bcb 获取图片
我现在获取到一个控件的句柄但是这个控件不是Image
我想获取到该控件里面显示的图片该怎么获取也
HANDLE hBitmap = hWndArray[ctlIndex]; // 假设是个有效的值
if(hBitmap)
{
Image1->Picture->Bitmap->Handle = hBitmap;
}
这样直接赋值好像没得反映
[解决办法]
可以取每幅图片的像素,然后进行比较,判断时候相等!
可以参考delphi例子
procedure TForm1.Button1Click(Sender: TObject); type PRGBTripleArray = ^TRGBTripleArray; TRGBTripleArray = array[0..32767] of TRGBTriple; var x,y:integer; p0,p1: PRGBTripleArray; begin Image1.Picture.LoadFromFile( 'C:\WINNT\wallpaper.bmp '); Image2.Picture.LoadFromFile( 'C:\WINNT\wallpaper1.bmp '); if (Image1.Picture.Bitmap.Height <> Image2.Picture.Bitmap.Height)or (Image1.Picture.Bitmap.Width <> Image2.Picture.Bitmap.Width ) then begin caption:= '不同 '; Exit; end; Image1.Picture.Bitmap.PixelFormat :=pf24bit; Image2.Picture.Bitmap.PixelFormat :=pf24bit; for y:=0 to Image1.Picture.Bitmap.Height -1 do begin p0:=Image1.Picture.Bitmap.ScanLine[y]; p1:=Image2.Picture.Bitmap.ScanLine[y]; for x:=0 to Image1.Picture.Bitmap.Width -1 do if (p0[x].rgbtBlue =p1[x].rgbtBlue)and (p0[x].rgbtGreen =p1[x].rgbtGreen )and (p0[x].rgbtRed =p1[x].rgbtRed ) then begin caption:= '相同 '; end else begin caption:= '不同 '; Exit; end; end; end;