당신은이 코드를 시도 BitBlt
기능
를 사용할 수 있습니다. 같은 비트 맵을 사용하려면
procedure CropBitmap(InBitmap, OutBitMap : TBitmap; X, Y, W, H :Integer);
begin
OutBitMap.PixelFormat := InBitmap.PixelFormat;
OutBitMap.Width := W;
OutBitMap.Height := H;
BitBlt(OutBitMap.Canvas.Handle, 0, 0, W, H, InBitmap.Canvas.Handle, X, Y, SRCCOPY);
end;
하고이 방법으로 사용할 수는
Var
Bmp : TBitmap;
begin
Bmp:=TBitmap.Create;
try
CropBitmap(Image1.Picture.Bitmap, Bmp, 10,0, 150, 150);
//do something with the cropped image
//Bmp.SaveToFile('Foo.bmp');
finally
Bmp.Free;
end;
end;
, 기능
procedure CropBitmap(InBitmap : TBitmap; X, Y, W, H :Integer);
begin
BitBlt(InBitmap.Canvas.Handle, 0, 0, W, H, InBitmap.Canvas.Handle, X, Y, SRCCOPY);
InBitmap.Width :=W;
InBitmap.Height:=H;
end;
이 버전을 시도하고이 방법으로 사용
Var
Bmp : TBitmap;
begin
Bmp:=Image1.Picture.Bitmap;
CropBitmap(Bmp, 10,0, 150, 150);
//do somehting with the Bmp
Image1.Picture.Assign(Bmp);
end;
고마워요. 두 번째 비트 맵을 필요로하지 않고이 작업을 수행하는 간단한 방법이 있습니까? 델파이의'Move' 루틴과 중복되는 소스와 목적지를 처리하는 것과 같은 방식으로, 2 차원 적으로 같은 것이 있습니까? – rossmcm
TBitmap의 ScanLine 속성과 함께 Move를 사용할 수 있지만 BitsPerPixel에 따라 픽셀의 바이트 크기를 계산해야합니다 –
두 번째 옵션이 하나의 비트 맵 만 사용하는지 확인하십시오. – RRUZ