有问怎样切图的,这里解释一下。首先需要在lazarus中装一下控件:RGBA controls,忘记连接了,自己去搜。
var
BGRABmpPart, BGRAStretch: TBGRABitmap;
i,j: Integer;
fn,fnJpg,fnPng: string;
Rect:TRect;
begin
// 加载完整图片
BGRABmpAll := TBGRABitmap.Create(utf8ToSys(EditSrcPic.Text));
ImageAll.Picture.LoadFromFile((EditSrcPic.Text));
// 显示打开图片的宽度及高度
memo1.Lines.Add('图片宽度:' + intToStr(BGRABmpAll.Width) + '; 图片高度:' + intToStr(BGRABmpAll.Height));
// 完整预览选择的图片
BGRAStretch := BGRABmpAll.Resample(Panel1.Width, Panel1.Height) as TBGRABitmap;
BGRABmpPart := TBGRABitmap.Create(256, 256);
for i := 0 to 1 do
for j := 0 to 1 do
begin
Rect.TopLeft:=Point(256 * i, 256 * j);
Rect.BottomRight:=Point(256 * (i + 1), 256 * (j + 1));
BGRABmpAll.DrawPart(Rect, BGRABmpPart.Canvas, 0, 0, true);
if (i = 0) and (j = 0) then
begin
BGRABmpAll.DrawPart(Rect, Image0.Canvas, 0, 0, true);
memo1.Lines.Add('第1样张图片显示完毕,图片加黑边为正常。');
end;
fnJpg := extractFilePath(paramStr(0)) + intToStr(i) + '_' + intToStr(j) + '.jpg';
BGRABmpPart.SaveToFile(fnJpg);
memo1.Lines.Add('测试图片存储为:' + sysToUtf8(fnJpg));
end;
memo1.Lines.Add('测试图片处理完毕。');
BGRABmpPart.Free;
BGRAStretch.Free;
这里资源非常多,需要什么自己去找。