Dec 16th, 2024, 02:14 PM
#1
Thread Starter
Fanatic Member
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
Dec 16th, 2024, 03:55 PM
#2
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
Dec 16th, 2024, 04:19 PM
#3
Thread Starter
Fanatic Member
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.
Dec 17th, 2024, 02:38 AM
#4
Thread Starter
Fanatic Member
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.
Attached Files
Last edited by tmighty2; Dec 17th, 2024 at 02:50 AM .
Dec 18th, 2024, 12:08 AM
#5
Thread Starter
Fanatic Member
Re: Why does .GetPathExtents not work? (cCairoContext)
Somebody gave me the answer, and I was able to fix the problem using CopyPath(Flat=true).
Attached Files
Dec 18th, 2024, 07:38 PM
#6
Thread Starter
Fanatic Member
Re: Why does .GetPathExtents not work? (cCairoContext)
No, I was wrong. It's not solved yet.
Dec 18th, 2024, 07:57 PM
#7
Thread Starter
Fanatic Member
Re: Why does .GetPathExtents not work? (cCairoContext)
Attached Files
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width