来自:房客 时间:01-1-17 22:40:57 ID:441256
1.拉伸TBITMAP到另一个TBITMAP 再传过去
stretchblt(BitMap1.canvas.handle,0,0,BitMap2.Width,BitMap2.Height,BitMap2.canvas.handle,0,0,BitMap1.Width,BitMap1.Height,srcand);
2.创建一指定大小TBitMap,BitMap2,用CopyRect, 将BitMap1中指定区域Copy到BitMap2中,最后用BitMap2的SaveToFile,将BitMap2保存即可.具体代码如下:
var
BitMap1, BitMap2: TBitMap;
YourRect: TRect;
begin
BitMap1 := TBitMap.Create;
BitMap1.LoadFromFile('OriginPictureFileName');
BitMap2 := TBitMap.Create;
BitMap2.Height := YourRect.Bottom - YourRect.Top;
BitMap2.Width := YourRect.Right - YourRect.Left;
BitMap2.CopyMode := cmSrcCopy;
BitMap2.CopyRect(YourRect, BitMap1.Canvas, YourRect);
BitMap2.SaveToFile('NewPictureFileName');
BitMap2.Free;
BitMap1.Free;
end