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
This commit is contained in:
jesusr
2012-11-15 21:17:53 +00:00
parent 106fd8d85b
commit 9426e4f37c
2 changed files with 30 additions and 5 deletions

View File

@ -486,6 +486,8 @@ type
TPRImage = class(TPRItem) TPRImage = class(TPRItem)
private private
FSharedName: string; FSharedName: string;
function GetScaleX: Single;
function GetScaleY: Single;
procedure SetStretch(Value: boolean); procedure SetStretch(Value: boolean);
procedure SetProportional(AValue: boolean); procedure SetProportional(AValue: boolean);
protected protected
@ -493,6 +495,7 @@ type
FSharedImage: boolean; FSharedImage: boolean;
FStretch: boolean; FStretch: boolean;
FProportional: boolean; FProportional: boolean;
FScaleX,FScaleY: Single;
procedure SetPicture(Value: TPicture); virtual; procedure SetPicture(Value: TPicture); virtual;
procedure Paint; override; procedure Paint; override;
procedure Print(ACanvas: TPRCanvas; ARect: TRect); override; procedure Print(ACanvas: TPRCanvas; ARect: TRect); override;
@ -500,6 +503,8 @@ type
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; 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; property SharedName: string read FSharedName write FSharedName;
published published
property Picture: TPicture read FPicture write SetPicture; property Picture: TPicture read FPicture write SetPicture;
@ -2443,7 +2448,7 @@ var
i: integer; i: integer;
FIdx: integer; FIdx: integer;
AWidth,AHeight: Integer; AWidth,AHeight: Integer;
RatioH,RatioW: Double; WidthF,HeightF: Single;
begin begin
if (FPicture = nil) or (FPicture.Graphic = nil) or if (FPicture = nil) or (FPicture.Graphic = nil) or
(FPicture.Graphic.Empty) {or not (FPicture.Graphic is TFPImageBitmap)} then (FPicture.Graphic.Empty) {or not (FPicture.Graphic is TFPImageBitmap)} then
@ -2480,10 +2485,12 @@ begin
CalcProportionalBounds(AWidth, AHeight); CalcProportionalBounds(AWidth, AHeight);
DrawXObject(Left, GetPage.Height - Top - AHeight, AWidth, AHeight, FXObjectName) DrawXObject(Left, GetPage.Height - Top - AHeight, AWidth, AHeight, FXObjectName)
end end
else else begin
DrawXObjectEx(Left, GetPage.Height - Top - FPicture.Height, WidthF := FPicture.Width * ScaleX;
FPicture.Width, FPicture.Height, HeightF := FPicture.Height * ScaleY;
DrawXObjectEx(Left, GetPage.Height - Top - HeightF, WidthF, HeightF,
Left, GetPage.Height - Top - Height, Width, Height, FXObjectName); Left, GetPage.Height - Top - Height, Width, Height, FXObjectName);
end;
end; end;
procedure TPRImage.CalcProportionalBounds(var AWidth, AHeight: Integer); procedure TPRImage.CalcProportionalBounds(var AWidth, AHeight: Integer);
@ -2507,6 +2514,8 @@ begin
FPicture := TPicture.Create; FPicture := TPicture.Create;
FSharedImage := true; FSharedImage := true;
FStretch := true; FStretch := true;
FScaleX := 1.0;
FScaleY := 1.0;
Randomize; Randomize;
end; end;
@ -2530,6 +2539,22 @@ begin
Invalidate; Invalidate;
end; 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); procedure TPRImage.SetProportional(AValue: boolean);
begin begin
if AValue <> FProportional then if AValue <> FProportional then

View File

@ -24,7 +24,7 @@
<CompilerPath Value="$(CompPath)"/> <CompilerPath Value="$(CompPath)"/>
</Other> </Other>
</CompilerOptions> </CompilerOptions>
<Version Minor="9" Release="9"/> <Version Minor="9" Release="10"/>
<Files Count="12"> <Files Count="12">
<Item1> <Item1>
<Filename Value="PdfTypes.pas"/> <Filename Value="PdfTypes.pas"/>