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 !
"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
"Sivaller" <sivaller.ni@voila.fr> wrote in message
news:452c0e04$0$27367$ba4acef3@news.orange.fr...
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.
"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.
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 );
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
);
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 );
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);
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);
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);