OVH Cloud OVH Cloud

Comprend pas !

4 réponses
Avatar
Sivaller
procedure TForm1.Button1Click(Sender: TObject);
var h,h2,hc : hdc;
offscrbmp : hbitmap;
lpbi : BITMAPINFO;
v : integer;
xf,yf,BitmapInfoSize : word;
p4 : pointer;
begin
h := getDC(0);
hc := CreateCompatibleDC(h);
BitBlt(hc,100,100,100,100,h,100,100,SRCCOPY );
for xf := 200 to 300 do
for yf := 200 to 300 do setpixelv(hc,xf,yf,clred);


OffscrBmp := CreateCompatibleBitmap(hc, 100, 100);
for xf := 0 to 99 do
for yf := 0 to 99 do
Setpixel(hc,xf,yf,clred);
v := GetDiBits( hc, // handle of device context
offscrbmp, // handle of bitmap
0, // first scan line to set in destination bitmap
100, // number of scan lines to copy
@img, // address of array for bitmap bits
lpbi, // address of structure with bitmap data
DIB_RGB_COLORS // RGB or palette index
);
deleteobject(offscrbmp);
DeleteDC(hc);
releaseDC(0,h);

end;

J'essaye de lire le desktop , ça marche pas ,
pour debugger j'appelle la fonction Setpixel(x,y ,rouge ) et dans la
fonction GetDiBits je vois que des valeurs 0 dans la variable img ; donc ca
bug ! chez MS Win
Je devrai voir que des codes 0 mais avec un 255 , CE n'est pas le cas !

Pourquoi ça marche pa ?
Pourquoi !!???

Merci ;;;

4 réponses

Avatar
Sivaller
et ça ne marche pas non plus avec ça




BitmapInfoSize := sizeof(TBitmapInfo);

FillChar(lpbi, BitmapInfoSize, #0);

{Fill in the BitmapInfo structure}
lpbi.bmiHeader.biSize := sizeof(TBitmapInfoHeader);
lpbi.bmiHeader.biWidth := 100;
lpbi.bmiHeader.biHeight := 100;
lpbi.bmiHeader.biPlanes := 1;
lpbi.bmiHeader.biBitCount := 24;
lpbi.bmiHeader.biCompression := BI_RGB;
lpbi.bmiHeader.biSizeImage : ((lpbi.bmiHeader.biWidth *
longint(lpbi.bmiHeader.biBitCount)) div 8) *
lpbi.bmiHeader.biHeight;
lpbi.bmiHeader.biXPelsPerMeter := 0;
lpbi.bmiHeader.biYPelsPerMeter := 0;

lpbi.bmiHeader.biClrUsed := 0;
lpbi.bmiHeader.biClrImportant := 0;
Avatar
Vincent Burel
"Sivaller" wrote in message
news:452c0e04$0$27367$
procedure TForm1.Button1Click(Sender: TObject);
var h,h2,hc : hdc;
offscrbmp : hbitmap;
lpbi : BITMAPINFO;
v : integer;
xf,yf,BitmapInfoSize : word;
p4 : pointer;
begin
h := getDC(0);
hc := CreateCompatibleDC(h);
BitBlt(hc,100,100,100,100,h,100,100,SRCCOPY );



ici le BitBlt ne sert à rien, vous n'avez pas sélectionné de Bitmap dans la
mem_dc (hc)

for xf := 200 to 300 do
for yf := 200 to 300 do setpixelv(hc,xf,yf,clred);


OffscrBmp := CreateCompatibleBitmap(hc, 100, 100);
for xf := 0 to 99 do
for yf := 0 to 99 do
Setpixel(hc,xf,yf,clred);



pareil, à partir du moment ou vous n'avez pas fait de SelectObject de votre
bitmap dans votre hc, la Device contexte est null et fait une taille de 0
par 0.


v := GetDiBits( hc, // handle of device context



y'a pas d'image dans le hc....

J'essaye de lire le desktop , ça marche pas ,



ben oui, on a vu pourquoi.

pour debugger j'appelle la fonction Setpixel(x,y ,rouge ) et dans la
fonction GetDiBits je vois que des valeurs 0 dans la variable img ; donc


ca
bug ! chez MS Win



:-) réflexion d'amateur :-)

Je devrai voir que des codes 0 mais avec un 255 , CE n'est pas le cas !

Pourquoi ça marche pa ?
Pourquoi !!???



Parce que vous ne vous servez pas bien des API GDI et que vous ne lisez pas
assez les doc windows.

VB
Avatar
Sivaller
j'ai essayez ceci et ça ne marche pas

OffscrBmp := CreateCompatibleBitmap(hc, 100, 100);
//OffScrBmp := CreateBitmap(100, 100, 1, 24, @img);
selectobject(hc,offscrbmp);

for xf := 0 to 99 do
for yf := 0 to 99 do
Setpixelv(hc,xf,yf,clred);

{Fill in the BitmapInfo structure}
lpbi.bmiHeader.biSize := sizeof(TBitmapInfoHeader);
lpbi.bmiHeader.biWidth := 100;
lpbi.bmiHeader.biHeight := 100;
lpbi.bmiHeader.biPlanes := 1;
lpbi.bmiHeader.biBitCount := 24;
lpbi.bmiHeader.biCompression := BI_RGB;
lpbi.bmiHeader.biSizeImage : ((lpbi.bmiHeader.biWidth *
longint(lpbi.bmiHeader.biBitCount)) div 8) *
lpbi.bmiHeader.biHeight;
lpbi.bmiHeader.biXPelsPerMeter := 0;
lpbi.bmiHeader.biYPelsPerMeter := 0;

lpbi.bmiHeader.biClrUsed := 0;
lpbi.bmiHeader.biClrImportant := 0;



fillchar(img,sizeof(img),255);
v := GetDiBits( hc, // handle of device context
offscrbmp, // handle of bitmap
0, // first scan line to set in destination bitmap
100, // number of scan lines to copy
@img, // address of array for bitmap bits
lpbi, // address of structure with bitmap data
DIB_RGB_COLORS // RGB or palette index
);

Il lit que des codes 0 ;

Quoi faire pour lire le desktop
Avatar
Sivaller
pardon ça ne marche pas non plus avec ça

h := getDC(0);
hc := CreateCompatibleDC(h);
hB := CreateCompatibleBitmap(h, 100, 100);
hBitmapOld := SelectObject(hc, hb);
BitBlt(hc, 0, 0, 100, 100, h, 0, 0, SRCCOPY);

FillChar(lpbi, BitmapInfoSize, #0);

{Fill in the BitmapInfo structure}
lpbi.bmiHeader.biSize := sizeof(TBitmapInfoHeader);
lpbi.bmiHeader.biWidth := 100;
lpbi.bmiHeader.biHeight := 100;
lpbi.bmiHeader.biPlanes := 1;
lpbi.bmiHeader.biBitCount := 24;
lpbi.bmiHeader.biCompression := BI_RGB;
lpbi.bmiHeader.biSizeImage : ((lpbi.bmiHeader.biWidth *
longint(lpbi.bmiHeader.biBitCount)) div 8) *
lpbi.bmiHeader.biHeight;
lpbi.bmiHeader.biXPelsPerMeter := 0;
lpbi.bmiHeader.biYPelsPerMeter := 0;

lpbi.bmiHeader.biClrUsed := 0;
lpbi.bmiHeader.biClrImportant := 0;

fillchar(img,sizeof(img),255);
v := GetDiBits( hc, // handle of device context
hbitmapold, // handle of bitmap
0, // first scan line to set in destination bitmap
100, // number of scan lines to copy
@img, // address of array for bitmap bits
lpbi, // address of structure with bitmap data
DIB_RGB_COLORS // RGB or palette index
);
deleteobject(offscrbmp);
DeleteDC(hc);
releaseDC(0,h);

eh ouuuiiiiiii ;