Si quelqu'un sait comment rendre compatible linux/macOs cette fonction je suis preneur !
Edit 2019-02-04 Mise à jour a cause de quelques bugs
Edit 2020-05-07 Mise à jour pour supporter le canal Alpha si il y a
Code : Tout sélectionner
Enumeration 1
#Effect_Normal
#Effect_Mirror_horizontal
#Effect_Rotate_180
#Effect_Mirror_vertical
#Effect_Mirror_horizontal_Rotate_270_CW
#Effect_Rotate_90_CW
#Effect_Mirror_Horizontal_Rotate_90_CW
#Effect_Rotate_270_CW
EndEnumeration
Procedure.i RotateImage(Image.i,Effect.l)
Protected Height.l = ImageHeight(Image)
Protected Width.l = ImageWidth(Image)
Protected sizeMax.l
Protected TmpImage.i
If Height > Width
sizeMax=Height
Else
sizeMax=Width
EndIf
TmpImage = CreateImage(#PB_Any,sizeMax,sizeMax,ImageDepth(Image))
Dim p.point(2)
Protected GrabWidth.l,GrabHeight.l
Select Effect.l
Case 0
FreeImage(TmpImage)
ProcedureReturn Image
Case 1 ; Horizontal (normal)
FreeImage(TmpImage)
ProcedureReturn Image
Case 2 ; Mirror horizontal
p(0)\x=0
p(0)\y=Height
p(1)\x=Width
p(1)\y=Height
p(2)\x=0
p(2)\y=0
GrabWidth=Width
GrabHeight=Height
Case 3 ; Rotate 180
p(0)\x=Width
p(0)\y=Height
p(1)\x=0
p(1)\y=Height
p(2)\x=Width
p(2)\y=0
GrabWidth=Width
GrabHeight=Height
Case 4 ; Mirror vertical
p(0)\x=Width
p(0)\y=0
p(1)\x=0
p(1)\y=0
p(2)\x=Width
p(2)\y=Height
GrabWidth=Width
GrabHeight=Height
Case 5 ; Mirror horizontal And rotate 270 CW
p(0)\x=0
p(0)\y=0
p(1)\x=0
p(1)\y=Width
p(2)\x=Height
p(2)\y=0
GrabWidth=Height
GrabHeight=Width
Case 6 ; Rotate 90 CW
p(0)\x=Height
p(0)\y=0
p(1)\x=Height
p(1)\y=Width
p(2)\x=0
p(2)\y=0
GrabWidth=Height
GrabHeight=Width
Case 7 ; Mirror horizontal And rotate 90 CW
p(0)\x=0
p(0)\y=0
p(1)\x=0
p(1)\y=Width
p(2)\x=Height
p(2)\y=0
GrabWidth=Height
GrabHeight=Width
Case 8 ; Rotate 270 CW
p(0)\x=0
p(0)\y=Width
p(1)\x=0
p(1)\y=0
p(2)\x=Height
p(2)\y=Width
GrabWidth=Height
GrabHeight=Width
EndSelect
Protected Dc.i
Dc = StartDrawing(ImageOutput(TmpImage))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0, 0, sizeMax, sizeMax, RGBA(0,0,255,0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(Image),0,0)
PlgBlt_(Dc,p(),Dc,0,0,Width,Height,0,0,0)
StopDrawing()
FreeImage(Image)
Protected NewImage.i
NewImage = GrabImage(TmpImage,#PB_Any,0,0,GrabWidth,GrabHeight)
FreeImage(TmpImage)
ProcedureReturn NewImage
EndProcedure