Set an image on a Canvas, top left corner. Rotate it 90 degrees anticlockwise. The rotated image is out by 1 pixel. Image width and height are even numbers (104 x 184) - so I suspect that might be the issue, but I don't recall seeing a wonky result using Luis's code:
viewtopic.php?f=12&t=38975
TestImageDownload
Edit: Perhaps rotate about 0,0 and then move-translate?
Code: Select all
Enumeration
#Win
#Canvas
#Img
EndEnumeration
UsePNGImageDecoder()
Procedure Win()
;#-------------
If OpenWindow(#Win, 0, 0, 220, 220, "Rotate 90", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(#Win, RGB(064,252,064))
CanvasGadget(#Canvas, 10, 10, 200, 200)
EndIf
EndProcedure
Procedure Vimg()
;#--------------
Protected dImgW.d, dImgH.d
If LoadImage(#Img, "C:\Test.png")
dImgW = ImageWidth(#Img)
dImgH = ImageHeight(#Img)
Debug "dImgW-->" + StrD(dImgW) + "<--"
Debug "dImgH-->" + StrD(dImgH) + "<--"
SetGadgetAttribute(#Canvas, #PB_Canvas_Image, ImageID(#Img))
Delay(2000) ;just to see original orientation
If StartVectorDrawing(CanvasVectorOutput(#Canvas))
VectorSourceColor(RGBA(255,255,255,255))
AddPathBox(0, 0, 220, 220)
FillPath()
MovePathCursor(0, 0)
MovePathCursor(dImgW * 0.50, dImgW * 0.50)
RotateCoordinates(dImgW * 0.50, dImgW * 0.50, -(90))
MovePathCursor(0, 0)
DrawVectorImage(ImageID(#Img), 255)
StopVectorDrawing()
EndIf
EndIf
EndProcedure
Win()
Vimg()
Repeat
Until WaitWindowEvent(1) = #PB_Event_CloseWindow