Merci Denis !
C'étais effectivement de ce côté qu'il fallait chercher.
J'ai utilisé un morceau de code de Gillou (
http://www.purebasic.fr/french/viewtopi ... f447c4fa13) :
Code : Tout sélectionner
; Ce code crée une capture partielle de l'écran, compresse la zone mémoire utilisée pour l'image, puis la décompresse et l'affiche
;****** Capture d'ecran sur une zone de 640x480
CreateImage(0,640,480)
DC = StartDrawing(ImageOutput(0))
BitBlt_(DC,0,0,ImageWidth(0),ImageHeight(0),GetDC_(GetDesktopWindow_()),0,0,#SRCCOPY )
StopDrawing()
;****** récupération de l'adresse de l'image (en fait d'une copie de l'image...)
ImageID0 = ImageID (0)
Hdc0 = CreateCompatibleDC_ ( GetDC_ ( ImageID0 ))
bmi.BITMAPINFO
bm.BITMAP
GetObject_ ( ImageID0 , 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
L=bm\bmWidth*bm\bmHeight*4
HList0 = AllocateMemory (L) ;<---- HList0 est l'@ de l'image, L sa "taille"
GetDIBits_ (hDC0, ImageID0 ,0,bm\bmHeight,HList0,bmi, #DIB_RGB_COLORS )
;****** on compresse l'image
HListComp = AllocateMemory (L+8)
t = ElapsedMilliseconds()
TailleCompress = PackMemory(HList0, HListComp, L,0)
delatT=ElapsedMilliseconds()-t
;****** on décompresse
HListDeComp = AllocateMemory (L+8)
Resultat = UnpackMemory(HListComp, HListDeComp)
;****** on crée une nouvelle image pour afficher le résultat
CreateImage(1,640,480)
ImageID1 = ImageID (1)
HDC1= StartDrawing ( ImageOutput (1))
SetDIBits_ (HDC1, ImageID1 ,0, ImageHeight (1), HListDeComp, bmi, #DIB_RGB_COLORS ) ;<---- on "remplit" l'image
Resultat = DrawText(10, 5, "Compression en "+Str(DelatT)+" ms pour passer de "+Str(L)+" octets à "+Str(TailleCompress)+" octets",$FF)
StopDrawing ()
;****** on affiche l'image
OpenWindow (1,0,0,640,480, "FastImageOutput Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered )
CreateGadgetList(WindowID(1))
ImageGadget(111,0,0,640,480,ImageID(1))
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Y'a plus qu'à insérer un transfert grâce à "SendNetworkData(Connexion, *BufferMemoire, Longueur)" entre compression et décompression pour envoyer l'image vers un client
CQFD ! Encore merci et bravo à ceux (Gillou et Denis ici) qui se (dé)battent avec succès avec les API windows. Chapeau bas.
