procedure NB( BmpSource, BmpDest : tbitmap ); var addrSource,addrDest:pointer; npix,heure,lim:dword; cr,cv,cb:byte; mR,mV,mB:word; begin addrsource:=bmpSource.ScanLine[bmpSource.height-1]; addrDest:=bmpDest.ScanLine[bmpSource.height-1]; npix:=bmpSource.height*bmpSource.width; asm push edi push esi mov eax,npix;shl eax,2;add eax,addrsource //l'assembleur permet d'utiliser de la même facon des pointeurs et des doubles-mots mov lim,eax //lim=addrbmp+4*npix mov edi,addrsource //edi stock l'addresse du pixel source en cours mov esi,addrDest //esi stock l'addresse du pixel destination en cours @b1: mov edx,dword [edi] //edx:8*0 8*r 8*v 8*b xor eax,eax;xor ecx,ecx;mov al,dl;mov cl,dh add ax,cx;shr edx,16;xor cx,cx;mov cl,dl add ax,cx //ax=cr+cv+cb xor edx,edx;mov ecx,3;idiv ecx //cnb=round((cr+cv+cb)/3) moyenne des trois composantes mov dl,al;shl edx,16;mov dl,al;mov dh,al mov dword [esi],edx //edx:8*0 8*cnb 8*cnb 8*cnb add edi,4;add esi,4 //saut de 32 bit, pixel suivant cmp edi,lim //boucle jusqu'à edi=lim jne @b1 pop esi pop edi end; end; procedure TForm1.Button3Click(Sender: TObject); var Wici: hdc; bitmap : TBitmap; begin DoubleBuffered := True; bitmap := TBitmap.Create; bitmap.PixelFormat := pf32bit; bitmap.Height := screen.Height; bitmap.Width := screen.width; form1.hide; image1.autosize := false; sleep(500); Wici := GetDesktopWindow; //donne le handle de l'écran BitBlt(bitmap.Canvas.handle, 0, 0, screen.width, screen.Height, getdc(wici), 0, 0, srcCopy);//copie l'écran vers image1 ReleaseDC(0, Wici); //libère NB(bitmap,bitmap); Image1.Picture.Bitmap.Assign(bitmap); form1.show; image1.autosize := true; bitmap.Free; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question