有一个image1里面显示了一个bmp,它的像素是320*240的,另外一个image2中通过设定宽为32,高为40,stretch为true,让bmp在image2中缩小为正常大小的十分之一显示出来。现在想逐像素扫描获取image2中的每个点的像素颜色,但是实际情况发现并不是这样,它扫描的像素并非image2中显示的全部,而是image1中那个bmp的左上角32*40这一小块。请问这是怎么回事?能用什么办法解决呢!?var
BMP : TBitmap;
begin
Image1.Width:= 32;
Image1.Height:= 24;
Image2.Width:= 32;
Image2.Height:= 24;
if openpicturedialog1.execute then
image1.Picture.loadfromfile(OpenPictureDialog1.filename);
Image1.Width:= 4*Image1.Width;
Image1.Height:= 4*Image1.Height;
BMP:=TBitmap.Create;
BMP.LoadFromFile(OpenPictureDialog1.filename);
image2.Picture.Bitmap:=BMP;
BMP.Free ;
下面就是循环扫描每个像素点
BMP : TBitmap;
begin
Image1.Width:= 32;
Image1.Height:= 24;
Image2.Width:= 32;
Image2.Height:= 24;
if openpicturedialog1.execute then
image1.Picture.loadfromfile(OpenPictureDialog1.filename);
Image1.Width:= 4*Image1.Width;
Image1.Height:= 4*Image1.Height;
BMP:=TBitmap.Create;
BMP.LoadFromFile(OpenPictureDialog1.filename);
image2.Picture.Bitmap:=BMP;
BMP.Free ;
下面就是循环扫描每个像素点
使用下面的方式Copy一下就OK了。StretchBlt(Image2.Picture.Bitmap.Canvas.Handle, 0, 0, Image2.Width, Image2.Height,
Image1.Picture.Bitmap.Canvas.Handle, 0, 0, Image1.Width, Image1.Height, SRCCOPY);