aawolf comming.....
用Image1->Canvas->CopyRect不就可以了吗?
我正在做
Graphics::TBitmap *Bitmap;
Bitmap = new Graphics::TBitmap;
TRect MyRect, MyOther;
MyRect = Rect(0,0,50,50); //将来显示的位置区域
MyOther = Rect(100,100,150,150); //从BMP图上抠下的区域
Bitmap->LoadFromResourceName((int)HInstance, "CATBMP");//读取资源文件的一张大BMP图
Image1->Canvas->CopyRect(MyRect, Bitmap->Canvas, MyOther);
delete Bitmap;
绝对没错!我正做一个桌面的小猫乱跑的东东,就是从一张100多个小猫组成的大BMP上截取小图
还是没有解答!
用API函数:
取点
SetPixel
GetPixel
我的一段程序,直接读像素,可做参考,不是好办法:
Graphics::TBitmap *bitmap1 =new Graphics::TBitmap();
Graphics::TBitmap *bitmap2 =new Graphics::TBitmap();
Byte *ptr;
Byte *newscanline;
int x,y;
try{
bitmap1->LoadFromFile("picture\\" +lblcapcount->Caption +".bmp");
bitmap2->PixelFormat = bitmap1->PixelFormat;
}
catch(...){ }
bitmap2->Height =caph-1;
bitmap2->Width = capw-1;
for (y = capt; y < caph; y++){
ptr = static_cast<Byte*>(bitmap1->ScanLine[y]);
newscanline = static_cast<Byte*>(bitmap2->ScanLine[y-capt]);
for (x = capl*3; x < capw*3; x++)
newscanline[x-capl*3] = ptr[x];
};
Image1->Picture->LoadFromFile("E:\\图像库\\starso\\Star100.bmp");
TRect rect1;
rect = Rect(0, 0, 100, 100);
Image2->Canvas->CopyRect(rect1, Image1->Canvas, rect1);
我看大家答的很好啊!
CopyRect
BrushCopy
Draw(做动画常用它)
这几个函数都能实现你要求的功能