You've already forked lazarus-ccr
lazbarcodes: Add method to copy a barcode image to clipboard.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5038 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -39,6 +39,7 @@ protected
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure CopyToClipboard(AWidth: Integer = -1; AHeight: Integer = -1);
|
||||||
procedure PaintOnCanvas(const aTargetCanvas: TCanvas; const aRect: TRect);
|
procedure PaintOnCanvas(const aTargetCanvas: TCanvas; const aRect: TRect);
|
||||||
procedure Generate; virtual; abstract;
|
procedure Generate; virtual; abstract;
|
||||||
published
|
published
|
||||||
@ -124,6 +125,9 @@ procedure Register;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
clipbrd;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
{$I tbarcodeqr.lrs}
|
{$I tbarcodeqr.lrs}
|
||||||
@ -296,6 +300,24 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazBarcodeCustomBase.CopyToClipboard(AWidth, AHeight: Integer);
|
||||||
|
var
|
||||||
|
bmp: TBitmap;
|
||||||
|
begin
|
||||||
|
if AWidth = -1 then AWidth := Width;
|
||||||
|
if AHeight = -1 then AHeight := Height;
|
||||||
|
bmp := TBitmap.Create;
|
||||||
|
try
|
||||||
|
bmp.SetSize(AWidth, AHeight);
|
||||||
|
bmp.Canvas.Brush.Color := clWhite;
|
||||||
|
bmp.Canvas.FillRect(0, 0, AWidth, AHeight);
|
||||||
|
PaintOnCanvas(bmp.Canvas, Rect(0, 0, AWidth, AHeight));
|
||||||
|
Clipboard.Assign(bmp);
|
||||||
|
finally
|
||||||
|
bmp.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLazBarcodeCustomBase.PaintOnCanvas(const aTargetCanvas: TCanvas;
|
procedure TLazBarcodeCustomBase.PaintOnCanvas(const aTargetCanvas: TCanvas;
|
||||||
const aRect: TRect);
|
const aRect: TRect);
|
||||||
begin
|
begin
|
||||||
|
Reference in New Issue
Block a user