Platoo VCL Web Components HelpTPLPicture

Contents - Methods - Properties

Helper class for image manipulations (wrapper to PLPict23.dll)


Description
Internal representation - truecolor device-independent bitmap (DIB).

Loading an image from file/stream - BMP, JPEG, TIFF, PNG, GIF, TGA, PCX, ....

Saving an image to file/stream - BMP, JPEG, TIFF, PNG.

Drawing directly into the image canvas (or HDC) - usable as offscreen bitmap.

Drawing an image into another canvas (or into HDC) - 1:1 or zoomed by factor.

Thread-safe (locking mechanism for using with unsafe VCL version).

At runtime, TPLPicture requires PLPict23.dll on search path ( Windowsetc).


TPLPicture - Methods

Contents - TPLPicture - Properties

~TPLPicture
Destructor

C++ declaration
__fastcall virtual ~TPLPicture(void)

BeginPaint
Begin painting into image canvas

Delphi declaration
function BeginPaint(bLockedPaint: Boolean): Boolean;
C++ declaration
bool __fastcall BeginPaint(bool bLockedPaint)

Description
bLockedPaint - Lock TPLPicture painting operations. Important in the case of multithreading.

Set bLockedPaint to TRUE, if your VCL graphics is not thread-safe (CBuilder1, Delphi2),

Otherwise set to FALSE (starting from CBuilder 4 and Delphi 4; we have not tested CBuilder 3 yet).

Don't forget to call EndPaint after your drawing is finished!

CheckPaintLibDllOk
Internal

Delphi declaration
function CheckPaintLibDllOk: Boolean;
C++ declaration
bool __fastcall CheckPaintLibDllOk(void)

Create
Create a new empty image object

Delphi declaration
constructor Create;

Description
The size is not determined (1x1 pixels).

Usage: before loading from file/stream.

CreateSize
Create a new empty image with determined width and height

Delphi declaration
constructor CreateSize(AWidth: Longint; AHeight: Longint);

Description
Usable before drawing into the image canvas.

Destroy
Destructor

Delphi declaration
destructor Destroy;

Draw
Draws an image into the canvas

Delphi declaration
procedure Draw(ACanvas: TCanvas; x: Integer; y: Integer);
C++ declaration
void __fastcall Draw(Graphics::TCanvas *ACanvas, int x, int y)

Description
ACanvas - where to draw

x,y - left upper corner in ACanvas

DrawDC
Draws an image into HDC

Delphi declaration
procedure DrawDC(dc: HDC; x: Integer; y: Integer);
C++ declaration
void __fastcall DrawDC(HDC dc, int x, int y)

Description
dc - device context, where to draw

x,y - left upper corner

EndPaint
End painting o n the image canvas

Delphi declaration
procedure EndPaint;
C++ declaration
void __fastcall EndPaint(void)

Description
At this point Canvas and dc are freed.

If previously BeginPaint was called requiring locking (BeginPaint(TRUE)), then this will also unlock other threads.

GetCanvas
Delphi declaration
function GetCanvas: TCanvas;
C++ declaration
Graphics::TCanvas *__fastcall GetCanvas(void)
GetFileLoadFilter
Delphi declaration
function GetFileLoadFilter: string;
C++ declaration
System::AnsiString __fastcall GetFileLoadFilter(void)
GetFileSaveFilter
Delphi declaration
function GetFileSaveFilter: string;
C++ declaration
System::AnsiString __fastcall GetFileSaveFilter(void)
GetHandle
Delphi declaration
function GetHandle: HBITMAP;
C++ declaration
HBITMAP __fastcall GetHandle(void)
GetHeight
Delphi declaration
function GetHeight: Longint;
C++ declaration
long __fastcall GetHeight(void)
GetWidth
Delphi declaration
function GetWidth: Longint;
C++ declaration
long __fastcall GetWidth(void)
LoadFromFile
Load (decode) image from file

Delphi declaration
function LoadFromFile(const FileName: string): Boolean;
C++ declaration
bool __fastcall LoadFromFile(const System::AnsiString FileName)

Description
Image type is detected automatically.

Warning: previous content and size will be overwritten.

LoadFromStream
Load (decode) image from stream

Delphi declaration
function LoadFromStream(InStream: TCustomMemoryStream): Boolean;
C++ declaration
bool __fastcall LoadFromStream(Classes::TCustomMemoryStream *InStream)

Description
Image type is detected automatically.

Warning: previous content and size will be overwritten.

Lock
Another way to lock an image before a thread-unsafe operation

Delphi declaration
procedure Lock;
C++ declaration
void __fastcall Lock(void)

Description
Don't forget to call UnLock, if the required operation is done!

SaveToBMPStream
Save (encode) an image into stream as BMP

Delphi declaration
function SaveToBMPStream(OutStream: TStream): Boolean;
C++ declaration
bool __fastcall SaveToBMPStream(Classes::TStream *OutStream)

SaveToFile
Save (encode) an image into a file

Delphi declaration
function SaveToFile(const FileName: string): Boolean;
C++ declaration
bool __fastcall SaveToFile(const System::AnsiString FileName)

Description
Image type will b e determined from t he filename extension (default BMP)

SaveToJPEGStream
Save (encode) an image into steam as JPEG with default quality

Delphi declaration
function SaveToJPEGStream(OutStream: TStream): Boolean;
C++ declaration
bool __fastcall SaveToJPEGStream(Classes::TStream *OutStream)

SaveToJPEGStreamQ
Save (encode) an image into steam as JPEG with custom quality

Delphi declaration
function SaveToJPEGStreamQ(OutStream: TStream; iQuality: Integer): Boolean;
C++ declaration
bool __fastcall SaveToJPEGStreamQ(Classes::TStream *OutStream, int iQuality)

Description
Parameter iQuality is t he BMP->JPEG conversion quality in percentages (0...100) - better quality means bigger size.

SaveToPNGStream
Save (encode) an image into steam as PNG

Delphi declaration
function SaveToPNGStream(OutStream: TStream): Boolean;
C++ declaration
bool __fastcall SaveToPNGStream(Classes::TStream *OutStream)

SaveToTIFFStream
Save (encode) an image into steam as TIFF

Delphi declaration
function SaveToTIFFStream(OutStream: TStream): Boolean;
C++ declaration
bool __fastcall SaveToTIFFStream(Classes::TStream *OutStream)

StretchDraw
Draws a n image into t he canvas, zoomed by factor

Delphi declaration
procedure StretchDraw(ACanvas: TCanvas; x: Integer; y: Integer; Factor: Double);
C++ declaration
void __fastcall StretchDraw(Graphics::TCanvas *ACanvas, int x, int y, double Factor)

Description
ACanvas - where to draw

x,y - left upper corner

StretchDrawDC
Draws a n image into HDC, zoomed by factor

Delphi declaration
procedure StretchDrawDC(dc: HDC; x: Integer; y: Integer; Factor: Double);
C++ declaration
void __fastcall StretchDrawDC(HDC dc, int x, int y, double Factor)

Description
dc - where to draw

x,y - left upper corner

TPLPicture
Constructor

C++ declaration
__fastcall virtual TPLPicture(void)

__fastcall virtual TPLPicture(long AWidth, long AHeight)

Description
Constructor without parameters creates a new empty image - usable before loading from file/stream.

Paramet e rized constructor creates a new empty image with a determined size - usable before drawing into the image canvas.

UnLock
Unlocking an image after a thread-unsafe operation

Delphi declaration
procedure UnLock;
C++ declaration
void __fastcall UnLock(void)


TPLPicture - Properties

Contents - TPLPicture - Methods

Canvas
Canvas for drawing o n the image

Delphi declaration
property Canvas: TCanvas read GetCanvas;
C++ declaration
__property Graphics::TCanvas *Canvas={ read=GetCanvas, nodefault }

Description
Canvas is available only between BeginPaint and EndPaint !

dc
Image's device context (HDC) for drawing

Delphi declaration
property dc: HDC read hMemDC;
C++ declaration
__property HDC dc={ read=hMemDC, nodefault }

Description
dc is available only between BeginPaint and EndPaint !

FileLoadFilter
Supported imagefiles filter for OpenFile dialog

Delphi declaration
property FileLoadFilter: string read GetFileLoadFilter;
C++ declaration
__property System::AnsiString FileLoadFilter={ read=GetFileLoadFilter, nodefault }

FileSaveFilter
Supported imagefiles filter for SaveFile dialog

Delphi declaration
property FileSaveFilter: string read GetFileSaveFilter;
C++ declaration
__property System::AnsiString FileSaveFilter={ read=GetFileSaveFilter, nodefault }

Handle
Handle to image's internal representation (Windows HBITMAP)

Delphi declaration
property Handle: HBITMAP read GetHandle;
C++ declaration
__property HBITMAP Handle={ read=GetHandle, nodefault }

Height
Image height in pixels

Delphi declaration
property Height: Longint read GetHeight;
C++ declaration
__property long Height={ read=GetHeight, nodefault }

Description
Value is not changeable (set in t he constructor or when loaded from file/stream)

Locked
Check if image is locked

Delphi declaration
property Locked: Boolean read FLocked;
C++ declaration
__property bool Locked={ read=FLocked, nodefault }

Width
Image width in pixels

Delphi declaration
property Width: Longint read GetWidth;
C++ declaration
__property long Width={ read=GetWidth, nodefault }

Description
Value is not changeable (set in t he constructor or or when loaded from file/stream)