From fe2bea132795d293a57e4ce834c179521858d3b4 Mon Sep 17 00:00:00 2001 From: Dibo Date: Wed, 1 May 2013 18:52:26 +0200 Subject: Added method ImageFromByte in TfpgBaseImgAnim. Now animation can be loaded from memory, not only from filename --- src/gui/fpg_animation.pas | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/gui/fpg_animation.pas') diff --git a/src/gui/fpg_animation.pas b/src/gui/fpg_animation.pas index 36972877..ff58f755 100644 --- a/src/gui/fpg_animation.pas +++ b/src/gui/fpg_animation.pas @@ -31,6 +31,8 @@ uses type + { TfpgBaseImgAnim } + TfpgBaseImgAnim = class(TfpgWidget) private FFrameCount: integer; @@ -58,6 +60,8 @@ type public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + + procedure ImageFromByte(ABmp: Pointer; ASize: longword); end; @@ -161,6 +165,24 @@ begin Repaint; end; +procedure TfpgBaseImgAnim.ImageFromByte(ABmp: Pointer; ASize: longword); +begin + if ABmp=nil then + Exit; + + FTimer.Enabled := False; + FImage.Free; + FImage := CreateImage_BMP(ABmp, ASize); + if FTransparent then + begin + FImage.CreateMaskFromSample(0, 0); + FImage.UpdateImage; + end; + FImageFilename := 'byte'; // because handle paint check if file is set + RecalcImageWidth; + Repaint; +end; + constructor TfpgBaseImgAnim.Create(AOwner: TComponent); begin inherited Create(AOwner); -- cgit v1.2.3-70-g09d2 From 51e554f5d61a3766d1bd00e4440cf9b7cd73b385 Mon Sep 17 00:00:00 2001 From: Dibo Date: Wed, 1 May 2013 20:50:40 +0200 Subject: Added Graeme suggestions --- src/gui/fpg_animation.pas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gui/fpg_animation.pas') diff --git a/src/gui/fpg_animation.pas b/src/gui/fpg_animation.pas index ff58f755..29a80960 100644 --- a/src/gui/fpg_animation.pas +++ b/src/gui/fpg_animation.pas @@ -61,7 +61,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; - procedure ImageFromByte(ABmp: Pointer; ASize: longword); + procedure ImageFromByteArray(ABmp: Pointer; ASize: longword; AMaskSample: TPoint); end; @@ -165,7 +165,8 @@ begin Repaint; end; -procedure TfpgBaseImgAnim.ImageFromByte(ABmp: Pointer; ASize: longword); +procedure TfpgBaseImgAnim.ImageFromByteArray(ABmp: Pointer; ASize: longword; + AMaskSample: TPoint); begin if ABmp=nil then Exit; @@ -175,7 +176,7 @@ begin FImage := CreateImage_BMP(ABmp, ASize); if FTransparent then begin - FImage.CreateMaskFromSample(0, 0); + FImage.CreateMaskFromSample(AMaskSample.X, AMaskSample.Y); FImage.UpdateImage; end; FImageFilename := 'byte'; // because handle paint check if file is set -- cgit v1.2.3-70-g09d2