From d4deaa39caefad1e30e699eb9d0d9fca973c5352 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 24 Sep 2017 07:48:22 +0000 Subject: [PATCH] * Add clipping git-svn-id: trunk@37308 - --- packages/fcl-image/src/fpimgbarcode.pp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/fcl-image/src/fpimgbarcode.pp b/packages/fcl-image/src/fpimgbarcode.pp index be664efb02..b55a69e144 100644 --- a/packages/fcl-image/src/fpimgbarcode.pp +++ b/packages/fcl-image/src/fpimgbarcode.pp @@ -31,6 +31,7 @@ Type TFPDrawBarCode = Class private FCanvas: TFPCustomCanvas; + FClipping: Boolean; FEncoding: TBarcodeEncoding; FImage: TFPCustomImage; FRect: TRect; @@ -71,6 +72,8 @@ Type Property Encoding : TBarcodeEncoding Read FEncoding Write SetEncoding; // Text to draw. Property Text : String Read FText Write FText; + // If true, the barcode will be clipped if it falls outside rect. + Property Clipping : Boolean Read FClipping Write FClipping; end; Function DrawBarCode(Img : TFPCustomImage; S : String; E : TBarcodeEncoding; aWidth : Integer = 1; AWeight : Double = 2.0) : Boolean; @@ -191,9 +194,8 @@ Function TFPDrawBarCode.Draw : Boolean; Var Cnv : TFPCustomCanvas; - i: integer; + I,L,MaxWidth, W, H : integer; xOffset: integer; - w, h: integer; BarRect : TRect; BP : TBarParams; Data : TBarTypeArray; @@ -210,7 +212,10 @@ begin Cnv.Brush.Style:=bsSolid; Cnv.FillRect(Rect); Cnv.Pen.Width := 1; - for i:=0 to Length(Data)-1 do + I:=0; + L:=Length(Data); + MaxWidth:=Rect.Right-Rect.Left; + While (I