咨询一个关于StretchDraw连续加载BMP的问题
我是想新建一个大的BMP,然后把两张或者多张BMP,统一画到一个BMP里,比如有两个BMP,高宽都是400,那么我新一个BMP高400,宽400,把两张图片并排画,代码如下:
if(!FileExists(".\\X.jpg") || !FileExists(".\\H.jpg")){ return;}Graphics::TBitmap *bmp = new Graphics::TBitmap();Graphics::TBitmap *bms = new Graphics::TBitmap();try{ bmp->Width = 400; bmp->Height = 800; bmp->PixelFormat = pf32bit; bms->PixelFormat = pf32bit; TJPEGImage *jpeg = new TJPEGImage(); try { jpeg->LoadFromFile(".\\X.jpg"); bms->Assign(jpeg); } __finally { delete jpeg; jpeg = NULL; } bms->SaveToFile("1.BMP"); bmp->Canvas->StretchDraw(Rect(0, 0, 400, 400),bms); bmp->SaveToFile("2.BMP"); TJPEGImage *jpeg1 = new TJPEGImage(); try { bms->FreeImage(); jpeg1->LoadFromFile(".\\H.jpg"); bms->Assign(jpeg1); } __finally { delete jpeg1; jpeg1 = NULL; } bms->SaveToFile("3.BMP"); bmp->Canvas->StretchDraw(Rect(400, 0, 800, 400),bms); bmp->SaveToFile("4.BMP");}__finally{ bmp->FreeImage(); delete bmp; bmp = NULL; bms->FreeImage(); delete bms; bms = NULL;}
bms->SaveToFile("3.BMP"); StretchBlt(bmp->Canvas->Handle ,0, 400, 400, 400,bms->Canvas->Handle,0,0,bms->Width,bms->Height,SRCCOPY); //bmp->Canvas->StretchDraw(Rect(0, 400, 800, 400),bms); bmp->SaveToFile("4.BMP");