j'ai voulu voir ce que votre routine donne en temps réel...
voici le bout de code qui montre que ca tourne bien...
et puis je me demandais si on pouvait définir la couleur de fond de l'image tournée de la facon suivante ( mais c'est plus lent car ca ne filtre plus les points en dehors de l'image pour remplir tout le rectangle ) :
Code:
#Pi.f=3.14159265
ProcedureDLL.l RotateImageEx2(ImageID, Angle.f, CouleurFond)
Protected bmi.BITMAPINFO, bmi2.BITMAPINFO, hdc.l, NewImageID, Mem, n, nn, bm.BITMAP
Angle = Angle * #Pi / 180
Cos.f = Cos(Angle)
Sin.f = Sin(Angle)
GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = bm\bmWidth
bmi\bmiHeader\biHeight = bm\bmHeight
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
bmi2\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi2\bmiHeader\biWidth = bm\bmWidth * Abs(Cos) + bm\bmHeight * Abs(Sin)
bmi2\bmiHeader\biHeight = bm\bmHeight * Abs(Cos) + bm\bmWidth * Abs(Sin)
bmi2\bmiHeader\biPlanes = 1
bmi2\bmiHeader\biBitCount = 32
bmi2\bmiHeader\biCompression = #BI_RGB
Mem = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
If Mem
Mem2 = AllocateMemory(bmi2\bmiHeader\biWidth * bmi2\bmiHeader\biHeight * 4)
If Mem2
hdc = CreateCompatibleDC_(GetDC_(ImageID))
If hdc
GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS)
ReleaseDC_(0, hdc)
EndIf
CX1 = bm\bmWidth - 1
CY1 = bm\bmHeight - 1
CX2 = bmi2\bmiHeader\biWidth - 1
CY2 = bmi2\bmiHeader\biHeight - 1
Mem01 = Mem + bm\bmWidth * 4
Mem10 = Mem + 4
Mem11 = Mem01 + 4
Mem2Temp = Mem2
deb=-CX2/2 : fin=(CX2*2-CX2)/2
For nn = 0 To CY2
y1b.l = nn * 2 - CY2
Temp1.f = (CX1 - y1b * Sin)/2
Temp2.f = (CY1 + y1b * Cos)/2
For x1b = deb To fin
x1.f = Temp1 + x1b * Cos
y1.f = Temp2 + x1b * Sin
x2.l = x1
y2.l = y1
If x1 < x2
DEC x2
EndIf
If y1 < y2
DEC y2
EndIf
x2b = x2 + 1
y2b = y2 + 1
fx.f = x1 - x2
fy.f = y1 - y2
f00.f = 1 - fx
f10.f = 1 - fy
f01.f = f00 * fy
f00 * f10
f10 * fx
f11.f = fx * fy
MemTemp = (x2 + y2 * bm\bmWidth) * 4
DefType.l c00, c01, c11, c10
If x2 >= 0 And x2 <= CX1
If y2 >= 0 And y2 <= CY1
MOV Eax,Mem
ADD Eax,MemTemp
MOV Eax,[Eax]
MOV c00,Eax
Else
c00 = CouleurFond
EndIf
If y2b >= 0 And y2b <= CY1
MOV Eax,Mem01
ADD Eax,MemTemp
MOV Eax,[Eax]
MOV c01,Eax
Else
c01 = CouleurFond
EndIf
Else
c00 = CouleurFond
c01 = CouleurFond
EndIf
If x2b >= 0 And x2b <= CX1
If y2 >= 0 And y2 <= CY1
MOV Eax,Mem10
ADD Eax,MemTemp
MOV Eax,[Eax]
MOV c10,Eax
Else
c10 = CouleurFond
EndIf
If y2b >= 0 And y2b <= CY1
MOV Eax,Mem11
ADD Eax,MemTemp
MOV Eax,[Eax]
MOV c11,Eax
Else
c11 = CouleurFond
EndIf
Else
c10 = CouleurFond
c11 = CouleurFond
EndIf
DefType.l r1,r2,r3,r4 , g1,g2,g3,g4 , b1,b2,b3,b4
MOV Eax,c00
MOV Ebx,Eax
MOV Ecx,Eax
And Eax,$FF
MOV r1,Eax
And Ebx,$FF00
MOV g1,Ebx
And Ecx,$FF0000
MOV b1,Ecx
MOV Eax,c10
MOV Ebx,Eax
MOV Ecx,Eax
And Eax,$FF
MOV r2,Eax
And Ebx,$FF00
MOV g2,Ebx
And Ecx,$FF0000
MOV b2,Ecx
MOV Eax,c01
MOV Ebx,Eax
MOV Ecx,Eax
And Eax,$FF
MOV r3,Eax
And Ebx,$FF00
MOV g3,Ebx
And Ecx,$FF0000
MOV b3,Ecx
MOV Eax,c11
MOV Ebx,Eax
MOV Ecx,Eax
And Eax,$FF
MOV r4,Eax
And Ebx,$FF00
MOV g4,Ebx
And Ecx,$FF0000
MOV b4,Ecx
r = r1 * f00 + r2 * f10 + r3 * f01 + r4 * f11
g = g1 * f00 + g2 * f10 + g3 * f01 + g4 * f11
b = b1 * f00 + b2 * f10 + b3 * f01 + b4 * f11
MOV Eax,r
MOV Ebx,g
MOV Ecx,b
And Eax,$FF
And Ebx,$FF00
And Ecx,$FF0000
Or Eax,Ebx
Or Eax,Ecx
MOV Ebx,Mem2Temp
MOV [Ebx],Eax
Mem2Temp + 4
Next
Next
NewImageID = CreateImage(#PB_Any, bmi2\bmiHeader\biWidth, bmi2\bmiHeader\biHeight)
hdc = CreateCompatibleDC_(GetDC_(ImageID()))
If hdc
SetDIBits_(hdc, ImageID(), 0, bmi2\bmiHeader\biHeight, Mem2, @bmi2, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
ReleaseDC_(0, hdc)
EndIf
FreeMemory(Mem2)
EndIf
FreeMemory(Mem)
EndIf
ProcedureReturn NewImageID
EndProcedure
CreateImage(0, 80, 100)
StartDrawing(ImageOutput())
Box(0, 0, 80, 100, $6F6F6F)
Box(5, 5, 35, 45, $FF)
Box(40, 5, 35, 45, $FF00)
Box(5, 50, 35, 45, $FF0000)
Box(40, 50, 35, 45, $FFFFFF)
StopDrawing()
OpenWindow(0, 0, 0, 250, 300, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget, "Effect - Rotation d'image")
CreateGadgetList(WindowID())
TextGadget(0, 10, 10, 100, 15, "Image normale")
ImageGadget(1, 10, 25, 0, 0, UseImage(0))
TextGadget(2, 10, 135, 200, 15, "Image en rotation")
ImageGadget(3, 10, 150, 0, 0, 0)
CouleurFond = $AAFFAA
SetTimer_(WindowID(),0,1,0)
Repeat
Select WaitWindowEvent()
Case #WM_CLOSE : Break
Case #WM_TIMER
If Image
FreeImage(Image)
EndIf
Angle.f + 0.666666
If Angle > 360.0
Angle = 0
EndIf
Image.l = RotateImageEx2(UseImage(0),Angle,CouleurFond)
ResizeGadget(3,0,WindowHeight()-ImageHeight(),-1,-1)
SetGadgetState(3,UseImage(Image))
EndSelect
ForEver
KillTimer_(WindowID(),0)