procedure TForm1.imgCarPhotoClick(Sender: TObject);
var
bmpLicense,bmpDigital,bmpClipboard,bmpMask:TBitmap;
rgn:Hrgn;
CurrentX,CurrentY:integer;
begin
FilePath:=ExtractFilePath(Application.ExeName)+'tp\';
if CombineLicense=1 then
begin
if LicenseType=0 then //大型汽车
begin
FileName:='H!_.bmp';
end;
if LicenseType=1 then //小型汽车
begin
FileName:='!.bmp';
end;
if LicenseType=2 then //农用运输车
begin end;
if LicenseType=3 then //教练汽车
begin
FileName:='H%.bmp';
end;
if LicenseType=4 then //警用汽车
begin
FileName:='[email protected]';
end; bmpLicense:=TBitmap.Create;
bmpDigital:=TBitmap.Create;
bmpClipboard:=TBitmap.Create;
bmpMask:=TBitmap.Create;
self.DoubleBuffered:=True; //设置双缓冲
//调入牌照
imgLicense.Picture.Bitmap.LoadFromFile(FilePath+FileName);
bmpLicense.Assign(imgLicense.Picture.Bitmap);
//调入掩膜图
{
FileName:='@.bmp';
imgLicense.Picture.Graphic:=nil;
imgLicense.Picture.Bitmap.LoadFromFile(FilePath+FileName);
bmpMask.Assign(imgLicense.Picture.Bitmap);
}
//创建剪切区域
CurrentX:=Mouse.CursorPos.X-imgCarPhoto.Left-Panel1.Left;
CurrentY:=Mouse.CursorPos.Y-imgCarPhoto.Top-Panel1.Top-20;
rgn:=CreateRectRgn(CurrentX,CurrentY,CurrentX+bmpLicense.Width,CurrentY+bmpLicense.Height);
SelectClipRgn(imgCarPhoto.Canvas.Handle,rgn); //将该区域剪切到bmpClipboard
//合并图像
imgCarPhoto.Picture:=nil; //此行清空图片
//用掩膜图处理车牌图片
//BitBlt(bmpLicense.Canvas.Handle,0,0,bmpLicense.Width,bmpLicense.Height,bmpMask.Canvas.Handle,0,0,MERGEPAINT);
//用掩膜图处理背景
//BitBlt(imgCarPhoto.Canvas.Handle,CurrentX,CurrentY,bmpMask.Width,bmpMask.Height,bmpMask.Canvas.Handle,0,0,NOTSRCERASE);
//把处理过的车牌图片贴到背景上
BitBlt(imgCarPhoto.Canvas.Handle,CurrentX,CurrentY,bmpLicense.Width,bmpLicense.Height,bmpLicense.Canvas.Handle,0,0,SRCCOPY); //释放资源
bmpLicense.Free;
bmpMask.Free;
bmpClipboard.Free;
bmpDigital.Free;
end;
end;代码如上,只能将原图清空后再粘贴,怎么能不清空才能粘贴上去呢?
主要是BitBlt中的SRCCOPY(dwrop参数怎么用)?