From beb50d953be276106e166c1a1c6ed33761bf0627 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 8 Apr 2013 09:04:35 +0100 Subject: New overloaded LoadImage_PNG() This allows us to read the image from a byte array, just like we do with BMP images. --- src/corelib/fpg_imgfmt_png.pas | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/corelib/fpg_imgfmt_png.pas b/src/corelib/fpg_imgfmt_png.pas index c0659d2e..c95150e4 100644 --- a/src/corelib/fpg_imgfmt_png.pas +++ b/src/corelib/fpg_imgfmt_png.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2012 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -31,6 +31,7 @@ uses function LoadImage_PNG(const AFileName: TfpgString): TfpgImage; overload; function LoadImage_PNG(AStream: TStream): TfpgImage; overload; +function LoadImage_PNG(const AImageData: Pointer; const AImageDataSize: LongWord): TfpgImage; overload; function LoadImage_PNG(AInstance: THandle; const AResName: String; AResType: PChar): TfpgImage; overload; function LoadImage_PNGcrop(const AMaxWidth, AMaxHeight: integer; const AFileName: TfpgString): TfpgImage; @@ -114,6 +115,19 @@ begin end; end; +function LoadImage_PNG(const AImageData: Pointer; const AImageDataSize: LongWord): TfpgImage; +var + s: TMemoryStream; +begin + s := TMemoryStream.Create; + try + s.Write(AImageData^, AImageDataSize); + Result := LoadImage_PNG(s); + finally + s.Free; + end; +end; + function LoadImage_PNG(AInstance: THandle; const AResName: String; AResType: PChar): TfpgImage; var res: TResourceStream; -- cgit v1.2.3-70-g09d2