mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 22:00:20 +02:00
added raw image examples
git-svn-id: trunk@4379 -
This commit is contained in:
parent
bda4fff627
commit
757fc41c8d
@ -177,11 +177,13 @@ type
|
||||
//------------------------------------------------------------------------------
|
||||
// raw image data
|
||||
type
|
||||
{ Colorformat: Higher values means higher intensity.
|
||||
For example: Red=0 means no red, Alpha=0 means transparent }
|
||||
TRawImageColorFormat = (
|
||||
ricfRGBA, // one pixel contains red, green, blue and alpha
|
||||
// If AlphaPrec=0 then there is no alpha.
|
||||
// Same for RedPrec, GreenPrec and BluePrec.
|
||||
ricfGray // R=G=B. The Red stores the Gray.
|
||||
ricfGray // R=G=B. The Red stores the Gray. AlphaPec can be >0.
|
||||
);
|
||||
|
||||
TRawImageByteOrder = (
|
||||
@ -258,6 +260,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.18 2003/07/07 13:19:08 mattias
|
||||
added raw image examples
|
||||
|
||||
Revision 1.17 2003/07/04 22:06:49 mattias
|
||||
implemented interface graphics
|
||||
|
||||
|
@ -374,6 +374,7 @@ end;
|
||||
Returns the client rectangle of a control. Left and Top are always 0.
|
||||
The client rectangle is the size of the inner area of a control, where the
|
||||
child controls are visible.
|
||||
A child control with Align=alClient will completely fill the clientrect.
|
||||
------------------------------------------------------------------------------}
|
||||
Function GetClientRect(handle : HWND; var Rect : TRect) : Boolean;
|
||||
begin
|
||||
@ -1659,6 +1660,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.92 2003/07/07 13:19:08 mattias
|
||||
added raw image examples
|
||||
|
||||
Revision 1.91 2003/07/07 07:59:34 mattias
|
||||
made Size_SourceIsInterface a flag
|
||||
|
||||
|
@ -37,7 +37,64 @@ uses
|
||||
type
|
||||
{ TLazIntfImage }
|
||||
{ This descendent of TFPCustomImage stores its image data as raw images and
|
||||
is therefore able to directly interchange images with the LCL interfaces. }
|
||||
is therefore able to directly interchange images with the LCL interfaces.
|
||||
|
||||
Usage examples:
|
||||
|
||||
1. Loading a .xpm file into a TBitmap:
|
||||
|
||||
var
|
||||
BmpHnd,MaskHnd: HBitmap;
|
||||
Bitmap1: TBitmap;
|
||||
IntfImg1: TLazIntfImage;
|
||||
Reader: TLazReaderXPM;
|
||||
begin
|
||||
// create a bitmap (or use an existing one)
|
||||
Bitmap1:=TBitmap.Create;
|
||||
// create the raw image
|
||||
IntfImg1:=TLazIntfImage.Create(0,0);
|
||||
// get the description for the current screen (bitsperpixel, depth, ...)
|
||||
IntfImg1.GetDescriptionFromDevice(0);
|
||||
// create the XPM reader
|
||||
Reader:=TLazReaderXPM.Create;
|
||||
// load the image
|
||||
IntfImg1.LoadFromFile('filename.xpm',Reader);
|
||||
// create the bitmap handles
|
||||
IntfImg1.CreateBitmap(BmpHnd,MaskHnd);
|
||||
// apply handles to the Bitmap1
|
||||
Bitmap1.Handle:=BmpHnd;
|
||||
Bitmap1.MaskHandle:=MaskHnd;
|
||||
// clean up
|
||||
Reader.Free;
|
||||
IntfImg1.Free;
|
||||
// do something with the Bitmap1
|
||||
...
|
||||
end;
|
||||
|
||||
|
||||
2. Saving a TBitmap to a .xpm file:
|
||||
|
||||
var
|
||||
BmpHnd,MaskHnd: HBitmap;
|
||||
Bitmap1: TBitmap;
|
||||
IntfImg1: TLazIntfImage;
|
||||
Writer: TLazWriterXPM;
|
||||
begin
|
||||
...
|
||||
// create the raw image
|
||||
IntfImg1:=TLazIntfImage.Create(0,0);
|
||||
// load the raw image from the bitmap handles
|
||||
IntfImg1.LoadFromBitmap(Bitmap1.Handle,Bitmap1.MaskHandle);
|
||||
// create the XPM writer
|
||||
Writer:=TLazWriterXPM.Create;
|
||||
// save image to file
|
||||
IntfImg1.SaveToFile('filename.xpm',Writer);
|
||||
// clean up
|
||||
Writer.Free;
|
||||
IntfImg1.Free;
|
||||
...
|
||||
end;
|
||||
}
|
||||
|
||||
TLazIntfImage = class(TFPCustomImage)
|
||||
private
|
||||
|
Loading…
Reference in New Issue
Block a user