LazBarcodes: Add SaveToFile to save barcode images in graphics files.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7597 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
8563d58898
commit
5b34810a57
@ -14,7 +14,7 @@
|
||||
</SearchPaths>
|
||||
</CompilerOptions>
|
||||
<Description Value="Provides barcode 1D and 2D generation based in the 'C' zint library."/>
|
||||
<Version Major="1" Release="3"/>
|
||||
<Version Major="1" Release="4"/>
|
||||
<Files Count="1">
|
||||
<Item1>
|
||||
<Filename Value="..\src\ubarcodes.pas"/>
|
||||
|
@ -28,7 +28,7 @@ Change to BSD-license is done for backend and therefore for ZINT shared library
|
||||
the frontends and Qt4-backend the GPL is still valid. Since BSD-license is GPL-compatible
|
||||
this gives the possibility to include ZINT library in own products or link against it from
|
||||
own software."/>
|
||||
<Version Major="1" Release="3"/>
|
||||
<Version Major="1" Release="4"/>
|
||||
<Files Count="9">
|
||||
<Item1>
|
||||
<Filename Value="..\src\zint.pp"/>
|
||||
|
@ -42,6 +42,9 @@ public
|
||||
procedure CopyToClipboard(AWidth: Integer = -1; AHeight: Integer = -1);
|
||||
procedure PaintOnCanvas(const aTargetCanvas: TCanvas; const aRect: TRect);
|
||||
procedure Generate; virtual; abstract;
|
||||
procedure SaveToFile(const AFileName: String;
|
||||
AClass: TFPImageBitmapClass = nil;
|
||||
AWidth: Integer = -1; AHeight: Integer = -1);
|
||||
published
|
||||
property StrictSize: Boolean read GetStrictSize write SetStrictSize;
|
||||
property BackgroundColor: TColor read GetBackgroundColor write SetBackgroundColor default clWhite;
|
||||
@ -307,7 +310,8 @@ begin
|
||||
FBackgroundColor:=clWhite;
|
||||
FForegroundColor:=clBlack;
|
||||
FStrictSize:=true;
|
||||
SetInitialBounds(0,0,88,88);
|
||||
Width := 88;
|
||||
Height := 88;
|
||||
end;
|
||||
|
||||
destructor TLazBarcodeCustomBase.Destroy;
|
||||
@ -395,6 +399,29 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazBarcodeCustomBase.SaveToFile(const AFileName: String;
|
||||
AClass: TFPImageBitmapClass = nil;
|
||||
AWidth: Integer = -1; AHeight: Integer = -1);
|
||||
var
|
||||
bmp: TFPImageBitmap;
|
||||
begin
|
||||
if AClass = nil then
|
||||
bmp := TBitmap.Create
|
||||
else
|
||||
bmp := AClass.Create;
|
||||
if AWidth = -1 then AWidth := Width;
|
||||
if AHeight = -1 then AHeight := Height;
|
||||
try
|
||||
bmp.SetSize(AWidth, AHeight);
|
||||
bmp.Canvas.Brush.Color := clWhite;
|
||||
bmp.Canvas.FillRect(0, 0, bmp.Width, bmp.Height);
|
||||
PaintOnCanvas(bmp.Canvas, Rect(0, 0, bmp.Width, bmp.Height));
|
||||
bmp.SaveToFile(AFileName);
|
||||
finally
|
||||
bmp.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TLazBarcodeCustomText.GetText: UTF8String;
|
||||
begin
|
||||
Result:=FText;
|
||||
|
Loading…
Reference in New Issue
Block a user