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?
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?
>
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?
>