不多说话,直接上源码:
type TFMXCanvasHelper = class helper for TCanvas public procedure StretchDraw(R: TRectF; ABitmap: TBitmap; ADoFit, AHighSpeed: Boolean); end; { TFMXCanvasHelper } procedure TFMXCanvasHelper.StretchDraw(R: TRectF; ABitmap: TBitmap; ADoFit, AHighSpeed: Boolean); var SR: TRectF; begin SR := RectF(0, 0, ABitmap.Width, ABitmap.Height); if ADoFit then R := SR.FitInto(R); DrawBitmap(ABitmap, SR, R, 1, AHighSpeed); end;
参数说明:
- R :绘制目标区域
- ABitmap:要绘制的位图内容
- ADoFit:是否按比例自适应目标区域大小
- AHighSpeed:是否高速绘图,如果你是要绘制边缘清晰的位图,如二维码,那就要设置为 true,否则设置为 false