From 9426e4f37ccad471d4d3e715e06af3faeeef51d4 Mon Sep 17 00:00:00 2001 From: jesusr Date: Thu, 15 Nov 2012 21:17:53 +0000 Subject: [PATCH] PowerPDF, added properties to freely scale a picture, helps to fix issue 23326, bumped version to 0.9.10 git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2594 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/powerpdf/PReport.pas | 33 +++++++++++++++++++++++---- components/powerpdf/pack_powerpdf.lpk | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/components/powerpdf/PReport.pas b/components/powerpdf/PReport.pas index ecceb45dd..b2d21e959 100644 --- a/components/powerpdf/PReport.pas +++ b/components/powerpdf/PReport.pas @@ -486,6 +486,8 @@ type TPRImage = class(TPRItem) private FSharedName: string; + function GetScaleX: Single; + function GetScaleY: Single; procedure SetStretch(Value: boolean); procedure SetProportional(AValue: boolean); protected @@ -493,6 +495,7 @@ type FSharedImage: boolean; FStretch: boolean; FProportional: boolean; + FScaleX,FScaleY: Single; procedure SetPicture(Value: TPicture); virtual; procedure Paint; override; procedure Print(ACanvas: TPRCanvas; ARect: TRect); override; @@ -500,6 +503,8 @@ type public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + property ScaleX: Single read GetScaleX write FScaleX; + Property ScaleY: Single read GetScaleY write FScaleY; property SharedName: string read FSharedName write FSharedName; published property Picture: TPicture read FPicture write SetPicture; @@ -2443,7 +2448,7 @@ var i: integer; FIdx: integer; AWidth,AHeight: Integer; - RatioH,RatioW: Double; + WidthF,HeightF: Single; begin if (FPicture = nil) or (FPicture.Graphic = nil) or (FPicture.Graphic.Empty) {or not (FPicture.Graphic is TFPImageBitmap)} then @@ -2480,10 +2485,12 @@ begin CalcProportionalBounds(AWidth, AHeight); DrawXObject(Left, GetPage.Height - Top - AHeight, AWidth, AHeight, FXObjectName) end - else - DrawXObjectEx(Left, GetPage.Height - Top - FPicture.Height, - FPicture.Width, FPicture.Height, + else begin + WidthF := FPicture.Width * ScaleX; + HeightF := FPicture.Height * ScaleY; + DrawXObjectEx(Left, GetPage.Height - Top - HeightF, WidthF, HeightF, Left, GetPage.Height - Top - Height, Width, Height, FXObjectName); + end; end; procedure TPRImage.CalcProportionalBounds(var AWidth, AHeight: Integer); @@ -2507,6 +2514,8 @@ begin FPicture := TPicture.Create; FSharedImage := true; FStretch := true; + FScaleX := 1.0; + FScaleY := 1.0; Randomize; end; @@ -2530,6 +2539,22 @@ begin Invalidate; end; +function TPRImage.GetScaleX: Single; +begin + if FScaleX<=0 then + result := 1.0 + else + result := FScaleX; +end; + +function TPRImage.GetScaleY: Single; +begin + if FScaleY<=0 then + result := 1.0 + else + result := FScaleY; +end; + procedure TPRImage.SetProportional(AValue: boolean); begin if AValue <> FProportional then diff --git a/components/powerpdf/pack_powerpdf.lpk b/components/powerpdf/pack_powerpdf.lpk index 25b417c19..8ce3eca6a 100644 --- a/components/powerpdf/pack_powerpdf.lpk +++ b/components/powerpdf/pack_powerpdf.lpk @@ -24,7 +24,7 @@ - +