class function TdbDocImg.ConvertPICintoJPG(cPic: TPicture;
pWidth, pHeight: Integer): TJpegImage;
var
tBMP: TBitmap;
begin
Result := TJpegImage.Create;
// if (pWidth > 0) or (pHeight > 0) then
// begin
try
tBMP := TBitmap.Create; // 创建一个过渡性BMP图片,用于更改图片尺寸
if pWidth <= 0 then
pWidth := cPic.width; // 若pWidth为有效值则改变tBMP宽度,否则不变
if pHeight <= 0 then
pHeight := cPic.height; // 若pHeight为有效值则改变tBMP高度,否则不变
tBMP.width := pWidth;
tBMP.height := pHeight;
tBMP.Canvas.StretchDraw(tBMP.Canvas.ClipRect, cPic.Graphic); // 按照新尺寸重画图形
Result.Assign(tBMP);
finally
tBMP.Free;
end;
// end
// else
// Result.Assign(cPic);
end;