J'ai une IMA sur ce code, quelqu'un pourrait-il m'éclairer ?
Code : Tout sélectionner
UsePNGImageDecoder()
UseJPEGImageDecoder()
CreateImage(0, 640, 480, 32, #PB_Image_Transparent)
Procedure OpenImage()
file$ = OpenFileRequester("Ouvrir une image", "", "Png, Jpg|*.png|*.jpg",0)
If file$ <> ""
If LoadImage(0, file$)
W = ImageWidth(0)
H = ImageHeight(0)
If StartDrawing(ImageOutput(0))
Buffer = DrawingBuffer()
If Buffer <> 0
pixelFormat = DrawingBufferPixelFormat()
lineLength = DrawingBufferPitch()
If pixelFormat = #PB_PixelFormat_32Bits_BGR | #PB_PixelFormat_ReversedY
For i = 0 To W - 1
For j = 0 To H - 1
b1 = PeekA(Buffer + 4 * j + i * lineLength);Bleu
g1 = PeekA(Buffer + 4 * j + i * lineLength + 1);Vert
r1 = PeekA(Buffer + 4 * j + i * lineLength + 2);Rouge
;Debug Str(r1) + "/" + Str(g1) + "/" + Str(b1)
; on effectue l'operation
r = 255 - r1
g = 255 - g1
b = 255 - b1
; on poke le pixel
PokeA(Buffer + 4 * j + i * lineLength, b);Bleu
PokeA(Buffer + 4 * j + i * lineLength + 1, g);Vert
PokeA(Buffer + 4 * j + i * lineLength + 2, r);Rouge
Next j
Next i
EndIf
StopDrawing()
EndIf
Debug "ok"
EndIf
SetGadgetState(0, ImageID(0))
EndIf
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "Inverse color", #PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_Maximize)
ImageGadget(0, 0,0,640,480,ImageID(0))
CreateMenu(0,WindowID(0))
MenuTitle("Image")
MenuItem(0, "Ouvrir une image")
Repeat
Event = WaitWindowEvent()
EventMenu = EventMenu()
EventWindow = EventWindow()
Select Event
Case #PB_Event_Menu
Select EventMenu
Case 0
OpenImage()
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
Until Quit = 1
EndIf

merci
