Why does .GetPathExtents not work? (cCairoContext)
In the following code, GetPathExtents never fills the values.
I don't see why.
Thank you for any help!
Code:
Public Sub DrawTo(ByRef uDestCC As cCairoContext, ByVal uLeft As Long, ByVal uTop As Long)
uDestCC.Save
Dim Matrix_Plan As cCairoMatrix
Set Matrix_Plan = Cairo.CreateIdentityMatrix
Dim dblOffx As Double
Dim dblOffy As Double
dblOffx = Me.OffsetFactorX * ((m_Img.Width * (Me.ScaleFactorW)) / 2)
dblOffy = Me.OffsetFactorY * ((m_Img.Height * (Me.ScaleFactorH)) / 2)
Matrix_Plan.TranslateCoords uLeft + dblOffx, uTop + dblOffy
' Apply rotation
Matrix_Plan.RotateCoordsDeg m_sngAngleDeg
' Scale and center the image
Matrix_Plan.ScaleCoords Me.ScaleFactorW, Me.ScaleFactorH
Matrix_Plan.TranslateCoords -(m_Img.Width / 2) - (Me.CenterOffsetX / 2), -(m_Img.Height / 2) - (Me.CenterOffsetY / 2)
Set uDestCC.matrix = Matrix_Plan
Dim x1 As Double
Dim x2 As Double
Dim y1 As Double
Dim y2 As Double
Dim dw As Double
Dim dh As Double
'these values are always 0:
uDestCC.GetPathExtents x1, y1, x2, y2 '<- retrieve TopLeft- and BottomRight-points of the Bounding-Rect
dw = Abs(x2 - x1)
dh = Abs(y2 - y1)
Debug.Assert dh = 0
Debug.Assert dw = 0
uDestCC.RenderSurfaceContent m_Img, 0, 0, , , CAIRO_FILTER_BEST, m_dblAlpha
uDestCC.Restore
'to check the extents
DrawRectangle uDestCC, x1, y1, dw, dh, 0, vbRed, 0.2, vbBlack, 1, 1
End Sub
Re: Why does .GetPathExtents not work? (cCairoContext)
It doesn't look like you've drawn anything that would generate a path yet. For example, if you put a path "drawing" call right before your GetPathExtents, then values will be filled into the appropriate variables:
Code:
uDestCC.Rectangle 100, 200, 600, 500
Re: Why does .GetPathExtents not work? (cCairoContext)
Thank you. The problem with this approach is
1) rotating makes the .GetPathExtents have weird values
2) I seem to be unable to "remove" this rectangle by using .Save / .Restore.
1 Attachment(s)
Re: Why does .GetPathExtents not work? (cCairoContext)
I have attached a sample project.
I believe that this problem has not been discussed before.
Can you please have a look?
I can not get rid of the rectangle, and my calculation seems to be just wrong.
When you think "Oh, it does work!", then please check the checkboxes "Animate ScaleFactorW" to see the behaviour.
1 Attachment(s)
Re: Why does .GetPathExtents not work? (cCairoContext)
Somebody gave me the answer, and I was able to fix the problem using CopyPath(Flat=true).
Re: Why does .GetPathExtents not work? (cCairoContext)
No, I was wrong. It's not solved yet.
1 Attachment(s)
Re: Why does .GetPathExtents not work? (cCairoContext)