Difference between revisions of "TBGRABitmap class"

From Lazarus wiki
Jump to navigationJump to search
Line 51: Line 51:
  
 
=== TBGRABitmap reference ===
 
=== TBGRABitmap reference ===
==== Properties ====
 
 
<table style="border-collapse: collapse;">
 
<table style="border-collapse: collapse;">
<tr style="background: white;"><td colspan="3">'''property''' CanvasBGRA: TBGRACanvas '''read''';</td></tr>
+
<tr style="background: white;"><td colspan="3">''TBGRADefaultBitmap'' = '''class'''(TBGRACustomBitmap)</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Provides a canvas with opacity and antialiasing</td></tr>
+
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">This class is the base for all ''TBGRABitmap'' classes. It implements most function to the exception from implementations specific to the widgetset</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''property''' Canvas2D: TBGRACanvas2D '''read''';</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' CanvasBGRA: TBGRACanvas '''read''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Provides a canvas with 2d transformation and similar to HTML5.</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Provides a canvas with opacity and antialiasing</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' Canvas2D: TBGRACanvas2D '''read''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Provides a canvas with 2d transformation and similar to HTML5.</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
</table>
 
</table>
Line 64: Line 66:
 
==== Reference counting ====
 
==== Reference counting ====
 
<table style="border-collapse: collapse;">
 
<table style="border-collapse: collapse;">
<tr style="background: white;"><td colspan="3">'''function''' NewReference: TBGRACustomBitmap;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' NewReference: TBGRACustomBitmap;</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Adds a reference (this reference count is not the same as the reference count of an interface, it changes only by explicit calls</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Adds a reference (this reference count is not the same as the reference count of an interface, it changes only by explicit calls</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''procedure''' FreeReference;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''procedure''' FreeReference;</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Free a reference. When the resulting reference count gets to zero, the image is freed. The initial reference count is equal to 1</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Free a reference. When the resulting reference count gets to zero, the image is freed. The initial reference count is equal to 1</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">'''function''' GetUnique: TBGRACustomBitmap;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GetUnique: TBGRACustomBitmap;</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Returns an object with a reference count equal to 1. Duplicate this bitmap if necessary</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns an object with a reference count equal to 1. Duplicate this bitmap if necessary</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
</table>
 
</table>
 
==== Constructors ====
 
==== Constructors ====
 
<table style="border-collapse: collapse;">
 
<table style="border-collapse: collapse;">
<tr style="background: white;"><td colspan="3">'''constructor''' Create(AWidth, AHeight: integer); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''constructor''' Create(AWidth, AHeight: integer); '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates a new bitmap, initialize properties and bitmap data</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates a new bitmap, initialize properties and bitmap data</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''procedure''' SetSize(AWidth, AHeight: integer); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''procedure''' SetSize(AWidth, AHeight: integer); '''override''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Can only be called with an existing instance of ''TBGRABitmap''. Sets the dimensions of an existing ''TBGRABitmap'' instance.</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Can only be called with an existing instance of ''TBGRABitmap''. Sets the dimensions of an existing ''TBGRABitmap'' instance.</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">'''constructor''' Create; override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''constructor''' Create; '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image of width and height equal to zero. In this case, ''Data'' = '''nil'''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image of width and height equal to zero. In this case, ''Data'' = '''nil'''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''constructor''' Create(AFPImage: TFPCustomImage); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''constructor''' Create(AFPImage: TFPCustomImage); '''override''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image by copying the content of a ''TFPCustomImage''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image by copying the content of a ''TFPCustomImage''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">'''constructor''' Create(ABitmap: TBitmap); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''constructor''' Create(ABitmap: TBitmap); '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image by copying the content of a ''TBitmap''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image by copying the content of a ''TBitmap''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''constructor''' Create(AWidth, AHeight: integer; Color: TColor); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''constructor''' Create(AWidth, AHeight: integer; Color: TColor); '''override''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image of dimensions ''AWidth'' and ''AHeight'' and fills it with the opaque color ''Color''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image of dimensions ''AWidth'' and ''AHeight'' and fills it with the opaque color ''Color''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">'''constructor''' Create(AWidth, AHeight: integer; Color: TBGRAPixel); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''constructor''' Create(AWidth, AHeight: integer; Color: TBGRAPixel); '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image of dimensions ''AWidth'' and ''AHeight'' and fills it with ''Color''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image of dimensions ''AWidth'' and ''AHeight'' and fills it with ''Color''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''constructor''' Create(AFilename: '''string'''); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''constructor''' Create(AFilename: '''string'''); '''override''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image by loading its content from the file ''AFilename''. The encoding of the string is the default one for the operating system. It is recommended to use the next constructor and UTF8 encoding</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image by loading its content from the file ''AFilename''. The encoding of the string is the default one for the operating system. It is recommended to use the next constructor and UTF8 encoding</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">'''constructor''' Create(AFilename: '''string'''; AIsUtf8: boolean); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''constructor''' Create(AFilename: '''string'''; AIsUtf8: boolean); '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image by loading its content from the file ''AFilename''. The boolean ''AIsUtf8Filename'' specifies if UTF8 encoding is assumed for the filename</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image by loading its content from the file ''AFilename''. The boolean ''AIsUtf8Filename'' specifies if UTF8 encoding is assumed for the filename</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''constructor''' Create(AStream: TStream); override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''constructor''' Create(AStream: TStream); '''override''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Creates an image by loading its content from the stream ''AStream''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Creates an image by loading its content from the stream ''AStream''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">''destructor'' Destroy; override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''destructor''' Destroy; '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Free the object and all its resources</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Free the object and all its resources</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' NewBitmap(AWidth, AHeight: integer): TBGRACustomBitmap; override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' NewBitmap(AWidth, AHeight: integer): TBGRACustomBitmap; '''override''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with dimensions ''AWidth'' and ''AHeight'', containing transparent pixels. Example: <syntaxhighlight>var bmp1, bmp2: TBGRABitmap; begin bmp1 := TBGRABitmap.Create(100,100); bmp2 := bmp1.NewBitmap(100,100) as TBGRABitmap; ... end;</syntaxhighlight></td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with dimensions ''AWidth'' and ''AHeight'', containing transparent pixels. Example: <syntaxhighlight>var bmp1, bmp2: TBGRABitmap; begin bmp1 := TBGRABitmap.Create(100,100); bmp2 := bmp1.NewBitmap(100,100) as TBGRABitmap; ... end;</syntaxhighlight></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">'''function''' NewBitmap(AWidth, AHeight: integer; Color: TBGRAPixel): TBGRACustomBitmap; override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' NewBitmap(AWidth, AHeight: integer; Color: TBGRAPixel): TBGRACustomBitmap; '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with dimensions ''AWidth'' and ''AHeight'', and fills it with Color</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with dimensions ''AWidth'' and ''AHeight'', and fills it with Color</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: #f0f0ff;"><td colspan="3">'''function''' NewBitmap(Filename: '''string'''): TBGRACustomBitmap; override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' NewBitmap(Filename: '''string'''): TBGRACustomBitmap; '''override''';</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with by loading its content from the file ''Filename''. The encoding of the string is the default one for the operating system</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with by loading its content from the file ''Filename''. The encoding of the string is the default one for the operating system</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">'''function''' NewBitmap(Filename: '''string'''; AIsUtf8: boolean): TBGRACustomBitmap; override;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' NewBitmap(Filename: '''string'''; AIsUtf8: boolean): TBGRACustomBitmap; '''override''';</td></tr>
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with by loading its content from the file ''Filename''</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Can only be called from an existing instance of ''TBGRABitmap''. Creates a new instance with by loading its content from the file ''Filename''</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
</table>
 
</table>
See '''[[BGRABitmap_tutorial_2|how to load and display an image]]'''
+
See tutorial 2 on '''[[BGRABitmap_tutorial_2|how to load and display an image]]'''
  
 
=== Text fonctions ===
 
=== Text fonctions ===

Revision as of 12:01, 1 May 2015

TBGRABitmap class contains an image stored in BGRA 32-bit format. It derives from TBGRADefaultBitmap which derives from TBGRACustomBitmap from which it inherits its properties. So it implements the interface IBGRAScanner which allows it to be used as a texture (like a brush).

Implementations

TBGRABitmap is a shortcut for the active implementation, depending on the widgetset. It can be one of the following:

  • TBGRAWinBitmap on Windows
  • TBGRAGtkBitmap on Gtk
  • TBGRAQtBitmap when Qt widget is active
  • TBGRAfpGUIBitmap when using the package for fpGUI toolkit (bgrabitmappack4fpgui.lpk)
  • TBGRANoGUIBitmap when using the package independent of the graphic user interface (bgrabitmappack4nogui.lpk)
  • TBGRADefaultBitmap otherwise

Direct pixel access

The image is stored as BGRA 32-bit:

PBGRAPixel = ^TBGRAPixel;
Pointer for direct pixel access. Data is stored as a sequence of TBGRAPixel. See BGRABitmap tutorial 4
TBGRAPixel = packed record blue, green, red, alpha: byte; end;
Each pixel is a sequence of 4 bytes containing blue, green, red and alpha channel. Values range from 0 to 255, color is in sRGB colorspace. The alpha value of 0 is transparent and 255 is opaque

You can either use Data property if you want to go through all pixels, or ScanLine property if you want to do something that depends on the line number. Data returns the first pixel in memory, so that you can read all the pixels from there by increasing the pointer (add 1 to PBGRAPixel). Otherwise, you can do a loop where y goes from 0 to Height-1, and for each line, retrieve with ScanLine the pointer of the beginning of the line. Then you can read all the pixels of the line from there by increasing the pointer.

The following properties of TBGRABitmap allow to access the data directly:

TBGRABitmap = class(TBGRADefaultBitmap)
property Width: integer read;
Width of the image in pixels
property Height: integer read;
Height of the image in pixels
property NbPixels: integer read;
Total number of pixels. It is always true that NbPixels = Width * Height
property ScanLine[y: integer]: PBGRAPixel read;
Returns the address of the left-most pixel of any line. The parameter y ranges from 0 to Height-1
property LineOrder: TRawImageLineOrder read;
Indicates the order in which lines are stored in memory. If it is equal to riloTopToBottom, the first line is the top line. If it is equal to riloBottomToTop, the first line is the bottom line. See miscellaneous types
property Data: PBGRAPixel read;
Provides a pointer to the first pixel in memory. Depending on the LineOrder property, this can be the top-left pixel or the bottom-left pixel. There is no padding between scanlines, so the start of the next line is at the address Data + Width. See BGRABitmap tutorial 4
property Caption: string read write;
Can contain a text to describe the image. It is not displayed. It is the name of the layer if this image is in a layered bitmap.

TBGRABitmap reference

TBGRADefaultBitmap = class(TBGRACustomBitmap)
This class is the base for all TBGRABitmap classes. It implements most function to the exception from implementations specific to the widgetset
property CanvasBGRA: TBGRACanvas read;
Provides a canvas with opacity and antialiasing
property Canvas2D: TBGRACanvas2D read;
Provides a canvas with 2d transformation and similar to HTML5.

For more properties, see parent class TBGRACustomBitmap

Reference counting

function NewReference: TBGRACustomBitmap;
Adds a reference (this reference count is not the same as the reference count of an interface, it changes only by explicit calls
procedure FreeReference;
Free a reference. When the resulting reference count gets to zero, the image is freed. The initial reference count is equal to 1
function GetUnique: TBGRACustomBitmap;
Returns an object with a reference count equal to 1. Duplicate this bitmap if necessary

Constructors

constructor Create(AWidth, AHeight: integer); override;
Creates a new bitmap, initialize properties and bitmap data
procedure SetSize(AWidth, AHeight: integer); override;
Can only be called with an existing instance of TBGRABitmap. Sets the dimensions of an existing TBGRABitmap instance.
constructor Create; override;
Creates an image of width and height equal to zero. In this case, Data = nil
constructor Create(AFPImage: TFPCustomImage); override;
Creates an image by copying the content of a TFPCustomImage
constructor Create(ABitmap: TBitmap); override;
Creates an image by copying the content of a TBitmap
constructor Create(AWidth, AHeight: integer; Color: TColor); override;
Creates an image of dimensions AWidth and AHeight and fills it with the opaque color Color
constructor Create(AWidth, AHeight: integer; Color: TBGRAPixel); override;
Creates an image of dimensions AWidth and AHeight and fills it with Color
constructor Create(AFilename: string); override;
Creates an image by loading its content from the file AFilename. The encoding of the string is the default one for the operating system. It is recommended to use the next constructor and UTF8 encoding
constructor Create(AFilename: string; AIsUtf8: boolean); override;
Creates an image by loading its content from the file AFilename. The boolean AIsUtf8Filename specifies if UTF8 encoding is assumed for the filename
constructor Create(AStream: TStream); override;
Creates an image by loading its content from the stream AStream
destructor Destroy; override;
Free the object and all its resources
function NewBitmap(AWidth, AHeight: integer): TBGRACustomBitmap; override;
Can only be called from an existing instance of TBGRABitmap. Creates a new instance with dimensions AWidth and AHeight, containing transparent pixels. Example:
var bmp1, bmp2: TBGRABitmap; begin bmp1 := TBGRABitmap.Create(100,100); bmp2 := bmp1.NewBitmap(100,100) as TBGRABitmap; ... end;
function NewBitmap(AWidth, AHeight: integer; Color: TBGRAPixel): TBGRACustomBitmap; override;
Can only be called from an existing instance of TBGRABitmap. Creates a new instance with dimensions AWidth and AHeight, and fills it with Color
function NewBitmap(Filename: string): TBGRACustomBitmap; override;
Can only be called from an existing instance of TBGRABitmap. Creates a new instance with by loading its content from the file Filename. The encoding of the string is the default one for the operating system
function NewBitmap(Filename: string; AIsUtf8: boolean): TBGRACustomBitmap; override;
Can only be called from an existing instance of TBGRABitmap. Creates a new instance with by loading its content from the file Filename

See tutorial 2 on how to load and display an image

Text fonctions

class TBGRABitmap
  property FontName: string; read write;
  property FontStyle: TFontStyles; read write;
  property FontQuality : TBGRAFontQuality; read write;
  property FontOrientation: integer; read write;
  property FontHeight: integer; read write;
  property FontAntialias: Boolean; read write;
  property FontFullHeight: integer; read write;
  property FontPixelMetric: TFontPixelMetric;
  property FontRenderer: TBGRACustomFontRenderer; read write;

  procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment);
  procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment);
  procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment);
  procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; texture: IBGRAScanner; align: TAlignment);
  procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel);
  procedure TextOut(x, y: single; sUTF8: string; c: TColor);
  procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner);
  procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; c: TBGRAPixel);
  procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; texture: IBGRAScanner);
  procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; c: TBGRAPixel);
  procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; texture: IBGRAScanner);
  function TextSize(sUTF8: string): TSize;

See TBGRABitmap text functions.

Pixel functions

class TBGRABitmap
  procedure SetPixel(x, y: int32or64; c: TColor);
  procedure XorPixel(x, y: int32or64; c: TBGRAPixel);
  procedure SetPixel(x, y: int32or64; c: TBGRAPixel);
  procedure DrawPixel(x, y: int32or64; c: TBGRAPixel);
  procedure DrawPixel(x, y: int32or64; c: TBGRAPixel; ADrawMode: TDrawMode);
  procedure DrawPixel(x, y: int32or64; ec: TExpandedPixel);
  procedure FastBlendPixel(x, y: int32or64; c: TBGRAPixel);
  procedure ErasePixel(x, y: int32or64; alpha: byte);
  procedure AlphaPixel(x, y: int32or64; alpha: byte);
  function GetPixel(x, y: int32or64): TBGRAPixel;
  function GetPixel256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear; smoothBorder: boolean = true): TBGRAPixel;
  function GetPixel(x, y: single; AResampleFilter: TResampleFilter = rfLinear; smoothBorder: boolean = true): TBGRAPixel;
  function GetPixelCycle(x, y: int32or64): TBGRAPixel;
  function GetPixelCycle(x, y: single; AResampleFilter: TResampleFilter = rfLinear): TBGRAPixel;
  function GetPixelCycle(x, y: single; AResampleFilter: TResampleFilter; repeatX: boolean; repeatY: boolean): TBGRAPixel;
  function GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear): TBGRAPixel;
  function GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter; repeatX: boolean; repeatY: boolean): TBGRAPixel;

See TBGRABitmap pixel functions.