[Résolu] Rotation d'image avec RotateCoordinates
Publié : lun. 17/juin/2024 9:39
Bonjour,
J’ai un peu de mal pour bien comprendre la lib « Vector ». J’aimerais juste faire une méthode de rotation d’image (avec ajustement de la taille de celle-ci).
Voilà ma routine actuelle :
merci d'avance, si quelqu'un peu m'aider.
Cordialement,
J’ai un peu de mal pour bien comprendre la lib « Vector ». J’aimerais juste faire une méthode de rotation d’image (avec ajustement de la taille de celle-ci).
Voilà ma routine actuelle :
Code : Tout sélectionner
Procedure.s ImageRotation(filename.s, filedest.s, angle.f)
CompilerIf #PB_Compiler_Debugger
Define.i itimer = ElapsedMilliseconds()
CompilerEndIf
Protected.s fileresult
Protected.i entrysize = FileSize(filename)
If entrysize <> -1 And entrysize <> -2 And entrysize > 0
Protected.i image = LoadImage(#PB_Any, filename)
If IsImage(image)
Protected.d CosA, SinA
Protected.i height, width, temp, img_w, img_h
CosA = Cos (Radian (angle))
SinA = Sin (Radian (angle))
width = ImageWidth (Image )
height = ImageHeight (Image )
img_w = Abs(height * SinA) + Abs(width * CosA)
img_h = Abs(height * CosA) + Abs(width * SinA)
temp = CreateImage(#PB_Any, img_w, img_h, 24, #White)
If IsImage(temp)
If StartVectorDrawing(ImageVectorOutput(temp))
VectorSourceColor(RGBA(255,255,255,255))
TranslateCoordinates(0, 0)
MovePathCursor (0, 0, #PB_Path_Default)
MovePathCursor (width * 0.5, height * 0.5, #PB_Path_Default)
RotateCoordinates (width * 0.5, height * 0.5, angle, #PB_Coordinate_User)
MovePathCursor (-width, -height, #PB_Path_Default)
DrawVectorImage (ImageID(image), 255, width, height)
StopVectorDrawing ()
EndIf
If SaveImage(temp, filedest, #PB_ImagePlugin_JPEG, QualityCompress, 24)
fileresult = filedest
EndIf
FreeImage(temp)
EndIf
FreeImage(image)
EndIf
EndIf
CompilerIf #PB_Compiler_Debugger
Debug "ROTATION : " + FormatDate("%hh:%ii:%ss", (ElapsedMilliseconds() - itimer) / 1000)
Debug "FILENAME : " + filename
CompilerEndIf
ProcedureReturn fileresult
EndProcedure
merci d'avance, si quelqu'un peu m'aider.
Cordialement,