Scaling problems using API Graphics


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Scaling problems using API Graphics

Hybrid View

  1. #1
    Allen Johnson Guest

    Scaling problems using API Graphics



    I use the following code to create polygons in a picture object,

    hBrush = CreateSolidBrush(CheckSysColor(m_FillColor))
    oldBrush = SelectObject(m_hDC, hBrush)
    Call BeginPath(m_hDC)
    Call Polyline(m_hDC, PolyPts(0), UBound(PolyPts) + 1)
    Call EndPath(m_hDC)

    If m_Filled And m_Outlined Then
    Call StrokeAndFillPath(m_hDC)
    ElseIf m_Filled Then
    Call FillPath(m_hDC)
    ElseIf m_Outlined Then
    Call StrokePath(m_hDC)
    End If

    Call SelectObject(m_hDC, oldBrush)
    Call DeleteObject(hBrush)

    Where polypts() is a pointAPI type array containing coordinates to draw the
    points.
    But when I scale the picture using picture1.scale (x1,y1) - (x2,y2)
    and try to draw the polygon to the window scale, the resultant polygon isn't
    drawn to
    the correct scale.

    I've tried the .scaleX .scaleY methods but they don't seem to work either:

    With Picture1
    PolyPts(0).X = .ScaleX(x3, .ScaleMode, vbTwips)
    End with

    Any suggestions?


  2. #2
    Jim Deutch Guest

    Re: Scaling problems using API Graphics

    API drawing functions use pixel coordinates and ignore the picturebox
    scalemode. I suggest you set the scalemode to pixels and write your own
    (very simple!) coordinate transformation functions.

    Jim Deutch

    Allen Johnson wrote in message <39071bc0$1@news.devx.com>...
    >
    >
    >I use the following code to create polygons in a picture object,
    >
    > hBrush = CreateSolidBrush(CheckSysColor(m_FillColor))

    <snip>
    >Where polypts() is a pointAPI type array containing coordinates to draw the
    >points.
    >But when I scale the picture using picture1.scale (x1,y1) - (x2,y2)
    >and try to draw the polygon to the window scale, the resultant polygon

    isn't
    >drawn to
    >the correct scale.
    >
    >I've tried the .scaleX .scaleY methods but they don't seem to work either:
    >
    >With Picture1
    > PolyPts(0).X = .ScaleX(x3, .ScaleMode, vbTwips)
    >End with
    >
    >Any suggestions?
    >




  3. #3
    Jim Deutch Guest

    Re: Scaling problems using API Graphics

    API drawing functions use pixel coordinates and ignore the picturebox
    scalemode. I suggest you set the scalemode to pixels and write your own
    (very simple!) coordinate transformation functions.

    Jim Deutch

    Allen Johnson wrote in message <39071bc0$1@news.devx.com>...
    >
    >
    >I use the following code to create polygons in a picture object,
    >
    > hBrush = CreateSolidBrush(CheckSysColor(m_FillColor))

    <snip>
    >Where polypts() is a pointAPI type array containing coordinates to draw the
    >points.
    >But when I scale the picture using picture1.scale (x1,y1) - (x2,y2)
    >and try to draw the polygon to the window scale, the resultant polygon

    isn't
    >drawn to
    >the correct scale.
    >
    >I've tried the .scaleX .scaleY methods but they don't seem to work either:
    >
    >With Picture1
    > PolyPts(0).X = .ScaleX(x3, .ScaleMode, vbTwips)
    >End with
    >
    >Any suggestions?
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center