Graphics32 Help and Reference

The Graphics32 Library

Overview
Installation
Examples
Contributors

Additional Topics

Line Patterns

Using TImage32

Classes (Alphabetical)

TAffineTransformation

TArrowBar

TBitmap32

TBitmap32Collection

TBitmap32Item

TBitmap32List

TBitmapLayer

TBitmapPolygonFiller

TByteMap

TCustomGaugeBar

TCustomImage32

TCustomImgView32

TCustomLayer

TCustomMap

TCustomPaintBox32

TCustomPolygonFiller

TCustomRangeBar

TGaugeBar

TImage32

TImgView32

TIVScrollProperties

TLayerCollection

TPaintBox32

TPaintStages

TPolygon32

TPositionedLayer

TProjectiveTransformation

TRangeBar

TRubberbandLayer

TThreadPersistent

TTransformation

Classes (Hierarchy)

TArrowBar

TCustomGaugeBar

TGaugeBar

TCustomRangeBar

TRangeBar

TBitmap32Collection

TBitmap32Item

TBitmap32List

TCustomLayer

TPositionedLayer

TBitmapLayer

TRubberbandLayer

TCustomPaintBox32

TCustomImage32

TCustomImgView32

TImgView32

TImage32

TPaintBox32

TCustomPolygonFiller

TBitmapPolygonFiller

TIVScrollProperties

TLayerCollection

TPaintStages

TThreadPersistent

TCustomMap

TBitmap32

TByteMap

TPolygon32

TTransformation

TAffineTransformation

TProjectiveTransformation

Routines

AlphaComponent | Creating Points | OffsetRect
AlphaToGrayscale | Creating Rectangles | Polygon
ApplyLUT | EMMS | Polyline
Blend | EqualRect | PolyPolygon
BlendEx | Fixed Point Math | PolyPolyline
BlockTransfer | Gray32 | PtInPolygon
BlueComponent | GreenComponent | PtInRect
ChromaKey | HSLtoRGB | RedComponent
Color32 | InflateRect | RGBtoHSL
Color32ToRGB | Intensity | SetAlpha
ColorAdd | IntensityToAlpha | SetBorderTransparent
ColorDiv | IntersectRect | SetGamma
ColorMax | Invert | StretchTransfer
ColorMin | InvertRGB | Transform
ColorModulate | IsRectEmpty | TransformPoints
ColorSub | Lighten | WinColor
ColorToGrayScale | Merge | WinPalette
Combine | MergeEx

Types

Arrays | TFillLineEvent | TRBBackgnd
Color Types | TFixed | TRBHandles
Point Types | TFloatMatrix | TRBStyle
Rectangle Types | TLUT8 | TRectRounding
TAntialiasMode | TPaintBoxOptions | TSize
TCombineMode | TPaintStage | TSizeGripStyle
TConversionType | TPixelCombineEvent | TStretchFilter
TDrawMode | TPolyFillMode

Variables

MMX_ACTIVE

Constants

Color Constants | G32Version | Layer Options Bits
DefaultAAMode | IdentityMatrix | Paint Stage Constants

Units

GR32 | GR32_Filters | GR32_Polygons
GR32_Blend | GR32_Image | GR32_RangeBars
GR32_ByteMaps | GR32_Layers | GR32_Transforms

Copyright ©2000-2004 Alex Denisov and Contributors - Graphics32 v1.7.1 - Build on 25-Februar-2005


Overview

Graphics32 is a set of functions, classes, components and controls designed for high-performance graphics programming.

Being highly specialized for 32-bit pixel format, it provides fast operations with pixels and graphic primitives and in most cases Graphics32 considerably outperforms standard TBitmap/TCanvas classes.

The library comes with a full source code, documentation and examples.

The following topics are covered in this overview:

  • Features;
  • License;
  • Donate;
  • Contacts;
  • Naming Convention;
  • Changes.

See Also

Changes, Contacts, Donate, Features, License, Naming Conventions


Features

Many features in Graphics32 are similar to those in standard TImage, TBitmap and TCanvas classes, however they were rewritten to accelerate and optimize drawing on 32-bit device-independent bitmaps (DIBs). It also includes a few new options.

Some of its features include:

  • Fast per-pixel access up to 100 times faster compared to standard TCanvas/TBitmap;
  • Bitmap alpha blending (including per-pixel alpha blending);
  • Pixel, line and polygon antialiasing (combined with alpha blending);
  • polygon transformations and custom fillings;
  • Locking the bitmap for safe multithreading;
  • Enhanced scaling of bitmaps;
  • Affine transformations of bitmaps: rotations, scaling, etc with sub-pixel accuracy;
  • Arbitrary projective transformations of bitmaps;
  • Flicker-free image displaying components with optimized double buffering;
  • Multiple customizible easy-to-use overlay layers;
  • A property editor for RGB and alpha channel loading;
  • Design-time loading of image formats supported by standard TPicture;

Except for extended features, Graphics32 has some important differences from standard components. It does not heavily rely on Windows GDI, most of the functions are reimplemented and optimized specifically for 32-bit pixel format.

See Also

Changes, Contacts, Donate, License, Naming Conventions


License

As of Version 1.5.1b Graphics32 is licensed under the terms of the Mozilla Public License. You may not use the Graphics32 library except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL

See Also

Changes, Contacts, Donate, Features, Naming Conventions


Donate

Graphics32 is free under the terms of the Mozilla Public License.

However, if you wish to express your appreciation for the time Alex Denisov spend on developing, documenting and supporting the initial version, he does accept and appreciate donations.

If you wish to make your donation, click here. The base amount is US$20, but if you would like to donate more, feel free to order multiple copies of the "Graphics32/G32 donation" product.

Thank you for your support.

See Also

Changes, Contacts, Features, Naming Conventions


Contacts

Graphics32 SourceForge home: http://sourceforge.net/projects/graphics32

Graphics32 new home: http://graphics32.org

Graphics32 support forum: http://graphics32.org/forum

Graphics32 support newsgroup: news://news.g32.org/g32org.public.graphics32

E-mail: team@graphics32.org

Please, use the newsgroup or forum for general support questions.

Graphics32 old home: http://g32.org

old E-mail: alex@g32.org

See Also

alex@g32, Changes, Donate, Features, License, Naming Conventions, team@graphics32


Naming Conventions

Graphics32 introduces several routines (as well as some class properties and methods) which have similar action but may have different arguments or other realization details.

They follow a simple naming convention:

Postfix | Details | Example
none | Property or method does not perform any range checking of its arguments. All the coordinates should be valid. | Line
S | 'Safe' version. Validates coordinates. If necessary, clipping is performed. | LineS
T | 'Transparent' version of the method. Uses the alpha channel of the provided color to blend the drawn primitive with the background pixels. | LineT
A | Methods with 'A' postfix provide antialiasing of the drawn primitive. | LineA
X | These functions operate with coordinates in TFixed format. They automatically provide antialiasing. | LineX
F | Methods with 'F' postfix take coordinates as floating point arguments and perform antialiasing of the drawn primitive. | LineF
TS, AS, XS, FS | Valid combinations of postfixes described above. | LineFS
P | 'Pattern' version. Usually combined with TS or FS postfixes, it allows for implementation of various effects, like gradient or dashed lines (See Line Patterns). | LineFSP

See Also

Changes, Contacts, Donate, Features, License, Line Patterns


Changes

v1.7.1 (25 February 2005)

Bugfixes:

  • fixes for AVs in new line drawing methods (LineS, LineTS, LineAS)
  • replaced incorrect call of VertLineS and HorzLineS in LineTS and LineAS with VertLineTS and HorzLineTS
  • fix for buffer reallocation inefficiency in TCustomPaintBox32 (non-critical, long standing)
    This should improve performance on resizing for all TCustomPaintBox32 derived controls.
  • added missing call to inherited constructor in TPolygon32 constructor (caused big trouble on Win9x/WinME systems)
  • RenderText now ignores Windows-based font smoothing in VCL
    (VCL-only change because the QT version that's used in CLX doesn't support disabling font antialiasing, neither in Windows nor in Linux/X11)
  • CLX compilation fixes
  • C++ Builder compilation fixes
  • ColorMul removed (duplicate of ColorModulate)
  • minor cleanups

v1.7 (16 January 2005)

New Features:

  • clipping rect support (all safe drawing operations are clipped to a rect)
  • support for custom polygon fillings (via callback or polygon filler objects)
  • support for polygon transformation (permanent or while drawing)
  • update to transformation classes to make them more suited for general usage
  • polygon performance enhancements
  • new CombineMode property in TBitmap32
  • TRubberbandLayer enhancements
  • additional color algebra functions
  • more versatile TBitmap32.ResetAlpha method (overloaded)
  • Delphi 2005 (Win32) support (optional inlining where applicable)
  • small speed enhancements

Bugfixes:

  • fix for RenderText problems with letters that spread below baseline
  • fix for bug in TBitmap32.Rotate180
  • fix for problem in TBitmap32.Assign that caused transparent regions in metafiles and icons to appear in blue when they really should be white.
  • fix for problem where the buffer content on repaint in TPaintBox32 wasn't validated
  • fix for problem where C++ Builder threw linker errors (HDC methods and "hoisted overload" or E2113) in GR32.pas and GR32_Image.pas
  • fix for linear/draft bug with bitmaps of size 100x1 et al.
  • fix for bug in Transform that caused the outline of the source bitmap to appear in OuterColor
  • fix for the 3DNow detection (caused "external exception" on some machines when sfDraft was used)
  • fix for dysfunctional OnMouseEnter and OnMouseLeave in TCustomImage32
  • fix for CheckParams problem in ApplyLUT
  • fix to preserve alpha channel in ApplyLUT and ColorToGrayscale

v1.6 (21 July 2004)

  • Graphics32 now fully supports CLX cross-platform development;
  • Example projects have been successfully converted and tested in Linux;
  • Fixed issues in GR32_Transforms that could potentially cause access violation;
  • Added sfDraft resampling filter with MMX optimization;
  • Added sfCosine resampling filter;
  • Added PixelF/X properties that read and write pixels with antialiasing;
  • SetPixelF/X methods have been deprecated;
  • Added new MMX optimized color algebra routines to GR32_Blend (Add, Subtract, Multiply etc.);
  • Added AntiAliasMode property to TPolygon32 for dynamically changing antialias level at runtime;
  • Added support for 4x supersampling antialias of polygons (significantly faster but with less quality);
  • Unicode support for TBitmap32.Text* and TBitmap32.Rendertext methods;
  • Fixed blending bug (the "not fully opaque" issue);
  • Performance optimizations (MMX) in blending routines and Transforms;
  • Several minor additions and optimizations.

v1.5.1b (5 July 2004)

Changed license to MPL. Everything else is identical with v1.5.1.

v1.5.1 (8 June 2003)

Fixed resource leaks in TBitmap32.Canvas and TBitmap32.Font.

A small bug fix in TRubberbandLayer.MouseMove

Added a new resampling option which is controlled through the FullEdge variable in GR32_Transforms.pas. To see how it affects resampled image, see the new example in the FineResample_Ex directory. The default value of FullEdge is True; change FullEdge back to False to get resampling results as in previous versions.

v1.5 (15 January 2003)

Added packages for Delphi 7. The library should also compile with C++ Builder 6.

v1.5 beta 2 (27 July 2002)

Completely rewritten bitmap resampling routines: added DstClip parameter to BlockTransfer and StretchTransfer, added new resampling filters. Warning: sfLinear2 filter has been removed - use sfLinear instead.

Added new TBitamp32 methods: FlipHorz, FlipVert, Rotate90, Rotate180, and Rotate270. Added TBitmap32.Canvas. Some changes in line drawing routines. Faster implementation of TColor <> TColor32 conversion. Other minor bug fixes.

v1.4 (29 March 2002)

Fixed a bug in TAffineTransformation. Exposed matrix transformation routines from GR32_Transforms for external use. Fixed handling of very small scales in TImage32. Fixed a bug in non-MMX blending. Fixed BCB packages. Added LoadFromResourceID and LoadFromResourceName wrappers. Some fixes in stippled lines with clipping (still not perfect, but now it should be more consistent). Added TBitmap32.HandleChanged.

v1.3 (12 February 2002)

GR32_CPUid.pas is renamed to GR32_System.pas and extended to handle windows xp visual styles. New implementation for range bars and gage bars. Fixed bugs in projective transformations, polygons, and design-time TBitmap32 editor. After a few tweaks the ImgView_Layers_Ex example should work considerable faster. Removed bgMix style from TArrowBar.Bkgnd as well as glyph properties to make range bars and gage bars compatible with visual styles in WindowsXP. Added a new property TPainBox32.Options.

I established a new Kagi account, so if you would like to support development of Graphics32 and it successor G32, you are very welcome to make your donation here. Thank you in advance.

v1.2 (15 January 2002)

All the units, dfm, etc. files have been renamed from G_*.* to GR_*.*

Renamed Rect() functions to MakeRect() to provide better BCB compatibility. Renamed TCustomMap.SetSize(Source: TPersistent) to TCustomMap.SetSizeFrom(Source: TPersistent)

v1.01 (30 December 2001)

Bug fixes in LineA functions, and scaling 1-pixel size bitmaps. Some steps are taken towards BCB compatibility.

v1.0 (17 September 2001)

A small fix in image resampling. Renamed TextOut methods to Textout (I'm not sure, but this might help in BCB compilation).

v0.99z (13 August 2001)

Included Borland C++ Builder installation packages. Changed references to a new web site. Fixed bugs with polygons and PaintTo method in TImage32.

v0.99f (3 August 2001)

Fixed (I hope) a last small glitch in font resource allocation. A few tune-ups in polygons. Added support for Delphi 6. Design-time and run-time packages have been separated (Note: deinstallation of previous version is required).

v0.99e (31 April 2001)

Fixed regarding OnPixelCombine event in TBitmap32. And corresponding code in StretchTransform.

A couple of new examples added.

v0.99d (6 February 2001)

Changed implementation of FillRect* and FrameRect* functions, now the right/bottom line of pixels is excluded. Inverted rectangles (with negative width or height) are considered empty, they are not drawn any more. This behavior should be more consistent with GDI and with other routines in the library.

Changed a couple of properties in TCustomRangeBar. Now Range and Increment can be of a floating point type and OnGetWindowSize event is substituted with the Window property.

Added SizeGrip property to TCustomImgView32, as well as changed the order of the repainting a little bit, now the control scale a bit smoother.

Fixed Win'98 resource leakage in RenderText function.

Changed UI in the byte maps example.

Added new example on Graphics32-based custom visual component creation.

Most likely, this is the final beta release, next one should be v1.0.

v0.99b

Removed OnChanging event from all classes. Fixed a bug in TByteMap.Assign.

A faster MulDiv implementation.

New mouse events in TCustomImage32 were implemented to simplify mouse interaction with layers. Some internal changes in layer scaling.

Added the OnDestroy event to layers. Added LOB_NO_UPDATE to layer option bits. Changed TRubberBandLayer to paint itself into the buffer instead of using GDI overlays, removed ResizeOptions and added the OnResizing event.

Added Dst parameter into layer painting functions and events to support layer flattening operation (See TCustomImage32.PaintTo). Added OnInitStages event to TCustomImage32. Also I'm thinking of replacing the GDI overlays with something more useful and less flickering. It is still in the code but their usage is not recommended.

Implemented a Sutherland-Cohen line clipping algorithm instead of slower Liang-Barsky.

Added Flush functions to TPaintBox32 for direct copying of the back buffer to the screen.

Updated some of the examples.

v0.99a (25 September 2000)

Some speed-ups in resampling functions.

v0.99 (9 September 2000)

New documentation is available in HTML Help format. Changed unit names. Changed implementation of TImage32 and layers (see docs). New TPaintBox32 does not support layers. TBitmapList32 is renamed to TBitmap32List and a little bit simplified. An couple of bugs fixed in TBitmap32.SetSize. One of them could lead to resource leakage. Also fixed a bug in design-time streaming. TImgView32, a new control introduced in v0.98c is improved and now it is a descendant of TImage32.

v0.98c (19 July 2000)

This release is to be considered as beta for v0.99. It contains most of the features planned for v0.99. I release it mostly to check the C++ Builder compatibility, and keep you up-to-date with the current development state. Note, that documentation is not completely updated. DrawLine* functions are changed to Line*. Added an ability to customize bitmap blending equation. Better and faster buffering in TPaintBox32 and its descendants. Perspective transformations are now possible as well. Introduced a new TFixed fixed point data type. A new unit, implementing controls similar to scroll bars is available together with sample control showing how to implement scroll bars with TImage32. Sample control showing how to implement rubber-banding with layers is available as well. New 'X' postfix is introduced to some line drawing routines than operate directly over fixed point arguments.

v0.98b (3 June 2000)

Just a few bug fixes.

v0.98a (22 May 2000)

A little optimization in TBitmap32.RenderText. A bug in Intensity function fixed. Some fix-ups in PolygonTS.

v0.98 (17 May 2000)

Delphi4 compatibility. New MMX optimization code with automatic MMX detection. A small fix in Bresenham's implementation. DrawLine* functions now have parameter controlling drawing of the last pixel. Added MoveTo*, LineTo* functions. Added text blending/antialiasing. Added polylines and polygons. DrawLineA* functions now support line opacity. Added GR32Bench.xls file with performance test results. Some other small fixes. New examples.

v0.97a (1 May 2000)

A bug with FillRectS, FillRectTS fixed. Added a SmartResize property to TPaintBox32, it helps to reduce the amount of back-buffer reallocations when the control resizes.

v0.97 (29 Apr 2000)

Complete redesign, no more MMX-specific code since the new integer version works just as fast, no more msimg32.dll dependence. New double buffering scheme, new change notification scheme, completely redesigned overlay layers implementation, new scaling and linear trannsformation implementation. Overall speed improevement.

v0.95 (5 April 2000)

Added MMX optimization for pixel blending. It is also used to accelerate bilinear interpolation when performing linear transformations. Well, not a huge increase in performance, but still something. Alternative non-MMX code was rearranged to increase the instruction pairing. It works a bit faster now. A few bugs with color algebra were eliminated. A couple of links regarding low-level optimization is added.

v0.94 (31 March 2000)

Added a new unit for byte array mapping. A little reorganization in OnChange event generation. Fixed a bug in DrawLineF/FS functions, when the last point (or part of it) was not always there it was supposed to be.

v0.93 (23 March 2000)

Added baTile mode to TImage32.BitmapAlign property. Added linear transformations (See documentation). EndUpdate method of TBitmap32 now does not generate change notification. The Changed method must be called explicitly. New example on linear transformation is available. A few improvements in pixel and line antialiasing.

v0.92a (17March 2000)

Win95/NT support bug fixed. This version emulates both bitmap transparency and bitmap alpha blending functions from msimg32.dll, however this emulation is not optimized and will be slower compared to msimg32.dll. Some other small bugs found and destroyed.

v0.92 (16 March 2000)

Sprite scaling is added. Removed Transparent and UseAlpha from TBitmap32 properties. A new property DrawMode is introduced instead. Windows 95 and NT compatibility compiler directive is added. TImage32 example is updated and Win95/NT version is posted. See updated documentation for details.

v0.91 (10 March 2000)

Some changes in TImage32 component to reduce flicker when DoubleBuffered is turned off. Fixed the multithreading example.

v0.9 (9 March 2000)

First public release.

See Also

Contacts, Donate, Features, License, Naming Conventions


Installation

Graphics32 supports Delphi versions 4, 5, 6, 7 and 2005 (Win32), and C++ Builder 5 and 6.

As of version 1.6 there is also CLX support in Graphics32. That means you can use it either with CLX on Windows using Delphi or on x86 Linux using the Kylix Delphi environment.

Note: If you want to use the Windows CLX version in Delphi, you'll have to uncomment the {$DEFINE CLX} line in GR32.inc.

Note: For Delphi 2005 function inlining is automatically used to improve performance in certain situations. If you want to avoid this, please comment out the {$DEFINE USEINLINING} line in GR32.inc.

Note: Because some properties of range bars and gage bars have been changed, you can obtain some error messages while opening your previous Graphics32 projects. Just ignore these messages and Delphi will fix DFM files automatically.

  • Unzip the files;
  • Add location of main installation directory to Tools | Environment Options | Library | Library Path.
  • Select F ile | Open... on the menu bar. Set Files of type to Delphi package source, locate and open GR32_DSGN_D6.dpk
    (GR32_DSGN_K for Kylix, GR32_DSGN_D2005 for Delphi 2005, GR32_DSGN_D7 for Delphi7, GR32_DSGN_D6 for Delphi6, GR32_DSGN_D5 for Delphi5, GR32_DSGN_D4 for Delphi4 or GR32_DSGN_B5 for C++ Builder);
  • A package editor window will appear. Click Compile, then click Install;
  • If compiler asks whether you want to save changes, usually it is a good idea to choose No.


Examples

There is a few examples included with the library, which you should be able to find in the respective subdirectories VCL or CLX in the Examples subdirectory.

Here is the list of examples with short descriptions:

ByteMaps Example

Directory: ByteMaps_Ex (VCL only due to the 3rd party components used)

A basic demonstration of mapping a 2D array of values to TByteMap and displaying it using TPalette32.

FineResample Example

Directory: FineResample_Ex

A basic demonstration of the different stretchfilter the Graphics32 offers.

GradLines Example

Directory: GradLines_Ex

An example on using line patterns to draw gradient lines.

Image32 Example

Directory: Image32_Ex

This example demonstrates the properties of TImage32 that control the scale and alignment of the bitmap image.

ImgView and Layers Example

Directory: ImgView_Layers_Ex

A demonstration of using TImgView32, TPositionedLayer, TBitmapLayer and TRubberbandLayer. It also shows how it is possible to load RGB and Alpha channels from different image files into the TBitmap32 object at run-time and demonstrates an application of affine transformations. It also shows how is it possible to 'flatten' layers.

LineStippling Example

Directory: LineStippling_Ex

An example on using line patterns to draw dashed lines.

PixelF Example

Directory: PixelF_Ex

A demonstration of interpolated PixelF property. It lets you compare the result with normal pixel access.

PixelCombine Example

Directory: PixelCombine_Ex

A short demonstration of using the OnPixelCombine method in TBitmap32.

ProgressBar Example

Directory: ProgressBar_Ex

A simple visual component, that demonstrates how is it possible to create custom components based on TCustomPaintBox32. Note, that this component is mostly designed for demonstration purposes, do not expect too much from it.

Polygons Example

Directory: Polygons_Ex

This example shows the application of TPolygon32 to draw thick lines and other polygons with thick outlines.

RenderText Example

Directory: RenderText_Ex

A basic demonstration of using the TBitmap32.RenderText method.

Rotate Example

Directory: Rotate_Ex

A simple example on using TAffineTransformation. It shows how to rotate and scale the bitmap at the same time so that it stays within the specified rectange.

RotLayer Example

Directory: RotLayer_Ex

Features custom layer class creation and demonsrtates TAffineTransformation.

Sprites Example

Directory: Sprites_Ex

A demonstration on adding, removing and animating multiple TBitmapLayer objects to TImage32.

Transform Example

Directory: Transform_Ex

An example, which demonstrates using the Transformation routine together with TAffineTransformation and TProjectiveTransformation.

See Also

Bitmap Image, Line Patterns, TBitmap32.OnPixelCombine, TBitmap32.Pixel, TBitmap32.RenderText, TAffineTransformation, TBitmap32, TBitmapLayer, TByteMap, TImage32, TImgView32, TPalette32, TPolygon32, TPositionedLayer, TProjectiveTransformation, Transform, TRubberbandLayer, TStretchFilter


Line Patterns

Graphics32 defines several functions to support non-uniform lines. This includes gradient lines, dashed lines etc.

The idea is pretty simple: TBitmap32 object holds dynamic array of colors, and a counter, which 'crawls' along the array and reads colors from its position. The line drawing algorithm queries color value from the current counter position at each point, then the counter is automatically incremented to get ready to supply the next value to line rasterisation routine.

The counter, accessed through StippleCounter property, wraps itself automatically at the edges of color array. It can move in both directions depending on stipple step, which in turn can be positive or negative. Its malue may even be fractional in this case resulting color is interpolated. The step is accessed with StippleStep property.

GetStippleColor returns color from the current counter position and automatically increments counter position by the counter step, so that next GetStippleColor call will return color value from the next position.

Drawing functions that support line patterns have 'P' in their postfix (as in LineFSP).

Warning: the counter is not thread-aware, it is shared by all threads accessing the bitmap. Additional care should be taken when multiple threads draw stippled lines in the same bitmap.

See Also

TBitmap32.GetStippleColor, GradLines Example, LineStippling Example, Naming Conventions, TBitmap32.StippleCounter, TBitmap32.StippleStep, TBitmap32


Using TImage32

Starting from v0.99 of the Graphics32 library, implementation of VCL components was changed.

This section describes behavior and properties of TCustomImage32 and TImage32 controls, as well as new realization of layers.

Since TCustomImage32 and TImage32 share the same behavior, I will denote both of them here as TImage32. Most of the discussion concerns TImgView32 as well.

Overview

TImage32 is an image displaying visual component, which also holds a collection of layers.

The image is defined as a TBitmap32 object and there exist several properties which specify how it is scaled and positioned within the control's boundaries. I will denote this image as Bitmap Image here.

The layer is, generally speaking, an entity which 'knows' how to combine itself with the back buffer of the control. TImage32 maintains a collection of layers, see 'Using Layers' for details.

When the image paints itself, it runs through several Paint Stages which determine the order in which layers and the bitmap image are painted. This order is completely customizeable.

To avoid flicker and to speed-up scaling and blending operations, each layer and the bitmap image is painted to a back-buffer of the control. See the reference of TImage32 ancestor TCustomPaintBox32 for details of the back-buffer realization.

Finally, TImage32 supports change notification (OnChange event), which is done similar to change notification in TBitmap32. Basically, it redirects change notification from its layers and the bitmap image.

See Also

Bitmap Image, ImgView and Layers Example, TCustomImage32.OnChange, Paint Stages, TBitmap32, TCustomImage32, TCustomPaintBox32, TImage32, Using Layers


Bitmap Image

A bitmap image is represented with a TBitmap32 object and is stored in the Bitmap property. Its scale and location within the control is determined by the following properties:

BitmapAlign — specifies if the bitmap image is positioned at the top-left corner of the control (baTopLeft), centered (baCenter), tiled (baTile) or it its exact location is determined by OffsetHorz and OffsetVert properties;

ScaleMode — indicates if the bitmap image is displayed with its original size (smNormal), stretched to fit the control's boundaries (smStretch), proportionally resized to fit the control's boundaries(smScale) or proportionally scaled using its Scale property (smScale).

The bitmap image is combined with the back-buffer according to its DrawMode property. And the quality of its resampling is determined by the StretchFilter property. If its DrawMode is dmCustom, the bitmap will fire a series of OnPixelCombine events.

See Also

TCustomImage32.Bitmap, TCustomImage32.BitmapAlign, TBitmap32.DrawMode, Image32 Example, TCustomImage32.OffsetHorz, TCustomImage32.OffsetVert, TCustomImage32.OnPixelCombine, TCustomImage32.Scale, TCustomImage32.ScaleMode, TBitmap32.StretchFilter, TBitmap32, TDrawMode, TStretchFilter


Paint Stages

An order in which TImage32 blends layers and bitmap image to its back-buffer is specified by paint stages.

For example, the default sequence of operations includes:

  • Clearing the visible area of the background, that is the parts of the buffered area which are not covered by the bitmap image, or the whole buffer, if the bitmap image is not in dmOpaque draw mode;
  • Drawing the dotted frame around the control boundaries (design-time only);
  • Drawing the scaled bitmap image;
  • Framing the area of the scaled bitmap image with the dotted frame (design-time only);
  • Drawing layers;

It is possible to change the order in which stages execute at run-time, add new stages, delete old ones, etc., using the PaintStages property of TImage32, which is basically a dynamic indexed list of stages.

TPaintStage Record

Each paint stage is defined with a TPaintStage record:

type TPaintStage = record
DsgnTime: Boolean;
RunTime: Boolean;
Stage: Cardinal; // a PST_* constant
Parameter: Cardinal; // an optional parameter
end;

where the Stage member holds one of the Paint Stage Constants and defines the action associated with the stage.

All stages include additional parameter, which may be ignored or may be used to store additional stage options. For example, PST_DRAW_LAYERS stage uses its parameter as a 32-bit mask to filter out invisible layers.

By default, TImage32 contains the following stages:

# | DsgnTime | RunTime | Stage | Parameter
0 | True | True | PST_CLEAR_BACKGND | not used
1 | False | True | PST_CONTROL_FRAME | not used
2 | True | True | PST_DRAW_BITMAP | not used
3 | False | True | PST_BITMAP_FRAME | not used
4 | True | True | PST_DRAW_LAYERS | $80000000

See 'Using Layers' for explanation on parameter value in PST_DRAW_LAYERS stage.

Customizing TImage32 at Run-Time

A PST_CUSTOM stage deserves a little bit deeper explaination. It causes the control to issue an OnPaintStage event, thus allowing to change TImage32 behavior at run-time.

The OnPaintStage event is of a TPaintStageEvent type:

type TPaintStageEvent = procedure(Sender: TObject; Dest: TBitmap32; StageNum: Cardinal) of object;

In the event handler, application can perform some custom operations over the back-buffer of the control.

Note, that by default, TImage32 does not generate OnPaintStage. In order to make it to do so, you have to insert a new stage in the PaintStages list, and set its Stage to PST_CUSTOM, or change one of the existent stages, for example:

type

TForm1 = class(TForm)

Image32: TImage32;

procedure Image32InitStages(Sender: TObject); // OnInitStages

procedure Image32PaintStage(Sender: TObject; Dest: TBitmap32; StageNum: Cardinal); // OnPaintStage

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Image32InitStages(Sender: TObject);

begin

// change default PST_CLEAR_BACKGND (0-th stage) to a custom handler

with Image32.PaintStages[0] do

begin

Stage := PST_CUSTOM;

Parameter := 1; // use parameter to tag the stage

end;

// insert another custom stage after the bitmap image

// was drawn, but before the control starts painting layers

with Image32.PaintStages.Insert(4) do

begin

// Note that for new stages RunTime = True by default

Stage := PST_CUSTOM;

Paramteter := 2; // use parameter to tag the stage

end;

end ;

procedure TForm1.Image32PaintStage(Sender: TObject; Dest: TBitmap32; StageNum: Cardinal);

begin

// OnPaintStage Handler

case Image32.PaintStages[StageNum].Parameter of

1: // do something with the background

2: // call another handler

end;

end;

GDI Overlays

[ Note: Most likely GDI Overlays will not be used in future versions. Do not use it ]

A final step in TImage32 repainting is the drawing of GDI overlays. This operation is performed after the bitmap image and layers have been combined in a back buffer and copied to the screen canvas.

At this stage, TImage32 fires the OnGDIOverlay event, where you can perform drawing using the standard Canvas of the TImage32.

The main reason for introducing this stage is that painting of GDI overlays does not affect the contents of the buffer, that is changes in overlay image will not cause the buffer invalidation, however GDI overlays have to be repainted each time the control repaints itself, and they are not flicker-free.

See Also

TCustomImage32.OnGDIOverlay, TCustomImage32.OnPaintStage, Paint Stage Constants, TCustomImage32.PaintStages, TPaintStage, Using Layers


Using Layers

TImage32 holds an indexed collection of layers, referenced by the Layers property. The number of layers is limited only by the amount of free memory.

Each layer is an entity, which basically 'knows' how to paint itself to the back-buffer of the control and how to interact with the mouse. Layers are indexed and their indexes are similar to the Z-order of standard controls. Layers with smaller indexes are considered to lie deeper. This common behavior is implemented in the TCustomLayer class.

Common Properties and Methods

The basic layer's behavior is controlled by its LayerOptions property, which is a 32-bit unsigned integer value composed of Layer Options Bits. This property allows for fast and relatively simple referencing of layers and groups of layers.

Consider, for example, the LOB_VISIBLE bit (31-st bit in layer options). When TImage32 repaints its layers at PST_DRAW_LAYERS stage, it uses the stage parameter from corresponding TPaintStage record as a bit-mask (default value is LOB_VISIBLE=$80000000). Being compared (logical AND operation) with LayerOptions of each layer, this mask determines whether the layer should be painted or not.

Similar situation is with reaction to mouse messages (see below).

Using LayerOptions you can easily customize the appearance and modify the order of in thich TImage32 repaints layers. For example, you may assign several categories to layers, using lower 24-bits of LayerOptions and then just change the mask in corresponding TPaintStage record to specify exactly which category you want do be displayed.

More of that, remember, that you can insert several PST_DRAW_LAYERS paint stages (even before the PST_DRAW_BITMAP stage), each with its own mask, or, alternatively, call ExecDrawLayers while handling PST_CUSTOM stages. Basically it means, that you can realize almost any complex repainting scheme, like overlay layers, underlay layers, layers, which are always on top... or always in the background, etc.

Tracking the Mouse

Each layer is capable of responding to mouse down/move/up messages, which are routed to OnMouseDown, OnMouseMove and OnMouseUp events of the container (TImage32 control). Only one layer can receive a mouse message at the time.

Searching for the layer that receives a mouse message starts from the top-most layer and ends when the first layer satisfying both of the following conditions is found:

  • Layer has LOB_MOUSE_EVENTS bit activated in its LayerOptions;
  • Layer passes a hit test (see below);

There is also a possibility to disable passing of all mouse messages to layers. Just set the MouseEvents property of the layer collection to False, and TImage32 will generate mouse events right away, without checking for possible receiving layer.

As stated earlier, layer should pass a hit test in order to receive mouse message. The hit test is, basically a boolean responce to a couple of coordinates, accomplished by the HitTest method:

function HitTest(X, Y: Integer): Boolean; virtual;

X and Y parameters here are the coordinates of the point specified relative to the top-left corner of TImage32 (in pixels). The function returns a value that indicates that the layer is 'there'. This function is overriden in descendants, for example, in TBitmapLayer, this hit test may take into consideration values stored in the alpha channel of the contained bitmap. You can also write a handler for OnHitTest event to customize hit tests at run-time.

Similar to standard controls, layers may also capture mouse messages. By default, all mouse messages are captured automatically once the mouse is pressed on top of the layer and until the mouse is released. The layer that has captured the mouse is pointed by the MouseListener property of the layer collection. (There is a few things to work on here... will do it later).

Painting Layers

Layers are painted in bottom-to-top order, starting from lower indexes. By default, only visible layers are painted, that is the ones with LOB_VISIBLE bit set, but as it was shown above, this order may be changed.

Positioned Layers

Positioned layers are the layers, you will probably use most of the time. The base class for positioned layers is TPositionedLayer. In addition to basic layer behavior, it introduces Location property (of the TFloatRect type), which specifies layer's position and size. Having location specified as a floating point rectangle helps to avoid rounding errors when layers are resized.

The location can be specified in pixels, relative to TImage32 top-left corner, or in scaled pixels, relative to the top-left corner of the bitmap image. In the second case, the scale of the layer coincides with the scale of the bitmap image and the actual location of the layer relative to the top-left corner of TImage32 may be obtained with its GetAdjustedLocation method.

See Also

Bitmap Image, TCustomImage32.ExecDrawLayers, TPositionedLayer.GetAdjustedLocation, TCustomLayer.HitTest, ImgView and Layers Example, Layer Options Bits, TCustomLayer.LayerOptions, TCustomImage32.Layers, TPositionedLayer.Location, TLayerCollection.MouseEvents, TLayerCollection.MouseListener, TCustomLayer.OnHitTest, TCustomImage32.OnMouseDown, TCustomImage32.OnMouseMove, TCustomImage32.OnMouseUp, TBitmapLayer, TCustomLayer, TFloatRect, TPaintStage Record, TPositionedLayer, TRubberbandLayer


Contributors

(in alphabetical order):

Main contributors:

Mattias Andersson <mattias@centaurix.com>:

GR32.pas:
- Tweaks.
- PixelF/X property.
- Some minor CLX/Kylix tweaks.
- Added CombineMode.

GR32_Image.pas:
- Ported to CLX/Kylix.

GR32_Polygons.pas:
- Added TPolygon32.ContainsPoint method.

GR32_Transforms.pas:
- Added sfCosine resampling filter.

GR32_Blend.pas

- Pascal and MMX version of Merge algorithm.
- Added MMX versions of almost all PixelCombine functions.

Andre Beckedorf <andre@metaexception.de>:

GR32.pas:
- Added Unicode text methods
- Ported to CLX/Kylix.
- Added CombineMode.
- Added clipping rect support.
- pixel-perfect line drawing methods (LineS, LineTS, LineAS).

GR32_Image.pas:
- Some part of the CLX/Kylix related changes in this unit.
- Added new overrideable Mouse* methods with Layer information.
- Added OverSize property in TCustomImgView32

GR32_Layers.pas:
- enhancements to TRubberbandLayer

GR32_Polygon.pas:
- Added option for dynamic antialias level adjustment at runtime.
- Added new 4x sampling mode (very fast but mediocre quality).
- Added support for custom polygon fillings (TCustomPolygonFiller, TBitmapPolygonFiller) and transformations.
- Added support for clipping to rect.
- Added PolylineXSP and PolyPolylineXSP.
- Additional performance tuning.

GR32_RangeBars.pas:
- Ported to CLX/Kylix.

GR32_System.pas:
- Added support for SSE, SSE2, 3DNow and 3DNow Ext detection.

GR32_Transforms.pas:
- Minor tweak to the BlendBlock procedure.
- Update to transformation classes to make them suited for general usage.

Michael Hansen <dyster_tid@hotmail.com>:

GR32.pas:
- PixelF/X property.
- MMX optimized GetPixelF/X FS/XS functions.

GR32_Blend.pas:
- Added Difference and Exclusion PixelCombine functions (Pascal).
- Added PixelCombine function setup, to support non MMX cpus.
- Worked out bugfix for "not fully opaque" problem in blendroutines.

GR32_Transforms.pas:
- Added sfDraft resampling routines
- MMX optimized sfLinear and sfDraft
- Updated Transform to use PixelX and PixelXS

Contributors:

Arioch /BDV/:

GR32.pas
- Added WinPalette function. (merged by Mattias with some modifications)

Thomas Bauer:

GR32.pas:
- Some bugfixes (merged by Andre)

GR32_Transforms.pas:
- FullEdge related bugfixes (merged by Andre)

Soumitra Bhattacharjee:

GR32_Polygons.pas:
- Added PtInPolygon function. (merged by Mattias with some modifications)

Greg Chapman:

GR32_Filters.pas:
- Report and bugfix for the CheckParams problem in ApplyLUT. (merged by Andre)

Cleber:

GR32.pas:
- Added Color32ToRGB(A). (merged by Andre)

Marc Lafon:

GR32_Image.pas:
- Custom color properties for the bars (merged by Andre)

Peter Larson:

GR32_Polygons.pas:
- Initial work on polygon transformation and bitmap pattern filling.
- Some optimizations in polygon setup.

GR32_Transforms.pas:
- TransformPoints routine.

Gerd Platl :

Documentation:
- illustration for TPolyFillMode

Andrew P. Rybin:

GR32_Image.pas:
- MouseEnter/MouseLeave (merged by Andre with some changes to match structure)

J. Tulach:

GR32.pas:
- Additional handling of chroma transperancy in TBitmap32.Assign (merged by Andre with some modifications and comments).

GR32_Transforms.pas:
- C++ Builder workaround (merged by Andre)

Bob Voigt:

GR32_Blend.pas:
- ColorMul and ColorDiv (merged by Andre)

Jens Weiermann:

GR32_Filters.pas:
- enhancements to ApplyLUT and ColorToGrayscale that preserve alpha channel (merged by Andre)

Norbert Witternigg:

- updated the example project files to Borland C++ Builder 6.


GR32

GR32.pas contains common functions and classes for working with 32-bit device independent bitmaps (DIBs). It also defines some other basic types and operations.

Contents

Classes | Routines | Types | Constants
TBitmap32 | AlphaComponent | Arrays | Color Constants
TCustomMap | BlueComponent | Color Types | G32Version
TThreadPersistent | Color32 | Point Types |
 | Color32ToRGB | Rectangle Types |
 | Creating Points | TCombineMode |
 | Creating Rectangles | TDrawMode |
 | EqualRect | TFixed |
 | Fixed Point Math | TPixelCombineEvent |
 | Gray32 | TRectRounding |
 | GreenComponent | TSize |
 | HSLtoRGB | TStretchFilter |
 | InflateRect |  |
 | Intensity |  |
 | IntersectRect |  |
 | IsRectEmpty |  |
 | OffsetRect |  |
 | PtInRect |  |
 | RedComponent |  |
 | RGBtoHSL |  |
 | SetAlpha |  |
 | SetGamma |  |
 | WinColor |  |
 | WinPalette |  |


TBitmap32

Hierarchy

TPersistent

|

TThreadPersistent

|

TCustomMap

Description

TBitmap32 is the central class in the Graphics32 library. It manages a single 32-bit device-independent bitmap (DIB) and provides methods for drawing on it and combining it with other DIBs or other objects with device context (DC).

TBitmap32 overrides Assign and AssignTo methods (inherited from TPersistent) to provide compatibility with standard objects: TBitmap, TPicture and TClipboard in both directions. The design-time streaming to and from *.dfm files, inherited from TPersistent, is supported, but its realization is different from streaming with other stream types (See the source code for details).

TBitmap32 does not implement its own low-level streaming or low-level file loading/saving. Instead, it uses streaming methods of temporal TBitmap or TPicture objects. This is an obvious performance penalty, however such approach allows using third-party libraries, which extend TGraphic class for various image formats support (JPEG, TGA, TIFF, GIF, PNG, etc.). When you install them, TBitmap32 will automatically obtain support for new image file formats in design time and in run time.

Since TBitmap32 is a descendant of TThreadPersistent, it inherits its locking mechanism and it may be used in multi-threaded applications.

Change Notification

Change notification events (OnCange, OnResize), inherited from TThreadPersistent and TCustomMap are generated by most drawing/resizing etc. functions with a few exceptions. Due to performance considerations the following functions are not accompanied with event generation:

  • Pixel-based operations (SetPixelT, SetPixelF...);
  • HorzLine* and VertLine* functions;

If necessary, the OnCange event may be generated explicitly by calling the Changed methods.

Normally, if the bitmap is a part of some container (TImage32, TBitmapLayer, etc.), its change notification events are linked to the container, causing repaint operations. When making several simultaneous changes, it may be beneficial to enclose them in BeginUpdate…EndUpdate block followed by the Changed call to reduce the amount of repaintings of the container.

Reference

Properties | Methods | Events
In TBitmap32:
BitmapHandle | CanvasAllocated | OnHandleChanged
BitmapInfo | Clear | OnPixelCombine
Bits | Create |
Canvas | DeleteCanvas |
Clipping | Destroy |
ClipRect | Draw |
CombineMode | DrawTo |
DrawMode | Empty |
Font | FillRect |
Handle | FlipHorz |
MasterAlpha | FlipVert |
OuterColor | FrameRect |
PenColor | GetStippleColor |
Pixel | HandleChanged |
PixelPtr | HorzLine |
Pixmap | Line |
PixmapChanged | LineTo |
ScanLine | LoadFromFile |
StippleCounter | LoadFromResourceID |
StippleStep | LoadFromResourceName |
StretchFilter | LoadFromStream |
 | MoveTo |
 | RaiseRectTS |
 | RenderText |
 | ResetAlpha |
 | ResetClipRect |
 | Roll |
 | Rotate |
 | SaveToFile |
 | SaveToStream |
 | SetPixel |
 | SetSize |
 | SetStipple |
 | TextExtent |
 | TextHeight |
 | TextOut |
 | TextWidth |
 | UpdateFont |
 | VertLine |
In TCustomMap:
Height | Delete | OnResize
Width | Resized |
In TThreadPersistent:
LockCount | BeginUpdate | OnChange
UpdateCount | Changed |
 | EndUpdate |
 | Lock |
 | Unlock |

See Also

TBitmapLayer, TCustomMap, TImage32, TThreadPersistent


BitmapHandle

TBitmap32.BitmapHandle

property BitmapHandle: HBITMAP; // read-only;

Description

Returns current bitmap handle. See HBITMAP in Windows SDK documentation for more information.

Note, this property is not the same as Handle, which returns device handle (HDC).

This property is only available in the VCL version. For CLX use the property Pixmap instead.

See Also

Handle, PixelPtr, Pixmap, ScanLine


BitmapInfo

TBitmap32.BitmapInfo

property BitmapInfo: TBitmapInfo; // read-only;

Description

Returns a BITMAPINFO record corresponding to a current DIB data. See BITMAPINFO in Windows SDK documentation for more information.

This property is only available in the VCL version.

See Also

PixelPtr, ScanLine


Bits

TBitmap32.Bits

property Bits: PColor32Array; // Read-only

type TColor32Array = array [0..0] of TColor32;

type PColor32Array = ^TColor32Array;

Description

The bits property contains the address of the first (top-left) pixel in a bitmap. If the bitmap is not allocated (width or height is zero), the returned address is nil.

Note, that numbering of rows in Graphics32 starts from the top-most one.

Data is continuously allocated in memory, row by row. You may safely access Width * Height elements, each of them is a 4-byte TColor32 value. For example:

var

P: PColor32Array;

begin

P := Bitmap32.Bits;

for I := 0 to Bitmap32.Width * Bitmap32.Height - 1 do

P[I] := Gray32(Random(255)); // fill with a random grayscale noise

end;

Note, that in this code no size verification is required, if width or height is zero, their product is zero and the loop will never be executed.

See Also

TCustomMap.Height, PixelPtr, ScanLine, TColor32, TColor32Array, TCustomMap.Width


Canvas

TBitmap32.Canvas

property Canvas: TCanvas; // read-only;

Description

Returns current Canvas instance. You can use that to draw onto the bitmap. However the methods provided by TCanvas are mostly slower than using their native Bitmap32 counterparts. So try to avoid the usage of Canvas where possible.

Special note for CLX users: Due to the way QT is handling image and bitmap data, please try to avoid using only single Canvas operations. Every time you access the Canvas, the internal QImage is unavoidably copied to a QPixmap representative and copied back once the Bits property or any other internal method is accessed. So, if you access the Bits and Canvas properties in short interval after each other, that poses a heavy performance hit due to copying the QImage to QPixmap back and forth.


Clipping

TBitmap32.Clipping

property Clipping: Boolean;

Description

Determines if a clipping rect was set.


ClipRect

TBitmap32.ClipRect

property ClipRect: TRect;

Description

Determines the clipping rectangle that all safe drawing operations are clipped to.

If no clipping rectangle is set, ClipRect is equal to the current dimension of the bitmap.

Note: Validation is performed upon setting of a clipping rect, so the clip rect is always sane.

See Also

Naming Conventions


CombineMode

TBitmap32.CombineMode

property CombineMode: TCombineMode;

type TCombineMode = (cmBlend, cmMerge);

Description

TCombineMode defines how drawing operations on the bitmap combine the foreground color with the background.
It also determines how the bitmap is combined with the background of another bitmap when DrawMode is set to dmBlend.

  • cmBlend - Fast blending of foreground color with the background color using the supplied alpha. This method is not suited for working and preserving alpha-channels. Use this if you want to blend directly to the display buffer. Internally uses Blend and BlendEx routines.
  • cmMerge - Uses a completely different formula that also merges the alpha-channels. This mode is slower than blending but is suited for working with alpha-channels (eg. when composing in temporary buffers). Internally uses Merge and MergeEx routines.

See Also

Blend, BlendEx, Draw, DrawMode, DrawTo, Merge, MergeEx, TCombineMode


DrawMode

TBitmap32.DrawMode

property DrawMode: TDrawMode;

type TDrawMode = (dmOpaque, dmBlend, dmCustom);

Description

Specifies how the bitmap should be combined with a background during pixel transfer and similar operations.

In dmOpaque mode, new pixels simply replace the background pixels. In dmBlend mode, they are combined using the alpha blending operation defined by CombineMode. This property is used while copying one bitmap into another, scaling, performing linear transformations etc. The dmCustom mode allows implementation of custom blending functions using the OnPixelCombine call-back event.

See Also

CombineMode, Draw, DrawTo, OnPixelCombine, TDrawMode


Font

TBitmap32.Font

property Font: TFont;

Description

Specifies a current font used by text output functions.

See Also

RenderText, TextOut, UpdateFont


Handle

TBitmap32.Handle

This following only applies to the VCL version of Graphics32:

property Handle: HDC; // read-only

Description

Provides device handle of the contained DIB.

This handle may be used in low-level Windows API calls or, for example, to attach a TCanvas object to TBitmap32:

var

Canvas: TCanvas;

begin

Canvas := TCanvas.Create; // create a new independent TCanvas object

try

Canvas.Handle := Bitmap32.Handle; // attach it to the Bitmap32 object

Canvas.Pen.Color := clRed; // use standard TCanvas methods for drawing

Canvas.Brush.Color := clGreen;

Canvas.Ellipse(10, 10, 60, 40);

finally

Canvas.Free;

end;

end;

Handle contains zero, if the bitmap is empty (width or height is zero), and its value can change after resizing.

This example is just a simple illustration of using the Handle property. For more information on using the TCanvas object with TBitmap32, see the Canvas property.

This following only applies to the CLX version of Graphics32:

property Handle: QPainterH; // read-only

Description

This provides a pointer to the current instance of the QPainterH in TBitmap32.

You can use this QPainter instance in external functions. However please notice, that the QPainter is not associated with the QPixmap of TBitmap32. You'll have to call QPainter_begin and QPainter_end manually to do so. See the QT docs for more information on this topic.

See Also

Canvas, TBitmap32


MasterAlpha

TBitmap32.MasterAlpha

property MasterAlpha: TColor32;

Description

When blending a bitmap to the screen or to another bitmap, MasterAlpha normally controls the blending factor. The per-pixel opacity, stored in the blended bitmap, is premultiplied with MasterAlpha. If the MasterAlpha property is $00, the bitmap will be fully transparent, if it is equal to $FF, only per-pixel opacity, stored in bitmap’s alpha channel is used. This property is used only for bitmap blending, it does not affect pixel/line drawing and other similar routines.

When blending bitmaps in dmCustom draw mode, this property may be used for other purposes. Custom combining routine may use all 32 bits of MasterAlpha.

If the bitmap is in dmBlend draw mode and MasterAlpha is not in the [0…255] range, the blending result is not specified, it is your responsibility to keep MasterAlpha consistent with current draw mode.

See Also

DrawMode, TColor32


OuterColor

TBitmap32.OuterColor

property OuterColor: TColor32;

Description

This property specifies the color returned by PixelS property when reading the pixel with coordinates that lie outside the bitmap. The default value is $00000000, which corresponds to a fully transparent black. It is also used when performing linear transformations of a bitmap.

See Also

Pixel, TColor32


PenColor

TBitmap32.PenColor

property PenColor: TColor32;

Description

Simulates TCanvas.Pen.Color property. PenColor is used exclusively in MoveTo/LineTo functions.

See Also

LineTo, MoveTo, TColor32


Pixel

TBitmap32.Pixel

property Pixel[X, Y: Integer]: TColor32; default;

property PixelS[X, Y: Integer]: TColor32;

property PixelX[X, Y: TFixed]: TColor32;

property PixelXS[X, Y: TFixed]: TColor32;

property PixelF[X, Y: Single]: TColor32;

property PixelFS[X, Y: Single]: TColor32;

Description

Pixel property sets the value of the pixel in the bitmap. Reading it, will return the color value of the pixel located at specified coordinates. This property does not validate the specified coordinates, so use it only then you are completely sure that you are not trying to read from or write to the outside of the bitmap boundary. Pixel is declared as default property, you may use it as shown below:

Bitmap32[10, 20] := Bitmap32[20, 10]; // copy a pixel from (20,10) to (10,20) position

PixelS is a 'safe' version of the Pixel property. When reading pixels from the outside the bitmap boundary, the value specified by OuterColor is returned. Writing with invalid coordinates will have no effect.

PixelX provides a method for accessing the pixels in fixed-point coordinates. The returned color is computed by performing linear interpolation on four adjacent pixels. Similarly, when pixels are set, they are antialiased.

PixelXS is a 'safe' version of the above property.

PixelF is similar to PixelX but works with floating point coordinates instead of fixed point.

PixelFS is a 'safe' version of the above property.

See Also

Naming Conventions, OuterColor, SetPixel, TColor32, TFixed


PixelPtr

TBitmap32.PixelPtr

property PixelPtr[X, Y: Integer]: PColor32; // read-only

Description

Converts coordinates of a pixel to its address in memory. Since TBitmap32 uses 32-bit DIBs, its memory is allocated as continuous string of 4-byte TColor32 values, starting at the top left corner.

Pixel with (0, 0) coordinates has the same address as specified in Bits property.

See Also

Bits, Pixel, ScanLine, TBitmap32, TColor32


Pixmap

TBitmap32.Pixmap

property Pixmap: QPixmapH; // read-only;

Description

Returns a pointer to the current Pixmap instance. You can use that if you're working directly with QT related methods.

Important Note: Due to the nature of QT handling images and bitmap information, there is a need to notify TBitmap32 about changes you made to the QPixmap. You can use the PixmapChanged property to do so.
This will copy the Pixmap content as soon as the Bits property is accessed or some internal function is accessing the image data directly. This will make sure that the content is copied from the QPixmap to the internal QImage in TBitmap32.

This property is only available in the CLX version. For VCL use the property BitmapHandle instead.

See Also

BitmapHandle


PixmapChanged

TBitmap32.PixmapChanged

property PixmapChanged: Boolean;

Description

Returns whether the current QPixmap instance has changed or not. You can use that if you're working directly with QT related methods.

Important Note: Due to the nature of QT handling images and bitmap information, there is a need to notify TBitmap32 about changes you made to the QPixmap. You can use this property to do so.
This will copy the QPixmap content as soon as the Bits property is accessed or some internal function is accessing the image data directly. This will make sure that the content is copied from the QPixmap to the internal QImage in TBitmap32.

This property is only available in the CLX version.

See Also

Pixmap


ScanLine

TBitmap32.ScanLine

property ScanLine[Y: Integer]: PColor32Array; // read-only

Description

Provides indexed access to each line of pixels. Returns the same address as PixelPtr[0, Y]. This property acts similar to TBitmap.ScanLine.

See Also

Bits, PixelPtr, TColor32Array


StippleCounter

TBitmap32.StippleCounter

property StippleCounter: Single;

Description

Use StippleCounter property to access current value of the stipple counter.

See Also

GetStippleColor, Line Patterns, SetStipple, StippleStep


StippleStep

TBitmap32.StippleStep

property StippleStep: Single;

Description

Provides access to stipple step. Default value is 1.0.

It is possible to set step to fractional or negative value.

See Also

GetStippleColor, Line Patterns, SetStipple, StippleCounter


StretchFilter

TBitmap32.StretchFilter

property StretchFilter: TStretchFilter;

type TStretchFilter = (sfNearest, sfDraft, sfLinear, sfCosine, sfSpline, sfLanczos, sfMitchell);

Description

StretchFilter specifies color interpolation method for image stretching as well as for some other operations, like linear transformations. Some functions (transformations, for example) can interpolate only using the sfNearest and sfLinear filters, other values will be implicitly processed as sfLinear.

See Also

Draw, TStretchFilter


CanvasAllocated

TBitmap32.CanvasAllocated

function CanvasAllocated: Boolean;

Description

Indicates whether the internal Canvas has been allocated.

See Also

Canvas, RenderText, UpdateFont


Clear

TBitmap32.Clear

procedure Clear; overload;

procedure Clear(FillColor: TColor32); overload;

Description

Fills the entire bitmap with FillColor. If there is no argument specified, method uses clBlack32 ($FF000000).

See Also

TCustomMap.Delete, TColor32


Create

TBitmap32.Create

constructor Create; override;

Description

Creates and initializes an instance of TBitmap32.

After calling the inherited constructor, Create initializes the following properties:

  • BitmapInfo is filled with data corresponding to 32-bit DIBs;
  • DrawMode to dmOpaque;
  • MasterAlpha to 255 ($FF);
  • OuterColor to transparent black: $00000000;
  • PenColor to clWhite32;
  • StippleCounter to 0;
  • StippleStep to 1.0;
  • StretchFilter to sfNearest;

See Also

BitmapInfo, DrawMode, MasterAlpha, OuterColor, PenColor, StippleCounter, StippleStep, TBitmap32, TStretchFilter


DeleteCanvas

TBitmap32.DeleteCanvas

procedure DeleteCanvas;

Description

Destroys the internal Canvas object.

See Also

Canvas, CanvasAllocated, RenderText


Destroy

TBitmap32.Destroy

destructor Destroy; override;

Description

Destroys the bitmap object and frees all associated memory.

Do not call Destroy directly, use Free method instead.


Draw

TBitmap32.Draw

procedure Draw(DstX, DstY: Integer; Src: TBitmap32); overload;

procedure Draw(DstX, DstY: Integer; const SrcRect: TRect; Src: TBitmap32); overload;

procedure Draw(const DstRect, SrcRect: TRect; Src: TBitmap32); overload;

procedure Draw(const DstRect, SrcRect: TRect; hSrc: HDC); overload; // VCL version

procedure Draw(const DstRect, SrcRect: TRect; SrcPixmap: QPixmapH); overload; // CLX version

Description

Renders the image specified by Src/hSrc parameter (or part of it specified by SrcRect parameter) at the location given by the coordinates (DstX, DstY) or the DstRect rectangle.

The method provides both: block transfer (versions with DstX, DstY parameters) and stretching (versions with DstRect parameter).

When the source is another TBitmap32 object (Src parameter), the method uses Src.DrawMode do determine how it should be blended with the background, and if stretching, Src.StretchFilter specifies how the image should be stretched.

The version with hSrc parameter, is introduced mainly for compatibility reasons. You may use it to transfer data from bitmaps with other formats, or any other windows objects that have device handle (DC). It is based on StretchDIBits GDI call, it does not support transparency and always uses nearest neighbor interpolation when stretching.

The version that uses the SrcPixmap is only available in the CLX version of Graphics32. You may use it to transfer data directly from QPixmap instances such as TBitmap.

The Dst parameter must not be necessarily some other bitmap. In fact, it is possible to copy/stretch areas inside the same bitmap that calls the Draw method. However, in this case, if source and destination areas intersect, the result is not specified (this is a limitation of the current version).

See Also

BlockTransfer, DrawMode, DrawTo, StretchFilter, StretchTransfer, TBitmap32, TRect


DrawTo

TBitmap32.DrawTo

procedure DrawTo(Dst: TBitmap32); overload;

procedure DrawTo(Dst: TBitmap32; DstX, DstY: Integer); overload;

procedure DrawTo(Dst: TBitmap32; DstX, DstY: Integer; const SrcRect: TRect); overload;

procedure DrawTo(Dst: TBitmap32; const DstRect: TRect); overload;

procedure DrawTo(Dst: TBitmap32; const DstRect, SrcRect: TRect); overload;

procedure DrawTo(hDst: HDC; DstX, DstY: Integer); overload;

procedure DrawTo(hDst: HDC; const DstRect, SrcRect: TRect); overload;

Description

The DrawTo method renders the bitmap (or part of it specified by SrcRect parameter) onto another bitmap specified by Dst/hDst parameter. It works similar to Draw method but instead of copying data from some other source, the bitmap renders itselt to destination object. See the Draw description for details.

See Also

Draw, TBitmap32, TRect


Empty

TBitmap32.Empty

function Empty: Boolean; override;

Description

Returns True if the bitmap is empty, that is Width or Height is zero. If the bitmap is empty, it has no device context (Handle property) allocated.

See Also

Handle, TCustomMap.Height, TCustomMap.Width


FillRect

TBitmap32.FillRect

procedure FillRect(X1, Y1, X2, Y2: Integer; Value: TColor32);

procedure FillRectS(X1, Y1, X2, Y2: Integer; Value: TColor32); overload;

procedure FillRectT(X1, Y1, X2, Y2: Integer; Value: TColor32);

procedure FillRectTS(X1, Y1, X2, Y2: Integer; Value: TColor32); overload;

procedure FillRectS(const ARect: TRect; Value: TColor32); overload;

procedure FillRectS(const ARect: TRect; Value: TColor32); overload;

Description

Fills the rectangle with a specified color. Methods with 'S' postfix provide necessary clipping to bitmap boundaries, versions without 'S' must be supplied with valid parameters and X2 > X1; Y2 > Y1.

The function fills the rectangle up to, but not including the right column and bottom row. When X2 <= X1 or Y2 <= Y1, nothing is drawn.

See Also

FrameRect, Naming Conventions, TColor32


FlipHorz

TBitmap32.FlipHorz

procedure FlipHorz(Dst: TBitmap32);

Description

FlipHorz flips the image horizontally. When Dst parameter is specified, the transformed version of the image is copied into Dst, otherwise the procedure performs the in-place flipping.

See Also

FlipVert, TBitmap32


FlipVert

TBitmap32.FlipVert

procedure FlipVert(Dst: TBitmap32);

Description

FlipVert flips the image vertically. When Dst parameter is specified, the transformed version of the image is copied into Dst, otherwise the procedure performs the in-place flipping.

See Also

FlipHorz, TBitmap32


FrameRect

TBitmap32.FrameRect

procedure FrameRectS(X1, Y1, X2, Y2: Integer; Value: TColor32); overload;

procedure FrameRectTS(X1, Y1, X2, Y2: Integer; Value: TColor32); overload;

procedure FrameRectS(const ARect: TRect; Value: TColor32); overload;

procedure FrameRectTS(const ARect: TRect; Value: TColor32); overload;
procedure FrameRectTSP(X1, Y1, X2, Y2: Integer);

Description

Draws a rectangle frame. Row with X2 coordinate and column with Y2 coordinate are excluded.

If X2 <= X1 or Y2 <= Y1, the function does not draw the rectangle.

FrameRectTSP version supports line patterns.

See Also

FillRect, LineTo, Naming Conventions, TColor32


GetStippleColor

TBitmap32.GetStippleColor

function GetStippleColor: TColor32;

Description

Returns color corresponding to the current counter position in stipple pattern. If the counter step is fractional, returned color will be interpolated. Calling GetStippleColor automatically changes the StippleCounter value by StippleStep.

See Also

Line Patterns, SetStipple, StippleCounter, StippleStep, TColor32


HandleChanged

TBitmap32.HandleChanged

procedure TBitmap32.HandleChanged; virtual; // protected

Description

This method is called every time the device handle of the bitmap is changed. It calls the OnHandleChanged event.

See Also

Handle, Naming Conventions, OnHandleChanged


HorzLine

TBitmap32.HorzLine

procedure HorzLine(X1, Y, X2: Integer; Value: TColor32);

procedure HorzLineS(X1, Y, X2: Integer; Value: TColor32);

procedure HorzLineT(X1, Y, X2: Integer; Value: TColor32);

procedure HorzLineTS(X1, Y, X2: Integer; Value: TColor32);

procedure HorzLineTSP(X1, Y, X2: Integer);

Description

Draws a horizontal line from (X1,Y) to (X2, Y). The last point is always included.

These functions works faster compared to Line (I think HorzLine is the fastest line drawing function in the world :) . In versions with 'S' postfix necessary clipping to a bitmap coordinate range is provided. In versions without 'S' postfix, the X1 value should be less than or equal to X2.

HorzLineTSP uses a stipple pattern to vary the color along the line.

See Also

Line, Line Patterns, Naming Conventions, TColor32, VertLine


Line

TBitmap32.Line

procedure Line(X1, Y1, X2, Y2: Integer; Value: TColor32; L: Boolean = False);

procedure LineS(X1, Y1, X2, Y2: Integer; Value: TColor32; L: Boolean = False);

procedure LineT(X1, Y1, X2, Y2: Integer; Value: TColor32; L: Boolean = False);

procedure LineTS(X1, Y1, X2, Y2: Integer; Value: TColor32; L: Boolean = False);

procedure LineA(X1, Y1, X2, Y2: Integer; Value: TColor32; L: Boolean = False);

procedure LineAS(X1, Y1, X2, Y2: Integer; Value: TColor32; L: Boolean = False);

procedure LineX(X1, Y1, X2, Y2: TFixed; Value: TColor32; L: Boolean = False);

procedure LineXS(X1, Y1, X2, Y2: TFixed; Value: TColor32; L: Boolean = False);

procedure LineF(X1, Y1, X2, Y2: Single; Value: TColor32; L: Boolean = False);

procedure LineFS(X1, Y1, X2, Y2: Single; Value: TColor32; L: Boolean = False);

procedure LineXP(X1, Y1, X2, Y2: Single; L: Boolean = False);

procedure LineXSP(X1, Y1, X2, Y2: Single; L: Boolean = False);

procedure LineFP(X1, Y1, X2, Y2: Single; L: Boolean = False);

procedure LineFSP(X1, Y1, X2, Y2: Single; L: Boolean = False);

Description

Draws a line from (X1,Y1) to (X2,Y2). Methods with 'S' postfix perform necessary pixel-perfect clipping to a bitmap boundary or clipping rectangle.

LineA and LineAS use modified versions of Bresenham’s algorithm (also known as Wu’s antialiasing), modified to support line transparency and pixel shape/gamma correction.

LineX/F/XS/FS functions use my own algorithm for antialiasing. Line ends have fixed- or floating-point coordinates. These methods work approximately 2–2.5 times slower than LineA and LineAS.

The last optional parameter (L) determines if the last point (X2,Y2) has to be drawn. It is useful in some cases to leave that point empty, especially when drawing sequences of transparent and/or antialiased lines. By default, Line methods don’t render the last point.

LineXP/FP/XSP/FXP draw antialiased lines with support for color patterns.

See Also

HorzLine, LineTo, MoveTo, Naming Conventions, TColor32, VertLine


LineTo

TBitmap32.LineTo

procedure LineToS(X, Y: Integer);

procedure LineToTS(X, Y: Integer);

procedure LineToAS(X, Y: Integer);

procedure LineToXS(X, Y: TFixed);

procedure LineToFS(X, Y: Single);

procedure LineToXSP(X, Y: TFixed);

procedure LineToFSP(X, Y: Single);

Description

LineTo* methods are similar to TCanvas.LineTo. The line is drawn from the current raster position, to the position specified by X and Y parameters excluding the last point. Then raster position is shifted to (X, Y) point.

The line is drawn with the color specified in PenColor property. 'S', 'TS', and 'AS' versions use and update integer integer raster position, while 'FS' and 'XS' versions use and update independent fixed-point raster position.

LineToXSP and LineToFSP do not use PenColor, instead, they draw a line using currend stipple pattern.

To start a new line or sequence of lines, use MoveTo methods.

See Also

Line, Line Patterns, MoveTo, Naming Conventions, PenColor, TFixed


LoadFromFile

TBitmap32.LoadFromFile

procedure LoadFromFile(const FileName: string);

Description

Loads an image from a file. This method uses a temporal TPicture object to load data and will succeed with any format supported by TPicture.

See Also

ImgView and Layers Example, LoadFromStream, SaveToFile


LoadFromResourceID

TBitmap32.LoadFromResourceID

procedure LoadFromResourceID(Instance: THandle; ResID: Integer);

Description

Loads an image from a resource. Instance is the handle of the module that contains the resource. ResID is the resource ID for the bitmap

See Also

LoadFromFile, LoadFromResourceName, LoadFromStream


LoadFromResourceName

TBitmap32.LoadFromResourceName

procedure LoadFromResourceName(Instance: THandle; const ResName: string);

Description

Loads an image from a resource. Instance is the handle of the module that contains the resource. ResName is the name of the resource to load.

See Also

LoadFromFile, LoadFromResourceID, LoadFromStream


LoadFromStream

TBitmap32.LoadFromStream

procedure LoadFromStream(Stream: TStream);

Description

Loads an image from a stream. This method uses a temporal TPicture object to load data and will succeed with any format supported by TPicture.

See Also

LoadFromFile, SaveToStream


MoveTo

TBitmap32.MoveTo

procedure MoveTo(X, Y: Integer);

procedure MoveToX(X, Y: TFixed);

procedure MoveToF(X, Y: Single);

Description

Shifts current raster to specified position, analogous to MoveTo method of standard TCanvas.

Each bitmap maintains separate raster positions for integer and fixed point coordinates. MoveTo affects the integer raster position, while MoveToX and MoveToF affect the fixed-point raster position.

Raster position is applicable only to MoveTo, LineTo methods and some polygon drawing routines, which use it internally, it is not changed neither by Line methods nor by any other method.

See Also

Line, LineTo, Naming Conventions, TFixed


RaiseRectTS

TBitmap32.RaiseRectTS

procedure RaiseRectTS(X1, Y1, X2, Y2: Integer; Contrast: Integer);

Description

This function draws a raised or recessed frame. The contrast property is an integer value ranging from –100 to +100.

See Also

FrameRect, Naming Conventions


RenderText

TBitmap32.RenderText

procedure RenderText( X, Y: Integer; const Text: String; AALevel: Integer; Color: TColor32);

procedure RenderTextW( X, Y: Integer; const Text: Widestring; AALevel: Integer; Color: TColor32);

Description

The RenderText or RenderTextW (the Unicode-Version) method draws a string of characters. This method is much slower compared to TextOut functions, however it supports antialiasing and transparency. AALevel specifies how the text is antialiased. If it is zero, no antialiasing is performed, the value of 4 corresponds to a maximum quality.

Note, that quality of the text is also influenced by the system font antialiasing.

This method draws a string using current Font, but it ignores the Font.Color property, substituting it with the Color parameter.

Please note that the CLX versions of the non-Unicode methods do also default to Widestring because that is the native QT string format.

See Also

Font, RenderText Example, TColor32, TextExtent, TextOut


ResetAlpha

TBitmap32.ResetAlpha

procedure ResetAlpha; overload;

procedure ResetAlpha(const AlphaValue: Byte); overload;

Description

Resets the alpha channel of the entire bitmap either to $FF or the value defined by AlphaValue.


ResetClipRect

TBitmap32.ResetClipRect

procedure ResetClipRect;

Description

Resets the clipping rect to the current dimensions of the bitmap.


Roll

TBitmap32.Roll

procedure Roll(Dx, Dy: Integer; FillBack: Boolean; FillColor: TColor32);

Description

Use Roll to scroll the whole bitmap Dx pixels right and Dy pixels down.

Dx an Dy may be negative.

The content of the new area may optionally be cleared with FillColor, if FillBack is true.

See Also

TColor32


Rotate

TBitmap32.Rotate

procedure Rotate90(Dst: TBitmap32);

procedure Rotate180(Dst: TBitmap32);

procedure Rotate270(Dst: TBitmap32);

Description

A set of optimized routines for rotating the image 90, 180, and 270 degrees. Angles correspond to the clockwise rotation.

See Also

TBitmap32


SaveToFile

TBitmap32.SaveToFile

procedure SaveToFile(const FileName: string);

Description

Writes a bitmap image to disk. The image is saved as 32-bit BMP file.

If you need another pixel format or storage format, create intermediate TBitmap object or other TGraphic descendant, assign it from TBitmap32 and save it to a file.

See source of TBitmap.SaveToFile for more details.

See Also

LoadFromFile, SaveToStream


SaveToStream

TBitmap32.SaveToStream

procedure SaveToStream(Stream: TStream);

Description

Stores a bitmap image to a stream. The data in the stream is stored in a form compatible with TBitmap, where each pixel allocates 32 bits.

[See also]: LoadFromStream, SaveToFile

See Also

LoadFromStream, SaveToFile


SetPixel

TBitmap32.SetPixel

procedure SetPixelT(X, Y: Integer; Value: TColor32); overload;

procedure SetPixelT(var Ptr: PColor32; Value: TColor32); overload;

procedure SetPixelTS(X, Y: Integer; Value: TColor32);

procedure SetPixelX(X, Y: TFixed; Value: TColor32); deprecated;

procedure SetPixelXS(X, Y: TFixed; Value: TColor32); deprecated;

procedure SetPixelF(X, Y: Single; Value: TColor32); deprecated;

procedure SetPixelFS(X, Y: Single; Value: TColor32); deprecated;

Description

SetPixelT blends the pixel with a bitmap at specified coordinates using the specified color. The pixel’s alpha channel is used, but the coordinates are not validated.

The overloaded version of SetPixelT with a pixel pointer argument allows setting pixels addressed with the pointer rather than with coordinates. The pointer is automatically incremented to a next pixel position with each call to SetPixelT, for example:

var
P: PColor32;
I: Integer;
begin { Draw a fading white line from (10, 20) to (265, 20) }
P := PixelPtr[10, 20];
for I := 0 to 255 do SetPixelT(P, Color32(255, 255, 255, 255 - I));
end;

SetPixelTS is the SetPixelT method with added coordinate verification. If pixel coordinates lie outside the bitmap area, SetPixelTS does nothing.

SetPixelX/F/XS/FS methods are deprecated. Please use the PixelX/F/XS/FS property instead.

See Also

Naming Conventions, Pixel, TColor32, TFixed


SetSize

TBitmap32.SetSize

function SetSize(NewWidth, NewHeight: Integer): Boolean; override;

procedure SetSize(Source: TPersistent); // implemented in TCustomMap

Description

Call SetSize to set a new width and height of the bitmap. If one of the arguments is zero, the bitmap is considered empty and its Handle property is set to zero.

Calling SetSize works faster than consecutive changing of Width and Height properties. If you use another bitmap or control as an argument, the bitmap will be sized to source dimensions.

If you have an external TCanvas attached, refresh it Handle property after resizing:

Bitmap32.SetSize(100, 200);

Canvas.Handle := Bitmap32.Handle;

After the SetSize call the image the bitmap should be completely redrawn.

See Also

Handle, TCustomMap.Height, TCustomMap, TCustomMap.Width


SetStipple

TBitmap32.SetStipple

procedure SetStipple(NewStipple: TArrayOfColor32); overload;

procedure SetStipple(NewStipple: array of TColor32); overload;

Description

Sets a new stipple pattern.

See Also

GetStippleColor, Line Patterns, TArrayOfColor32, TColor32


TextExtent

TBitmap32.TextExtent

function TextExtent(const Text: String): TSize;

function TextExtentW(const Text: Widestring): TSize;

Description

Returns the width and height, in pixels, of a string rendered in the current Font.

Note, that the size returned by this function may differ from the actual width of the text produced by RenderText function, especially when using raster fonts.

Please note that the CLX versions of the non-Unicode methods do also default to Widestring because that is the native QT string format.

See Also

Font, RenderText, TextHeight, TextOut, TextWidth, TSize


TextHeight

TBitmap32.TextHeight

function TextHeight(const Text: String): Integer;

function TextHeightW(const Text: Widestring): Integer;

Description

Returns the height, in pixels, of a string rendered in the current Font.

Please note that the CLX versions of the non-Unicode methods do also default to Widestring because that is the native QT string format.

See Also

Font, RenderText, TextExtent, TextOut, TextWidth


TextOut

TBitmap32.TextOut

procedure TextOut(X, Y: Integer; const Text: String); overload;

procedure TextOutW(X, Y: Integer; const Text: Widestring); overload;

procedure TextOut(X, Y: Integer; const ClipRect: TRect; const Text: String); overload;

procedure TextOutW(X, Y: Integer; const ClipRect: TRect; const Text: Widestring); overload;

procedure TextOut(DstRect: TRect; const Flags: Cardinal; const Text: String); overload;

procedure TextOutW(DstRect: TRect; const Flags: Cardinal; const Text: Widestring); overload;

Description

Use TextOut or TextOutW (the Unicode version) to write a string onto the bitmap. The string will be written using current Font.

Use the TextExtent method to determine the space occupied by the text in the image. TextOut does not support transparent text colors.

The second version performs clipping of a text to the ClipRect rectangle.

The last version provides the most flexible text formatting. See description of DrawText function in 'Win32 Developer Reference' help file for information on Flags and their function.

Special Note for CLX users:

Since CLX is based on the QT library rather than the native Win API the flags used in the last two functions are somewhat different from the Win32 flags. You can get more information on the QT specific flags here and here. However, to make it easier for you, we have provided some basic mappings that will work in QT just as their Win API counterparts:

DT_LEFT, DT_RIGHT, DT_TOP, DT_BOTTOM, DT_CENTER, DT_VCENTER, DT_EXPANDTABS, DT_NOCLIP, DT_WORDBREAK, DT_SINGLELINE

However, the following flags are missing because there is no equivalent value in QT at this time:

DT_CALCRECT, DT_EDITCONTOL, DT_END_ELLIPSIS and DT_PATH_ELLIPSIS, DT_EXTERNALLEADING, DT_MODIFYSTRING, DT_NOPREFIX, DT_RTLREADING, DT_TABSTOP

Please note that the CLX versions of the non-Unicode methods do also default to Widestring because that is the native QT string format.

See Also

Font, RenderText, TextExtent, TextHeight, TextWidth, TRect


TextWidth

TBitmap32.TextWidth

function TextWidth(const Text: String): Integer;

function TextWidthW(const Text: Widestring): Integer;

Description

Returns the width, in pixels, of a string rendered in the current Font.

Please note that the CLX versions of the non-Unicode methods do also default to Widestring because that is the native QT string format.

See Also

Font, RenderText, TextExtent, TextHeight, TextOut


UpdateFont

TBitmap32.UpdateFont

procedure UpdateFont;

Description

Use this method before calling the Windows API functions that handle text output. It will synchronize the device font object with the Font property. You do not have to call UpdateFont when using text output methods of TBitmap32 since they call UpdateFont automatically.

See Also

Font, TBitmap32


VertLine

TBitmap32.VertLine

procedure VertLine(X, Y1, Y2: Integer; Value: TColor32);

procedure VertLineS(X, Y1, Y2: Integer; Value: TColor32);

procedure VertLineT(X, Y1, Y2: Integer; Value: TColor32);

procedure VertLineTS(X, Y1, Y2: Integer; Value: TColor32);

procedure VertLineTSP(X, Y1, Y2: Integer);

Description

Draws a vertical line from (X,Y1) to (X, Y2). The last point is included.

These functions works faster compared to Line. In versions with 'S' postfix necessary clipping to a bitmap coordinate range is provided. In versions without 'S', the Y2 value should be greater or equal to Y1.

VertLineTSP supports line patterns.

See Also

HorzLine, Line, Line Patterns, Naming Conventions, TColor32


OnHandleChanged

TBitmap32.OnHandleChanged

property OnHandleChanged: TNotifyEvent;

Description

This event is called when the HDC/QPainterH of property Handle changed. Use this event to customize handling of such events.

See Also

Handle


OnPixelCombine

TBitmap32.OnPixelCombine

property OnPixelCombine: TPixelCombineEvent;

type TPixelCombineEvent = procedure(F: TColor32; var B: TColor32; M: TColor32) of object;

Description

This event is called when the bitmap is drawn in dmCustom draw mode. Use this event to customize handling of colors. Note, however, that this event is called for every pixel, so keeping the event handler small and fast is in your own interest.

See Also

DrawMode, PixelCombine Example, TColor32, TPixelCombineEvent


TCustomMap

Hierarchy

TPersistent

|

TThreadPersistent

Description

TCustomMap is a common ancestor for objects that hold 2D arrays of data.

Reference

Properties | Methods | Events
In TCustomMap:
Height | Delete | OnResize
Width | Empty |
 | Resized |
 | SetSize |
In TThreadPersistent:
LockCount | BeginUpdate | OnChange
UpdateCount | Changed |
 | Create |
 | Destroy |
 | EndUpdate |
 | Lock |
 | Unlock |


Height

TCustomMap.Height

property Height: Integer;

Description

Specifies the height of the contained data array.

Use SetSize method to change both width and height simultaneously.

See Also

SetSize, Width


Width

TCustomMap.Width

property Width: Integer;

Description

Defines the width of the contained data array.

Writing into the Width property will resize the data array.

See Also

Height, SetSize


Delete

TCustomMap.Delete

procedure Delete; virtual;

Description

By default, Delete calls SetSize(0, 0). In descendants this is accompanied with deletion of stored data and freeing of the occupied memory.

See Also

SetSize


Empty

TCustomMap.Empty

function Empty: Boolean; virtual;

Description

Returns True if the data set is empty. Normally, it means that either its Width or Height is 0.

See Also

Height, Width


Resized

TCustomMap.Resized

procedure Resized; virtual;

Calls the OnResize event.

Descendants of TCustomMap call Resized internally after changing the size of the contained data array.

See Also

OnResize, TCustomMap


SetSize

TCustomMap.SetSize

procedure SetSize(NewWidth, NewHeight: Integer); virtual;

procedure SetSizeFrom(Source: TPersistent);

Description

Simultaneously changes both Width and Height of contained data.

The SetSizeFrom method 'knows' how to get the size from the following objects or their descendants: TCustomMap, TGraphic, TControl and nil. When other parameter is specified, TCusomMap will generate an exception.

The SetSize method is overriden in descendants (TBitmap32, TByteMap) so that bitmap bits are reallocated and byte map data array is resized.

See Also

Height, TBitmap32, TByteMap, TCustomMap, Width


OnResize

TCustomMap.OnResize

property OnResize: TNotifyEvent;

Description

OnResize is called each time dimensions of the associated data array change. This event is normally preceeded with the OnChange call.

Similar to OnChange, generation of OnResize may be temporarily suppressed with BeginUpdate/EndUpdate.

See Also

TThreadPersistent.BeginUpdate, TThreadPersistent.EndUpdate, TThreadPersistent.OnChange


TThreadPersistent

Hierarchy

TPersistent

Description

TThreadPersistent extends the standard TPersistent class with the thread-safe locking and declares change notification events.

The locking provides means of syncronization of simultaneous access to the same resource in applications with multiple threads and it works similar to that in TCanvas class. For additional information, see Delphi documentation on TCanvas.

This class also declares change notification abilities. That is, it provides methods and events allowing it descendants to issue notification on their changes. For example, TBitmap32 uses OnChange to notify its container (usually TImage32 or TBitmapLayer) that it was modified and its data has to be repainted to the screen. TThreadPersistent, however, does not use or implement automatic change notification itself. This is done in descendants.

Reference

Properties | Methods | Events
In TThreadPersistent:
LockCount | BeginUpdate | OnChange
UpdateCount | Changed |
 | Create |
 | Destroy |
 | EndUpdate |
 | Lock |
 | Unlock |

See Also

TBitmap32, TBitmapLayer, TImage32


LockCount

TThreadPersistent.LockCount

property LockCount: Integer; // Read-only; protected;

Description

LockCount represents the current nesting level of the threading lock. This is a counter shared by all running threads in the curent process.

The object is unlocked only when LockCount is 0 and only one thread can lock the object at the time. Call Lock to increase LockCount value and Unlock to decrease it.

See Also

Lock, Unlock


UpdateCount

TThreadPersistent.UpdateCount

property UpdateCount: Integer; // Read-only; protectred;

Description

The current nesting level of the update lock.

UpdateCount is increased each time you call the BeginUpdate method and is decreased with EndUpdate calls. The object does not generate OnChange as long as its UpdateCount is greater than 0.

See Also

BeginUpdate, EndUpdate, OnChange


BeginUpdate

TThreadPersistent.BeginUpdate

procedure BeginUpdate;

Description

Call this method in order to temporarily disable the update notification.

BeginUpdate increases the UpdateCount property, which disables generation of OnChange events. Calls to BeginUpdate must be paired with EndUpdate and they may be safely nested.

See Also

EndUpdate, OnChange, UpdateCount


Changed

TThreadPersistent.Changed

procedure Changed;

Description

Calls the OnChange event, provided the change notification is not masked with BeginUpdate.

Descendants of TThreadPersistent call Changed after making changes to their data or properties.

You will need to call Changed explicitly in your application after leaving the BeginUpdate... EndUpdate block since EndUpdate itself does not internally call Changed.

See Also

BeginUpdate, EndUpdate, OnChange, TThreadPersistent


Create

TThreadPersistent.Create

constructor Create; virtual;

Description

Creates and initializes an instance of TThreadPersistent.

See Also

TThreadPersistent


Destroy

TThreadPersistent.Destroy

destructor Destroy; override;

Description

Destroys the TThreadPersistent object.

Do not call Destroy directly, use Free method instead.

See Also

TThreadPersistent


EndUpdate

TThreadPersistent.EndUpdate

procedure EndUpdate;

Description

Re-enables change notification previously disabled with BeginUpdate.

EndUpdate decreases the UpdateCount property and re-enables generation of OnChange events.

EndUpdate itself does not generate the OnChange event. You will need to call Changed explicitly, after calling EndUpdate in case the change notification is required.

See Also

BeginUpdate, Changed, OnChange, UpdateCount


Lock

TThreadPersistent.Lock

procedure Lock;

Description

Blocks other execution threads from locking the object until the Unlock method is called. If another thread tryes to call the Lock method of an object which is already locked, its execution will be stalled until the lock is released with Unlock method.

Once a thread has locked the object, it can make additional calls to Lock method without blocking its own execution. This prevents the thread from deadlocking itself while waiting for releasing of a lock that it already owns. LockCount is increased each time Lock is called.

See Also

LockCount, Unlock


Unlock

TThreadPersistent.Unlock

procedure Unlock;

Description

Removes the multithreading lock from the object.

Each call to Unlock decreases the LockCount property, allowing other threads to access the object when LockCount reaches 0. Each thread must call Unlock once for each time that it locked the object.

See Also

Lock, LockCount


OnChange

TThreadPersistent.OnChange

property OnChange: TNotifyEvent;

Description

OnChange is called immediately after the object changes. For example, TThreadPersistent’s descendant TBitmap32, uses the OnChange event to notify its parent that something was changed in a bitmap, and the screen image must be updated.

Generation of OnChange events can be prevented by calling BeginUpdate.

See Also

BeginUpdate, Changed, TBitmap32, TThreadPersistent


AlphaComponent

function AlphaComponent(Color32: TColor32): Integer;

Description

Extracts the alpha component from the parameter.

This function is provided for convenience only. Use direct conversion in performance-critical parts of your code, for example:

Alpha := Color32 shr 24;

See Also

BlueComponent, GreenComponent, RedComponent, TColor32


BlueComponent

function BlueComponent(Color32: TColor32): Integer;

Description

Extracts the blue component from the parameter.

This function is provided for convenience only. Use direct conversion in performance-critical parts of your code:

Blue := Color32 and $0000FF;

See Also

AlphaComponent, GreenComponent, RedComponent, TColor32


Color32

function Color32(R, G, B: Byte; A: Byte = $FF): TColor32; overload;

This function combines its parameters into a 4-byte TColor32.

function Color32(WinColor: TColor): TColor32; overload;

This function provides conversion of TColor into TColor32.

The pixel format of 32-bit DIBs (ARGB) is different from that used in the standard TColor type (ABGR). Some standard windows colors are coded using special constants which are encoded into RGB form.

The alpha of the resulting color is set to $FF;

function Color32(Index: Byte; Palette: PPalette32): TColor32; overload;

This function simply picks the color value from the palette, same as

Result := Palette[Index];

See Also

Gray32, TColor32, TPalette32, WinColor


Color32ToRGB

procedure Color32ToRGB(Color32: TColor32; var R, G, B: Byte);

procedure Color32ToRGBA(Color32: TColor32; var R, G, B, A: Byte);

Both procedures split the Color32 parameter up into their respective components.

These procedures are provided for convenience only. Use direct conversion in performance-critical parts of your code:

Alpha := Color32 shr 24;

Red := (Color32 and $00FF0000) shr 16;

Green := (Color32 and $0000FF00) shr 8;

Blue := Color32 and $000000FF;


Creating Points

Point

function Point(X, Y: Integer): TPoint; overload;

function Point(const FP: TFloatPoint): TPoint; overload;

function Point(const FXP: TFixedPoint): TPoint; overload;

Constructs a point with integer coordinates, or converts it from the one with fixed/floating point coordinates by rounding them to nearest integers.

FloatPoint

function FloatPoint(X, Y: Single): TFloatPoint; overload;

function FloatPoint(const P: TPoint): TFloatPoint; overload;

function FloatPoint(const FXP: TFixedPoint): TFloatPoint; overload;

Provides construction and converstion of points with floating-point coordinates.

FixedPoint

function FixedPoint(X, Y: Integer): TFixedPoint; overload;

function FixedPoint(X, Y: Single): TFixedPoint; overload;

function FixedPoint(const P: TPoint): TFixedPoint; overload;

function FixedPoint(const FP: TFloatPoint): TFixedPoint; overload;

Provides construction and converstion of points with fixed-point coordinates

See Also

TFixedPoint, TFloatPoint, TPoint


Creating Rectangles

Rect

function MakeRect(L, T, R, B: Integer): TRect; overload;

function MakeRect(const FR: TFloatRect; Rounding: TRectRounding = rrClosest): TRect; overload;

function MakeRect(const FXR: TFixedRect; Rounding: TRectRounding = rrClosest): TRect; overload;

Provides construction and convertion of rectangles with integer coordinates.

FloatRect

function FloatRect(L, T, R, B: Single): TFloatRect; overload;

function FloatRect(const Rect: TRect): TFloatRect; overload;

function FloatRect(const FXR: TFixedRect): TFloatRect; overload;

Provides construction and convertion of rectangles with floating-point coordinates.

FixedRect

function FixedRect(L, T, R, B: TFixed): TFixedRect; overload;

function FixedRect(const Rect: TRect): TFixedRect; overload;

function FixedRect(const FR: TFloatRect): TFixedRect; overload;

Provides construction and convertion of rectangles with fixed-point coordinates.

See Also

TFixedRect, TFloatRect, TRect, TRectRounding


EqualRect

function EqualRect(const R1, R2: TRect): Boolean;

Description

Returns True if the rectangles are identical.

See Also

TRect


Fixed Point Math

Fixed

function Fixed(S: Single): TFixed; overload;

function Fixed(I: Integer): TFixed; overload;

A couple of TFixed constructors.

In case you don't want your program to loose time on extra function call, you can use another method of converting Integer to TFixed:

var

FX: TFixed;

begin

FX := IntVal shl 16;

...

end;

FixedFloor

function FixedFloor(A: TFixed): Integer;

An analogue to Floor function.

FixedCeil

function FixedCeil(A: TFixed): Integer;

An implementation of the Ceil function for TFixed type.

FixedMul

function FixedMul(A, B, TFixed): TFixed;

This is the same as using MulDiv(A, B, $10000).

FixedDiv

function FixedDiv(A, B, TFixed): TFixed;

This is the same as using MulDiv(A, $10000, B).

FixedRound

function FixedRound(A, B, TFixed): TFixed;

Provides correct rounding of fixed-point values.

See Also

TFixed


Gray32

function Gray32(Intensity: Byte; Alpha: Byte): TColor32;

Description

The action of Gray32(I, A) is the same as Color32(I, I, I, A). It just works faster.

See Also

AlphaComponent, BlueComponent, Color32, GreenComponent, RedComponent, TColor32


GreenComponent

function GreenComponent(Color32: TColor32): Integer;

Description

Extracts the green component from the parameter.

This function is provided for convenience only. Use direct conversion in performance-critical parts of your code:

Green := (Color32 and $0000FF00) shr 8;

See Also

AlphaComponent, BlueComponent, RedComponent, TColor32


HSLtoRGB

function HSLtoRGB(H, S, L: Single): TColor32;

Description

Conversion from HSL to RGB color space. Each argument should normally be in [0…1] range, although the H value is automatically wrapped.

See Also

Gray32, RGBtoHSL, TColor32


InflateRect

procedure InflateRect(var R: TRect; Dx, Dy: Integer); overload;

procedure InflateRect(var FR: TFloatRect; Dx, Dy: Single); overload;

Description

Increases (or decreases if Dx, Dy negative) the width and height of specified rectangle:

R.Left := R.Left - Dx;
R.Right := R.Right + Dx;
R.Top := R.Top - Dy;
R.Bottom := R.Bottom + Dy;

See Also

OffsetRect, TFloatRect, TRect


Intensity

function Intensity(Color32: TColor32): Integer;

Description

Returns weighted intensity of the color, which is calculated as

I = R * 0.21 + G * 0.71 + B * 0.08;

See Also

Color32, Gray32, TColor32


IntersectRect

function IntersectRect(out Dst: TRect; const R1, R2: TRect): Boolean; overload;

function IntersectRect(out Dst: TFloatRect; const FR1, FR2: TFloatRect): Boolean; overload;

Description

Calculates intersection of the rectangles and writes result into Dst. Functions return True if rectangles intersect, otherwise it returns False and writes an empty rectangle into Dst, that is rectangle with all coortinates equal to 0.

See Also

Creating Rectangles, TFloatRect, TRect


IsRectEmpty

function IsRectEmpty(const R: TRect): Boolean; overload;

function IsRectEmpty(const FR: TRect): Boolean; overload;

Description

Returns True if the rectangle is empty, that is its width or height is not positive.

See Also

TRect


OffsetRect

procedure OffsetRect(var R: TRect; Dx, Dy: Integer);

procedure OffsetRectF(var FR: TFloatRect; Dx, Dy: Single);

Description

Use thise functions to shift rectangles. Dx and Dy parameters specify the distance.

See Also

InflateRect, TFloatRect, TRect


PtInRect

function PtInRect(const R: TRect; const P: TPoint): Boolean;

Description

Returns True if the point lies inside the specified rectangle.

See Also

TPoint, TRect


RedComponent

function RedComponent(Color32: TColor32): Integer;

Description

Extracts the red component from the parameter.

This function is provided for convenience only. In performance-critical parts of your code I'd recommend the following direct conversion:

Red := (Color32 and $00FF0000) shr 16;

See Also

AlphaComponent, BlueComponent, GreenComponent, TColor32


RGBtoHSL

procedure RGBtoHSL(RGB: TColor32; var H, S, L : Single);

Description

Conversion from RGB to HSL color space. The H, S and L components are returned in corresponding var parameters ranging from 0 to 1.

See Also

Gray32, HSLtoRGB, TColor32


SetAlpha

function SetAlpha(Color32: TColor32; NewAlpha: Integer): TColor32;

Description

Returns a color with the new alpha channel. This function automatically performs clipping of the NewAlpha parameter to [0…255] range.

See Also

TColor32


SetGamma

procedure SetGamma(Gamma: Single = 0.7);

Description

Updates gamma/shape correction table.

Pixel and line antialiasing produces much better results with correction of opacities for partially covered pixels. This accounts both for monitor gamma and for pixel shape correction.

Use this function to update the internal gamma-correction table which is used in pixel and line rasterization.

The default value of 0.7 works fine in most cases.


WinColor

function WinColor(Color32: TColor32): TColor;

Description

Provides conversion of the TColor32 value back into TColor. The highest-order byte (Alpha channel) of resulting color is assigned the $FF value.

See Also

Color32, TColor32


WinPalette

function WinPalette(P: TPalette32): HPALETTE;

Description

The provided TPalette32 fixed-size buffer of color values is converted into the Win32 API equivalent HPALETTE handle definition of a palette with 256 32-bit color entries.

See Also

Color32, TPalette32


Arrays

TArrayOfByte

type TArrayOfByte = array of Byte;

A dynamic array of bytes.

TArrayOfInteger

type TArrayOfInteger = array of Integer;

A dynamic array of integers.

TArrayOfSingle

type TArrayOfSingle = array of Single;

A dynamic array of single-precision floating-point values.

TArrayOfArrayOfInteger

type TArrayOfArrayOfInteger = array of TArrayOfInteger;

A dynamic array of dynamic arrays of integers.


Color Types

TColor32

type TColor32 = type Longword;

type PColor32 = ^TColor32;

A simple ARGB color quad, compatible with 32-bit DIBs.

TColor32 holds color information in ARGB format:

Bits 32...24 | Bits 23...16 | Bits 15...8 | Bits 7...0
Alpha | Red | Green | Blue

This order is different from ABGR pixel format used by most Windows API functions and implemented in Delphi as TColor type. A couple of functions is provided to convert colors between different standards: Color32, WinColor.

The alpha channel is responsible for pixel’s opacity: zero value corresponds to complete transparency, and the value of 255 corresponds to completely opaque pixels.

Graphics32 specifies several pre-defined Color Constants, which are similar to standard ones except that they have properly filled alpha value and swapped red and blue channels.

TColor32Array

type TColor32Array = array [0..0] of TColor32;

type PColor32Array = ^TColor32Array;

A reference to array of TColor32-typed values.

Most likely you will never use the TColor32Array type itself, however PColor32Array is the one of some importance. It provides indexed access to color values stored in memory. For example, in TBitmap32, it is used to access pixel data.

TArrayOfColor32

type TArrayOfColor32 = array of TColor32;

A dynamic array of TColor32-typed values.

You may use the standard SetLength function for array allocation and dynamic size changes.

Do not confuse PColor32Array and TArrayOfColor32 types. While the first one holds the pointer to a memory location, the second one is a fully functional dynamic array.

TPalette32

type TPalette32 = array [Byte] of TColor32;

type PPalette32 = ^TPalette32;

A fixed-size array of 256 TColor32-typed values.

TPalette32 type is mostly used to simulate palette-based operations.

See Also

Color Constants, Color32, TBitmap32, WinColor


Point Types

Graphics32 uses coordinate system with an origin at the top-left corner. Due to performance considerations, other coordinate systems are not supported and not planned in future versions.

Point coordinates are defined with following structures:

TPoint

type TPoint = Windows.TPoint;

type PPoint = ^TPoint;

A point with integer coordinates. TPoint type, is redeclared from Windows.pas unit. It is compatible with all Delphi/Windows API calls.

TFloatPoint

type TFloatPoint = record
X, Y: Single;
end;

type PFloatPoint = ^TFloatPoint;

Defines a point with single-precision floating-point coordinates.

TFixedPoint

type TFixedPoint = record
X, Y: TFixed;
end;

type PFixedPoint = ^TFixedPoint;

TFixedPoint is bitwise-compatible with TPointFx type from Windows.pas, which is used by some API calls. TFixedPoint is not assignment-compatible with TPointFX, however, appropriate data in memory may be safely referenced by both types and it is still possible to assign between these types using, for example, Move procedure from System.pas.

TArrayOfPoint

type TArrayOfPoint = array of TPoint;

A dynamic array of TPoint.

TArrayOfFloatPoint

type TArrayOfFloatPoint = array of TFloatPoint;

A dynamic array of TFloatPoint.

TArrayOfFixedPoint

type TArrayOfFixedPoint = array of TFixedPoint;

A dynamic array of TFixedPoint.

TArrayOfArrayOfPoint

type TArrayOfArrayOfPoint = array of TArrayOfPoint;

TArrayOfArrayOfFloatPoint

type TArrayOfArrayOfFloatPoint = array of TArrayOfFloatPoint;

TArrayOfArrayOfFixedPoint

type TArrayOfArrayOfFixedPoint = array of TArrayOfFixedPoint;

Maybe last three types look a little cumbersome, but they are what it says: dynamic arrays of dynamic arrays of points. These are the types used in PolyPolyline and PolyPolygon functions to define shapes constructed of several outlines.

See Also

Creating Points, PolyPolygon, PolyPolyline, TFixed


Rectangle Types

Several data types are designated to handle rectangles:

TRect

type TRect = Windows.TRect;

TRect is redeclared from Windows.h and is compatible with Delphi/Windows API calls.

TFloatRect

type TFloatRect = record
case Integer of
0: (Left, Top, Right, Bottom: Single);
1: (TopLeft, BottomRight: TFloatPoint);
end;

A rectangle with floating-point coordinates.

TFixedRect

type TFixedRect = record
case Integer of
0: (Left, Top, Right, Bottom: TFixed);
1: (TopLeft, BottomRight: TFixedPoint);
end;

A rectangle with fixed-point coordinates.

See Also

Creating Rectangles, TFixed, TFixedPoint, TFloatPoint


TCombineMode

type TCombineMode = (cmBlend, cmMerge);

Description

TCombineMode defines how drawing operations combine the foreground color with the background.
It also determines how a bitmap is combined with the background when DrawMode is set to dmBlend.

  • cmBlend - Fast blending of foreground color with the background color using the supplied alpha. This method is not suited for working and preserving alpha-channels. Use this more if you want to blend directly to the display buffer.
  • cmMerge - Uses a completely different formula that also merges the alpha-channels. This mode is slower than blending but is suited for working with alpha-channels (eg. when composing in temporary buffers).

See Also

TBitmap32.DrawMode


TDrawMode

type TDrawMode = (dmOpaque, dmBlend, dmCustom);

Description

TDrawMode defines how the bitmap is combined with the background. This is the type for DrawMode property of TBitmap32 class, and it is also passed as parameter in BlockTransfer and StretchTransfer functions.

  • dmOpaque – a color information from the foreground image completely replaces the background data;
  • dmBlend – foreground and background colors are blended together using per-pixel opacity of the foreground bitmap (stored in its alpha channel), multiplied by its MasterAlpha;
  • dmCustom – colors are mixed using OnPixelCombine event, that is essentially a call-back function allowing for any custom blending routine.

See Also

BlockTransfer, TBitmap32.DrawMode, TBitmap32.MasterAlpha, TBitmap32.OnPixelCombine, StretchTransfer, TBitmap32


TFixed

type TFixed = type Integer;

type PFixed = ^TFixed;

Description

In order to accelerate some calculations, Graphics32 extensively uses fixed point arithmetics, which is mostly based on TFixed type:

TFixed is a 32-bit fixed point value in 16.16 format, that is 16 bits represent signed integer part and 16 bits represent unsigned fractional part. This format is bitwise-compatible with TFixed type from the Windows.pas unit, except it does not use a record to store the value, which allows for faster function parameter passing and faster value copying and assignment.

Conversion from floating to fixed point is very simple:

Fixed := Round(Single * 65536);

See Also

Fixed Point Math


TPixelCombineEvent

type TPixelCombineEvent = procedure(F: TColor32; var B: TColor32; M: TColor32) of object;

Desctiption

TPixelCombineEvent is a type for OnPixelCombine callback function. It specifies a function which takes foreground color (F) and blends it with the background (B). This function may optionally use master alpha value (M). Moreover, in dmCustom mode master alpha value does not necesserely have to be in [0…255] range anymore, you are free to use all its 32-bits.

See Also

TBitmap32.DrawMode, TBitmap32.OnPixelCombine, TColor32


TRectRounding

type TRectRounding = (rrClosest, rrOutside, rrInside);

Desctiption

TRectRounding type is involved in conversion from TFloatRect/TFixedRect to TRect. It specifies how the coordinates are rounded:

  • rrClosest – a simple Round() function is used for each coordinate;
  • rrOutside – Floor() is used for Left and Top; Ceil() – for Right and Bottom;
  • rrInside – Ceil() is used for Left and Top; Floor() – for Right and Bottom;

See Also

Creating Rectangles, TFixedRect, TFloatRect, TRect


TSize

type TSize = record
Cx, Cy: Integer;
end;

Description

A generic type which holds dimensions of a rectangle, if not stated otherwise, dimensions are specified in pixels.


TStretchFilter

type TStretchFilter = (sfNearest, sfDraft, sfLinear, sfCosine, sfSpline, sfLanczos, sfMitchell);

Description

When the bitmap is scaled, these filters control how the colors are interpolated:

  • sfNearest is the fastest filter, although the quality of the stretched image is fair.
  • sfDraft is a complex resampler, meaning that it uses several different methods. For downsampling it uses row-column zoneshifting to preserve more details than sfNearest, however the quality is not as good as sfLinear. For upsampling it uses a linear interpolation method that may compromise details - this happens if both downsampling and upsampling is needed. sfDraft is ideal for preview fields and thumbnails. Please note, that the algorithm is not pixel-perfect, that why using a custom cliprect might result in a so called jitter-effect.
  • sfLinear is several times slower, but it produces more decent results in most cases.
  • sfCosine is almost equally fast as sfLinear, but it uses cosine interpolation, which produces a sharper image.
  • sfSpline is an approximation of spline interpolation, for some applications its result may be too smooth and blurry, but when using with large magnification factors, it usually yields better image compared to sfLinear.
  • sfLanczos generally produces the sharpest image (especially when downsampling), however sometimes can produce excessive "ringing" effect - this is the slowest filter.
  • sfMitchell is often considered as one of the best filters for enlarging images; generally not as sharp as Lanczos.

In some functions filters above sfLinear may not be applicable (for example in Transform), in this case the filter value will be substituted with sfLinear.

See Also

TBitmap32.StretchFilter, StretchTransfer


Color Constants

Color constants specify some predefined values of TColor32 type.

Their names are similar to standard ones, they just have a '32' postfix:

Constant | Value
clBlack32 | $FF000000
clDimGray32 | $FF3F3F3F
clGray32 | $FF7F7F7F
clLightGray32 | $FFBFBFBF
clWhite32 | $FFFFFFFF
clMaroon32 | $FF7F0000
clGreen32 | $FF007F00
clOlive32 | $FF7F7F00
clNavy32 | $FF00007F
clPurple32 | $FF7F007F
clTeal32 | $FF007F7F
clRed32 | $FFFF0000
clLime32 | $FF00FF00
clYellow32 | $FFFFFF00
clBlue32 | $FF0000FF
clFuchsia32 | $FFFF00FF
clAqua32 | $FF00FFFF

In addition, Graphics32 defines a few colors with 50% transparency:

Constant | Value
clTrWhite32 | $7FFFFFFF
clTrBlack32 | $7F000000
clTrRed32 | $7FFF0000
clTrGreen32 | $7F00FF00
clTrBlue32 | $7F0000FF

See Also

TColor32


G32Version

The Graphics32Version constant is a string that holds version number of the library.

The version number is a simple string which may optionally include sub-version literal, e.g. '0.98a', '0.99', '1.0' etc.


GR32_Blend

GR32_Blend.pas includes low-level functions, mostly blending of pixels. The library automatically determines whether the CPU supports MMX instructions, and uses MMX optimized routines when it is possible.

Contents

Routines | Variables
Blend | MMX_ACTIVE
BlendEx |
ColorAdd |
ColorDiv |
ColorMax |
ColorMin |
ColorModulate |
ColorSub |
Combine |
EMMS |
Lighten |
Merge |
MergeEx |


Blend

function BlendReg(F, B: TColor32): TColor32;

procedure BlendMem(F: TColor32; var B: TColor32);

Description

Mixes a foregrownd (F) color with the background color (B) using the alpha component of the foreground color.

SRGB = FA * FRGB + (1 – FA) * BRGB;

BlendReg takes parameters and produces the result operating on CPU registers.

BlendMem operates with the background color referenced by a memory address.

Using BlendMem is more efficient when blending/combining data to a bitmap, since it excludes writing operation for transparent pixels and reading operation for opaque ones.

Note, that after using the Blend function, you have to call EMMS. Otherwise CPU will be unable to handle floating point instructions.

See Also

BlendEx, Combine, EMMS, Merge, MergeEx, TColor32


BlendEx

function BlendRegEx(F, B, M: TColor32): TColor32;

procedure BlendMemEx(F: TColor32; var B: TColor32; M: TColor32);

Description

Mixes a foreground color with the background color using alpha of the foreground color scaled by the master alpha value M.

SRGB = (M * FA) * FRGB + (1 – (M * FA)) * BRGB;

M is defined as TColor32 to avoid unnecessary type conversions, it must store only values in [0..255] range, the function does not perform range checking and the result in case M > 255 is not specified.

BlendRegEx takes parameters and produces the result operating on CPU registers.

BlendMemEx operates with the background color referenced by a memory address.

Using BlendMemEx is more efficient when blending/combining data to a bitmap since it excludes writing operation for transparent pixels and reading operation for opaque ones.

Note, that after using BlendEx functions, you have to call EMMS. Otherwise CPU will be unable to handle floating point instructions.

See Also

Blend, Combine, EMMS, Merge, MergeEx, TColor32


ColorAdd

function ColorAdd(C1, C2: TColor32): TColor32;

Description

Returns the sum of two colors. Each color component: red, green, blue and alpha is added separately and summation results are clamped to fit into [0…255] range.

See Also

ColorSub, TColor32


ColorDiv

function ColorDiv(C1, C2: TColor32): TColor32;

Description

The resulting color components are the result of the division of corresponding components from C2 and C1.

See Also

TColor32


ColorMax

function ColorMax(C1, C2: TColor32): TColor32;

Description

Resultin color components are maximums of corresponding components in C1 and C2.

See Also

ColorMin, TColor32


ColorMin

function ColorMin(C1, C2: TColor32): TColor32;

Description

Resultin color components are minimums of corresponding components in C1 and C2.

See Also

ColorMax, TColor32


ColorModulate

function ColorModulate(C1, C2: TColor32): TColor32;

Description

The resulting color components are calculated as products of corresponding components in C1 and C2 divided by $FF:

See Also

TColor32


ColorSub

function ColorSub(C1, C2: TColor32): TColor32;

Description

Subtracts C2 from C1. The resulting color components are clamped to [0…255] range. The alpha channel is subtracted as well.

See Also

ColorAdd, TColor32


Combine

function CombineReg(X, Y, W: TColor32): TColor32;

procedure CombineMem(F: TColor32; var B: TColor32; W: TColor32);

Description

Returns the color with components calculated as linear interpolation between X and Y colors. The W parameter, which sholuld be in [0..255] range, specifies the weight of the first color (X). The alpha channel is interpolated as well.

SRGBA = W * XRGBA + (1 – W) * YRGBA;

CombineReg takes parameters and produces the result operating on CPU registers.

CombineMem operates with the background color referenced by a memory address.

Using CombineMem is more efficient when blending/combining data to a bitmap since it excludes writing operation for transparent pixels and reading operation for opaque ones.

Note, that after using Combine functions, you have to call EMMS. Otherwise CPU will be unable to handle floating point instructions.

See Also

Blend, BlendEx, EMMS, TColor32


EMMS

procedure EMMS;

Description

Calls to blending functions must be followed by EMMS procedure. This restores the state of FPU flags, altered by MMX instructions. When CPU does not support MMX, the EMMS function does nothing.

This function must be called after Blend, BlendEx or Combine calls, otherwise CPU will not be able to execute floating point instructions.

If you are using color algebra (such as ColorAdd, ColorMax etc.) that use MMX internally you also have to make sure that EMMS is called.

A typical example of using blending functions:

try
for i := X1 to X2 do
begin
BlendMem(Clr32, P^); // This function uses MMX
Inc(P);
end;
finally
EMMS; // EMMS is called only once, since there is no FPU code inside the loop
end;

See Also

Blend, BlendEx, ColorAdd, ColorMax, Combine


Lighten

function Lighten(C: TColor32; Amount: Integer): TColor32;

Description

The resulting color is formed from the color components of the parameter C by adding Amount to each of them and clipping the sum to [0…255] range.

Amount may be negative.

See Also

TColor32


Merge

function MergeReg(F, B: TColor32): TColor32;

procedure MergeMem(F: TColor32; var B: TColor32);

Description

Merges a foregrownd (F) color with the background color (B) using the alpha component of the foreground color. It does merge the alpha-channels.

SA = 1 - (1 - FA) (1 - BA)

SRGB = (FA * FRGB + BA * (1 - FA) * BRGB) / SA

MergeReg takes parameters and produces the result operating on CPU registers.

MergeMem operates with the background color referenced by a memory address.

Note, that after using the Merge function, you have to call EMMS. Otherwise CPU will be unable to handle floating point instructions.

See Also

Blend, BlendEx, Combine, EMMS, MergeEx, TColor32


MergeEx

function MergeRegEx(F, B, M: TColor32): TColor32;

procedure MergeMemEx(F: TColor32; var B: TColor32; M: TColor32);

Description

Merges the foreground color with the background color using alpha of the foreground color scaled by the master alpha value M. Alpha-Channels are also merged.

SA = 1 - (1 - (M * FA)) (1 - BA)

SRGB = ((M * FA) * FRGB + BA * (1 - FA) * BRGB) / SA

M is defined as TColor32 to avoid unnecessary type conversions, it must store only values in [0..255] range, the function does not perform range checking and the result in case M > 255 is not specified.

MergeRegEx takes parameters and produces the result operating on CPU registers.

MergeMemEx operates with the background color referenced by a memory address.

Note, that after using MergeEx functions, you have to call EMMS. Otherwise CPU will be unable to handle floating point instructions.

See Also

Blend, BlendEx, Combine, EMMS, Merge, TColor32


MMX_ACTIVE

var MMX_ACTIVE: Boolean;

Description

This variable indicates if the CPU supports MMX instructions. MMX_ACTIVE is initialized automatically upon the library initialization.


GR32_ByteMaps

The GR32_ByteMaps.pas unit contains the TByteMap class.

Contents

Classes | Types
TByteMap | TConversionType

See Also

TByteMap


TByteMap

Hierarchy

TPersistent

|

TThreadPersistent

|

TCustomMap

Description

The TByteMap class may be used to simulate palette-based operations or to access separate color layers in TBitmap32.

TByteMap is an ancestor of TCustomMap and is assignment compatible with TBitmap32 objects in both directions.

Reference

Properties | Methods | Events
In TByteMap:
Bytes | Assign |
ValPtr | Clear |
Value | Destroy |
 | Empty |
 | ReadFrom |
 | SetSize |
 | WriteTo |
In TCustomMap:
Height | Delete | OnResize
Width | Resized |
In TThreadPersistent:
LockCount | BeginUpdate | OnChange
UpdateCount | Changed |
 | Create |
 | EndUpdate |
 | Lock |
 | Unlock |

See Also

ByteMaps Example, TBitmap32, TCustomMap


Bytes

TByteMap.Bytes

property Bytes: TArrayOfByte;

type TArrayOfByte = array of Byte;

Description

Returns the pointer to the internal array of bytes. Data is stored in row-major order, top-left "pixel" comes first.

See Also

TArrayOfByte


ValPtr

TByteMap.ValPtr

property ValPtr[X, Y: Integer]: PByte;

Description

Returns a pointer to the specific byte in the array.


Value

TByteMap.Value

property Value[X, Y: Integer]: Byte; default;

Description

Provides coordinate-based access to stored bytes. This function does not perform any range checking of its arguments. Be sure, that the byte map is not empty and that both X and Y are in a valid range.


Assign

TByteMap.Assign

procedure Assign(Source: TPersistent); override;

Description

Copies data from another object, specified by the Source parameter.

This method supports following classes:

  • nil – assigns an empty data array;
  • TByteMap – copies data bytes from another byte map;
  • TBitmap32 – transforms bitmap data using the ReadFrom method with ctWeightedRGB conversion type.

TByteMap also overrides the protected AssignTo method, making it possible to assign bitmaps from byte maps, so that both following lines are correct:

ByteMap.Assign(Bitmap32); // an analog to BM := Intensity(B32);

Bitmap32.Assign(ByteMap); // an analog to B32 := Gray32(BM);

See Also

ReadFrom, TByteMap


Clear

TByteMap.Clear

procedure Clear(FillValue: Byte);

Description

Fills the entire byte map with the specified value.


Destroy

TByteMap.Destroy

destructor Destroy; override;

Description

Destroys the bytemap object and frees all the associated memory.

Do not call Destroy directly, use the Free method instead.


Empty

TByteMap.Empty

function Empty: Boolean; override;

Description

Returns True if the byte map contains no data, that is Width or Height is equal to 0.

See Also

TCustomMap.Height, TCustomMap.Width


ReadFrom

TByteMap.ReadFrom

procedure ReadFrom(Source: TBitmap32; Conversion: TConversionType);

Description

ReadFrom allows reading and converting data from TBitmap32 objects into the byte map.

First, the byte map is resized to fit the Source bitmap dimensions, then the 32-bit RGBA color is transformed to 8-bits depending on the conversion type:

Conversion | Action
ctRed | Copies red channel
ctGreen | Copies green channel
ctBlue | Copies blue channel
ctAlpha | Copies alpha channel
ctUniformRGB | Copies averaged value: (R + G + B) / 3
ctWeightedRGB | Copies intensity: R * 0.21 + G * 0.71 + B * 0.08

See Also

TBitmap32, TConversionType


SetSize

TByteMap.SetSize

function SetSize(NewWidth, NewHeight: Integer): Boolean; override;

procedure SetSize(Source: TPersistent); // implemented in TCustomMap

Description

Call SetSize to set new dimensions of the bytemap. If one of the arguments is zero, the bytemap is considered empty and its Bytes property is set to nil.

Calling SetSize works faster than changing both Width and Height properties.

If you use another bitmap, byte map or control as an argument, the byte map will be sized to corresponding dimensions.

See Also

Bytes, TCustomMap.Height, TCustomMap, TCustomMap.Width


WriteTo

TByteMap.WriteTo

procedure WriteTo(Dest: TBitmap32; Conversion: TConversionType); overload;
procedure WriteTo(Dest: TBitmap32; const Palette: TPalette32); overload;

Description

WriteTo fills the Dest bitmap using the values stored in the byte map.

If it is necessary, the destination bitmap is resized to fit the byte map dimensions.

The following table shows how 8-bit data is transformed into 32-bit RGBA color depending on Conversion parameter.

Conversion | Action
ctRed | Copies bytes into red channel
ctGreen | Copies bytes into green channel
ctBlue | Copies bytes into blue channel
ctAlpha | Copies bytes into alpha channel
ctUniformRGB | Copies the same byte value into red, green and blue channels.
ctWeightedRGB

WriteTo method does not distinguish between ctUniformRGB and ctWeightedRGB conversion types.

Note, that this method alters only the specified color channels, other channels remain intact.

The second overloaded version with Palette parameter uses TPalette32 array to map byte values into RGBA colors.

See Also

TBitmap32, TConversionType, TPalette32


TConversionType

type TConversionType = (
ctRed,
ctGreen,
ctBlue,
ctAlpha,
ctUniformRGB,
ctWeightedRGB);

Description

Specifies how data is converted from 32-bit ARGB bitmap to 8-bit bytemap and back.

See Also

TByteMap.ReadFrom, TByteMap.WriteTo


GR32_Filters

GR32_Filters.pas provides some basic functions for operating over bitmap data.

Contents

Routines | Types
AlphaToGrayscale | TLUT8
ApplyLUT |
ChromaKey |
ColorToGrayScale |
IntensityToAlpha |
Invert |
InvertRGB |


AlphaToGrayscale

procedure AlphaToGrayscale(Dst, Src: TBitmap32);

Description

This function transforms an alpha channel from Src bitmap into grayscale (R=A, G=A, B=A) color in Dst bitmap. If necessary, Dst bitmap is resized to fit Src dimesions.

It writes only RGB components into Dst. The alpha channel (A) remains intact, provided that dimensions of Dst and Src match before AlphaToGrayScale call.

This function is useful when it is necessary to visualize the alpha channel, or when you want to store it as standard bitmap into a file.

See Also

IntensityToAlpha, TBitmap32


ApplyLUT

procedure ApplyLUT(Dst, Src: TBitmap32; const LUT: TLUT8; PreserveAlpha: Boolean = False);

Description

Converts color from Src to Dst using a look-up table (LUT parameter) to map the color components. The alpha channel of the result is set to $FF by default. However, you can override this behaviour by setting PreserveAlpha to True.

RDST = LUT[RSRC];

GDST = LUT[GSRC];

BDST = LUT[BSRC];

If PreserveAlpha then ADST = ASRC else ADST = $FF;

This function supports in-place operation, that is Dst may be the same as Src.

See Also

TBitmap32, TLUT8


ChromaKey

procedure ChromaKey(ABitmap: TBitmap32; TrColor: TColor32);

Description

Preprocesses a Bitmap for standard color key transparency, ie. areas that are of color TrColor are made transparent.

It is possible to use this function several times for different colors.

See Also

Color Types, TBitmap32


ColorToGrayScale

procedure ColorToGrayscale(Dst, Src: TBitmap32; PreserveAlpha: Boolean = False);

Description

Calculates color intensity from Src and writes it as a grayscale image into Dst. The alpha channel in Dst will be set to $FF by default. However, you can override this behaviour by setting PreserveAlpha to True.

This function supports in-place operation, that is Dst may be the same as Src.

See Also

AlphaToGrayscale, TBitmap32


IntensityToAlpha

procedure IntensityToAlpha(Dst, Src: TBitmap32);

Description

This function transforms the color intensity, stored in RGB channels of Src bitmap into the alpha channel in Dst. If necessary, the Dst bitmap is resized to fit Src dimesions.

The intensity is calculated using the Intensity function.

The function writes only the alpha component into Dst. Other channels remain intact (provided dimensions of Dst and Src match before IntensityToAlpha call).

IntensityToAlpha is useful when it is necessary to load an alpha channel stored in as an image.

The in-place operation is fully supported, that is Dst may be the same as Src.

See Also

AlphaToGrayscale, Intensity, TBitmap32


Invert

procedure Invert(Dst, Src: TBitmap32);

Description

Inverts all color channels, including the alpha channel.

This function supports in-place operation, that is Dst may be the same as Src.

See Also

InvertRGB, TBitmap32


InvertRGB

procedure InvertRGB(Dst, Src: TBitmap32);

Description

Inverts RGB color channels, and copies the alpha channel without inversion. If necessary, the Dst bitmap is resized to fit Src dimensions.

This function supports in-place operation, that is Dst may be the same as Src.

See Also

Invert, TBitmap32


TLUT8

type TLUT8 = array [Byte] of Byte;

Description

A look-up table of 256 values, each ranging from 0 to 255.

TLUT8 is used to transform color data with ApplyLUT procedure.

See Also

ApplyLUT


GR32_Image

GR32_Image.pas contains visual components for image storing and visualization.

Contents

Classes | Types | Constants
TBitmap32Collection | TPaintBoxOptions | Paint Stage Constants
TBitmap32Item | TPaintStage |
TBitmap32List | TSizeGripStyle |
TCustomImage32 |  |
TCustomImgView32 |  |
TCustomPaintBox32 |  |
TImage32 |  |
TImgView32 |  |
TIVScrollProperties |  |
TPaintBox32 |  |
TPaintStages |  |


TBitmap32Collection

Hierarchy

TCollection

Description

TBitmap32Collection is a collection of TBitmap32Item objects.

Reference

Properties | Methods
In TBitmap32Collection:
Items | Add
 | Create

See Also

TBitmap32Item


Items

TBitmap32Collection.Items

property Items[Index: Integer]: TBitmap32Item;

Description

Provides indexed access to stored bitmap items.

Bitmap items are instances of TBitmap32Item object. Each bitmap item, in turn, contains a TBitmap32 object, accessible through its Bitmap property.

The number of items may be obtained by reading inherited Count property.

See Also

TBitmap32Item.Bitmap, TBitmap32, TBitmap32Item


Add

TBitmap32Collection.Add

function Add: TBitmap32Item;

Description

Creates a new instance of the bitmap item with the empty bitmap, adds it to the collection and returns reference to the new bitmap item.

Alternatively, you may use TBitmap32Item.Create method to add new items to the collection.

See Also

TBitmap32Item.Create, TBitmap32Item


Create

TBitmap32Collection.Create

constructor Create(AOwner: TPersistent; ItemClass: TBitmap32ItemClass);

type TBitmap32ItemClass = class of TBitmap32Item;

Description

Creates an instance of TBitmap32Collection.

ItemClass specifies must specify TBitmap32Item or its descendant. When calling collection's Add method it will create instances of the class specified in ItemClass parameter.

See Also

Add, TBitmap32Collection, TBitmap32Item


TBitmap32Item

Hierarchy

TCollectionItem

Description

TBitmap32Item is a simple descendant of standard TCollectionItem, specialized for storing bitmaps.

Reference

Properties | Methods
In TBitmap32Item:
Bitmap | Create
 | Destroy


Bitmap

TBitmap32Item.Bitmap

property Bitmap: TBitmap32;

Description

Provides access to the contained bitmap.

See Also

TBitmap32


Create

TBitmap32Item.Create

constructor Create(Collection: TCollection); override;

Description

Creates an instance of TBitmap32Item.

When creating bitmap items at run time, pass the corresponding TBitmap32Collection object as the parameter.

Alternatively, you may use TBitmap32Collection.Add method to create new bitmap items:

var
BitmapCollection: TBitmap32Collection;
B1, B2: TBitmap32Item;
begin
BitmapCollection := TBitmap32Collection.Create;
try
B1 := TBitmap32Item.Create(BitmapCollection);
B2 := BitmapCollection.Add;
// some operations with B1, B2...
finally
BitmapCollection.Free;
end;
end;

Note, that it is not necessary to call the Free method for bitmap items, since they are owned by the collection.

See Also

TBitmap32Collection.Add, TBitmap32Collection, TBitmap32Item


Destroy

TBitmap32Item.Destroy

destructor Destroy; override;

Description

Removes a bitmap item from the collection, destroys it and frees allocated memory.

Do not call Destroy in your application, use standard Free method instead.

Since bitmap items are owned by the collection, they all are destroyed automaticaly when the collection is destroyed. There is no need to call Free method for bitmap items unless you want them to be explicitly destroyed before the collection is destroyed.

See Also

TBitmap32Collection.Items


TBitmap32List

Hierarchy

TComponent

Description

A VCL wrapper around TBitmap32Collection object.

TBitmap32List provides simple means for storing bitmaps in design time.

The TBitmap32List object is quite different from the standard TImageList.

While TImageList, in fact, stores all images on a single bitmap, and all of its images have the same dimensions, TBitmap32List stores its items as independent bitmaps, which means, it can contain bitmaps of different sizes.

Reference

Properties | Methods
In TBitmap32List:
Bitmap | Create
Bitmaps | Destroy

See Also

TBitmap32Collection


Bitmap

TBitmap32List.Bitmap

property Bitmap[Index: Integer]: TBitmap32; default;

Description

Provides an indexed access to stored bitmaps.

Using Bitmap[Index] is the same as using Bitmaps[Index].Bitmap.

See Also

Bitmaps, TBitmap32


Bitmaps

TBitmap32List.Bitmaps

property Bitmaps: TBitmap32Collection;

Description

Provides indexed access to contained TBitmap32Collection object. The total number of items may be obtained through collection's Count property.

See Also

TBitmap32Collection


Create

TBitmap32List.Create

constructor Create(AOwner: TComponent); override;

Description

Creates an instance of TBitmap32List.

See Also

TBitmap32List


Destroy

TBitmap32List.Destroy

destructor Destroy; override;

Description

Destroys the contained bitmap collection, including all the bitmaps in it, then calls the inherited destructor.

Do not call Destroy in your application, use standard Free method instead.


TCustomImage32

Hierarchy

TCustomControl

|

TCustomPaintBox32

Description

A visual control capable of displaying bitmap images.

TCustomImage32 is a base class for TImage32. In addition to TCustomPaintBox32 behavior, it contains an easy-manageable bitmap and a collection of layers.

It introduces several properties to determine how the bitmap image is displayed within the boundaries of the control.

For more information on how to use TCustomImage32 and its descendants, see Using TImage32.

Reference

Properties | Methods | Events
In TCustomImage32:
Bitmap | BeginUpdate | OnBitmapResize
BitmapAlign | BitmapToControl | OnChange
Layers | Changed | OnGDIOverlay
OffsetHorz | ControlToBitmap | OnInitStages
OffsetVert | Create | OnMouseDown
PaintStages | Destroy | OnMouseMove
Scale | EndUpdate | OnMouseUp
ScaleMode | ExecBitmapFrame | OnPaintStage
 | ExecClearBackgnd | OnPixelCombine
 | ExecClearBuffer |
 | ExecControlFrame |
 | ExecCustom |
 | ExecDrawBitmap |
 | ExecDrawLayers |
 | GetPictureRect |
 | GetPictureSize |
 | Resize |
 | SetupBitmap |
In TCustomPaintBox32:
Buffer | DoPaintBuffer | OnMouseEnter
BufferOversize | Flush | OnMouseLeave
BufferValid | GetViewportRect |
Options | Invalidate |
 | Loaded |
 | SetBounds |

See Also

Image32 Example, ImgView and Layers Example, Sprites Example, TCustomPaintBox32, TImage32, Using TImage32


Bitmap

TCustomImage32.Bitmap

property Bitmap: TBitmap32;

Description

Provides access to the bitmap image.

See Also

Bitmap Image, TBitmap32


BitmapAlign

TCustomImage32.BitmapAlign

property BitmapAlign: TBitmapAlign;

type TBitmapAlign = (baTopLeft, baCenter, baTile, baCustom);

Description

Specifies how the bitmap image is located withing the control's boundaries.

Note, that in TCustomImgView32 this property should always remain baCustom.

See Also

Bitmap Image, TCustomImgView32


Layers

TCustomImage32.Layers

property Layers: TLayerCollection;

Description

Provides access to the layer collection.

See Also

TLayerCollection, Using Layers


OffsetHorz

TCustomImage32.OffsetHorz

property OffsetHorz: Single;

Description

Specifies the horizontal offset of the bitmap image in baCustom BitmapAlign mode

See Also

Bitmap Image, BitmapAlign


OffsetVert

TCustomImage32.OffsetVert

property OffsetVert: Single;

Description

Specifies the vertical offset of the bitmap image in baCustom BitmapAlign mode

See Also

Bitmap Image, BitmapAlign


PaintStages

TCustomImage32.PaintStages

property PaintStages: TPaintStages;

Description

Provides access to paint stages of the control, allowing to customize the order in which it repaints itself.

See Also

Paint Stages, TPaintStages


Scale

TCustomImage32.Scale

property Scale: Single;

Description

Specifies the scale of the bitmap image when ScaleMode is smScale.

Warning: do not set too small scales in baTile BitmapAlign mode.

See Also

Bitmap Image, BitmapAlign, ScaleMode


ScaleMode

TCustomImage32.ScaleMode

property ScaleMode: TScaleMode;

type TScaleMode = (smNormal, smStretch, smScale, smResize);

Description

Specifies the current scale mode for the bitmap image.

Note, that TCustomImgView32 descendant supports only smScale mode.

See Also

Bitmap Image, TCustomImgView32


BeginUpdate

TCustomImage32.BeginUpdate

procedure BeginUpdate; virtual;

Description

Disables change notifications until the paired EndUpdate method is called.

BeginUpdate...EndUpdate blocks may be nested.

See Also

EndUpdate, OnChange


BitmapToControl

TCustomImage32.BitmapToControl

function BitmapToControl(const APoint: TPoint): TPoint;

Description

Transforms point coordinates from the reference frame of bitmap image to control's reference frame.

See Also

Bitmap Image, ControlToBitmap, TPoint


Changed

TCustomImage32.Changed

procedure Changed; virtual;

Description

In case the update notification is not masked with BeginUpdate, Changed invalidates the control and then calls the OnChange event.

See Also

BeginUpdate, EndUpdate, TCustomPaintBox32.Invalidate, OnChange


ControlToBitmap

TCustomImage32.ControlToBitmap

function ControlToBitmap(const APoint: TPoint): TPoint;

Description

Transforms point coordinates from control's reference frame to the reference frame of bitmap image.

See Also

Bitmap Image, BitmapToControl, TPoint


Create

TCustomImage32.Create

constructor Create(AOwner: TComponent); override;

Description

Creates an instance of TCustomImage32.

After calling the inherited constructor, Create initializes the following properties:

  • BitmapAlign to baTopLeft;
  • OffsetHorz to 0;
  • OffsetVert to 0;
  • Scale to 1.0;
  • ScaleMode to smNormal;

See Also

BitmapAlign, OffsetHorz, OffsetVert, Scale, ScaleMode, TCustomPaintBox32


Destroy

TCustomImage32.Destroy

destructor Destroy; override;

Description

Destroys an instance of TCustomImage32, freeing the memory allocated to bitmap image and layers.

Do not call the Destroy directly in your application. Call the standard Free method instead.

See Also

TCustomImage32


EndUpdate

TCustomImage32.EndUpdate

property EndUpdate: TNotifyEvent;

Description

Re-enables generation of the OnChange event, masked with BeginUpdate method.

BeginUpdate...EndUpdate pairs may be safely nested.

See Also

BeginUpdate, OnChange


ExecBitmapFrame

TCustomImage32.ExecBitmapFrame

procedure ExecBitmapFrame(Dest: TBitmap32; Stage: Integer); virtual;

Description

Draw a dotted frame around the scaled bitmap image in design time.

This method is called by the control when it executes PST_BITMAP_FRAME paint stage.

See Also

Paint Stages, TBitmap32


ExecClearBackgnd

TCustomImage32.ExecClearBackgnd

procedure ExecClearBuffer(Dest: TBitmap32; Stage: Integer); virtual;

Description

Clears the visible area of the buffer with the color specified in the Color property of the control.

This method is called by the control when it executes PST_CLEAR_BACKGND paint stage.

See Also

Paint Stages, TBitmap32


ExecClearBuffer

TCustomImage32.ExecClearBuffer

procedure ExecClearBuffer(Dest: TBitmap32; Stage: Integer); virtual;

Description

Clears the whole buffer with the color specified in the Color property of the control.

This method is called by the control when it executes PST_CLEAR_BUFFER paint stage. Note, however, that by default, TCustomImage32 does not execute PST_CLEAR_BUFFER stage, instead of it it uses PST_CLEAR_BACKGND, which works faster in some cases.

See Also

Paint Stages, TBitmap32, TCustomImage32


ExecControlFrame

TCustomImage32.ExecControlFrame

procedure ExecControlFrame(Dest: TBitmap32; Stage: Integer); virtual;

Description

Draw a dotted frame around control boundaries in design-ime.

This method is called by the control when it executes PST_CONTROL_FRAME paint stage.

See Also

Paint Stages, TBitmap32


ExecCustom

TCustomImage32.ExecCustom

procedure ExecCustom(Dest: TBitmap32; Stage: Integer); virtual;

Description

Calls the OnPaintStage event.

This method is called by the control when it executes PST_CUSTOM stage.

See Also

OnPaintStage, Paint Stages, TBitmap32


ExecDrawBitmap

TCustomImage32.ExecDrawBitmap

procedure ExecDrawBitmap(Dest: TBitmap32; Stage: Integer); virtual;

Description

Paints the bitmap image.

This method is called by the control when it executes PST_DRAW_BITMAP stage.

See Also

Paint Stages, TBitmap32


ExecDrawLayers

TCustomImage32.ExecDrawLayers

procedure ExecDrawLayers(Dest: TBitmap32; Stage: Integer); virtual;

Description

Paints layers using the layer mask of the corresponding stage.

This method is called by the control when it executes PST_DRAW_LAYERS stage.

See Also

Paint Stages, TBitmap32


GetPictureRect

TCustomImage32.GetPictureRect

function GetPictureRect: TRect;

Description

Returns the location of the bitmap image after an appropriate ScaleMode and BitmapAlign is applied. In bmTile ScaleMode it returns the location of a top-left tile.

See Also

Bitmap Image, BitmapAlign, GetPictureSize, ScaleMode, TRect


GetPictureSize

TCustomImage32.GetPictureSize

function GetPictureSize: TSize;

Description

Returns the size of the bitmap image after an appropriate ScaleMode is applied. In bmTile ScaleMode it returns the size of a tile.

See Also

Bitmap Image, GetPictureRect, ScaleMode, TSize


Resize

TCustomImage32.Resize

procedure Resize; override;

Description

Copyright ©2000-2004 Alex Denisov and Contributors - Graphics32 v1.7.1 - Build on 25-Februar-2005


SetupBitmap

TCustomImage32.SetupBitmap

procedure SetupBitmap(
DoClear: Boolean = False;
ClearColor: TColor32 = $FF000000);

Description

Sets the size of the bitmap image to the size of the buffered area. This method does not account for current ScaleMode.

If DoClear = True, the resized image will be filled with a color specified in the ClearColor parameter.

See Also

Bitmap Image, TCustomPaintBox32.GetViewportRect, ScaleMode, TColor32


OnBitmapResize

TCustomImage32.OnBitmapResize

property OnBitmapResize: TNotifyEvent;

Description

This event is generated after the bitmap image is resized, that is its Width or Height property changes. OnBitmapResize is not generated when Scale or ScaleMode is changed.

See Also

TCustomMap.Height, Scale, ScaleMode, TCustomMap.Width


OnChange

TCustomImage32.OnChange

property OnChange: TNotifyEvent;

Description

OnChange is an abstract change notification event, which is called by some of the descendants of TCustomPaintBox32 immediately after changes have been made to their contents.

In TCustomImage32, for example, this includes redirection of change notification events from the contained bitmap and from layers.

This event, however, is not called by TCustomPaintBox32 control itself, unless you call the Changed method explicitly.

Change notification may be disabled with BeginUpdate call and re-enabled with EndUpdate call.

See Also

BeginUpdate, Changed, EndUpdate, TCustomImage32, TCustomPaintBox32


OnGDIOverlay

TCustomImage32.OnGDIOverlay

property OnGDIOverlay: TNotifyEvent;

Description

[ Note: Most likely this event will be removed in future versions. Do not use it ]

This event is called after the image has been combined with layers in the back-buffer and copied to the screen. In the event handler you can provide additional drawing using the standard Canvas of the control.

Drawing at this stage will not affect the contents of the back-buffer.

See Also

OnPaintStage, Paint Stages


OnInitStages

TCustomImage32.OnInitStages

property OnInitStages: TNotifyEvent;

Description

OnInitStages is called by TCustomImage32 in the process of initialization right after it finishes building default list of paint stages. You may also alter the stages in the OnCreate event handler of the owner form or anywhere else in you program.

See Also

Paint Stages, TCustomImage32


OnMouseDown

TCustomImage32.OnMouseDown

property OnMouseDown: TImgMouseEvent;

type TImgMouseEvent = procedure(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer) of object;

Description

This event occurs when user pushes the mouse button in the image area. The Layer parameter indicates the layer under the mouse, or nil in case the mouse is over the background area.

Whether the layer is under the mouse or not, is determined by the HitTest function and by the LOB_MOUSE_EVENTS bit in LayerOptions. The top-most layer which passes the test is passed into the Layer parameter of the event.

Note, that once mouse was pressed, the layer (or the background) captures the mouse messages until the mouse button is released.

See Also

TCustomLayer.HitTest, TCustomLayer.LayerOptions, OnMouseMove, OnMouseUp, TCustomLayer


OnMouseMove

TCustomImage32.OnMouseMove

property OnMouseMove: TImgMouseMoveEvent;

type TImgMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer) of object;

Description

This event is fired while the mouse is dragged over the image. Layer indicates the layer under the mouse, nil – when there is no layer under the mouse, or the layer which has captured mouse events.

See Also

OnMouseDown, OnMouseUp, TCustomLayer


OnMouseUp

TCustomImage32.OnMouseUp

property OnMouseUp: TImgMouseEvent;

type TImgMouseEvent = procedure(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer) of object;

Description

This event occurs when the mouse button is released. Layer indicates the layer under the mouse, nil – when there is no layer under the mouse, or the layer which has captured mouse events.

See Also

Changed, TCustomLayer


OnPaintStage

TCustomImage32.OnPaintStage

property OnPaintStage: TPaintStageEvent;

type TPaintStageEvent = procedure(Sender: TObject; Dest: TBitmap32; StageNum: Cardinal) of object;

Description

An event, called by the control while it repaints itself. By default, TCustomImage32 does not generate OnPaintStage events, but this can be changed by adding PST_CUSTOM paint stages.

In the event handler, do not paint to Buffer directly, use the passed Dest parameter instead.

See Also

TCustomPaintBox32.Buffer, Paint Stages, TBitmap32, TCustomImage32


OnPixelCombine

TCustomImage32.OnPixelCombine

property OnPixelCombine: TPixelCombineEvent;

type TPixelCombineEvent = procedure(F: TColor32; var B: TColor32; M: TColor32) of object;

Description

This event is redirected from the bitmap image, in order to make it accessible in the Delphi's Object Manager. There is no difference between using TCustomImage32.OnPixelCombine and TBitmap32.OnPixelCombine.

See Also

TBitmap32.OnPixelCombine, TColor32, TCustomImage32, TPixelCombineEvent


TCustomImgView32

Hierarchy

TCustomControl

|

TCustomPaintBox32

|

TCustomImage32

Description

TCustomImgView32 is an extention of TCustomImage32, which additionaly provides a couple of scroll bars to simplify operations with images larger then the control area.

Most of its behavior is inherited from TCustomImage32, however some properties are obsolete:

  • BitmapAlign is no longer used, since the control is always in baCustom mode;
  • ScaleMode is no longer used, the control is always in smScale mode;

For more information on how to use TCustomImgView32 and its descendants, see Using TImage32.

Reference

Properties | Methods | Events
In TCustomImgView32:
Centered | Create | OnScroll
OverSize | Destroy |
ScrollBars | GetViewportRect |
SizeGrip | Loaded |
 | Resize |
 | Scroll |
 | ScrollToCenter |
In TCustomImage32:
Bitmap | BeginUpdate | OnBitmapResize
BitmapAlign | BitmapToControl | OnChange
Layers | Changed | OnGDIOverlay
OffsetHorz | ControlToBitmap | OnInitStages
OffsetVert | EndUpdate | OnMouseDown
PaintStages | ExecBitmapFrame | OnMouseMove
Scale | ExecClearBackgnd | OnMouseUp
ScaleMode | ExecClearBuffer | OnPaintStage
 | ExecControlFrame | OnPixelCombine
 | ExecCustom |
 | ExecDrawBitmap |
 | ExecDrawLayers |
 | GetPictureRect |
 | GetPictureSize |
 | SetupBitmap |
In TCustomPaintBox32:
Buffer | DoPaintBuffer | OnMouseEnter
BufferOversize | Flush | OnMouseLeave
BufferValid | Invalidate |
Options | SetBounds |

See Also

TCustomImage32, Using TImage32


Centered

TCustomImgView32.Centered

property Centered: Boolean;

Description

Indicates the alignmet of the container bitmap image. When Centered is True (default) the image is automatically positioned at the center of the control, otherwise it is located at the top-left corner.


OverSize

TCustomImgView32.OverSize

property OverSize: Integer;

Description

This property introduces a frame of OverSize pixels in each direction around the bitmap.
This will keep the bitmap scrollable even if it is scaled to fit the viewport. OverSize is set to 0 by default.


ScrollBars

TCustomImgView32.ScrollBars

property ScrollBars: TIVScrollProperties;

Description

Controls appearance of scroll bars.

The scroll bars in TCustomImgView32 are of the TCustomRangeBar type. Use ScrollBars to control properties of the vertical and horizontal scroll bar simultaneously.

See Also

TCustomImgView32, TCustomRangeBar, TIVScrollProperties


SizeGrip

TCustomImgView32.SizeGrip

property SizeGrip: TSizeGripStyle;

type TSizeGripStyle = (sgAuto, sgNone, sgAlways);

Description

Modify the SizeGrip property to control the appearance of the resizing grip at the lower-right corner of the control:

In shAuto mode, visibuility of the grip is determined similar to tat in other standard controls (e.g. TScrollBox), it becomes visible when control is client-aligned (if it has parents, they should be client-aligned as well).

Use snNone and sgAlways styles to specify its appearance explicitly.

See Also

TSizeGripStyle


Create

TCustomImgView32.Create

constructor Create(AOwner: TComponent); override;

Description

Creates an instance of TCustomImgView32.

After calling the inherited constructor, Create initializes the Centered property to True.

See Also

Centered, TCustomImgView32


Destroy

TCustomImgView32.Destroy

destructor Destroy; override;

Description

Destroys the instance of TCustomImgView32 class and frees all associated memory.

Do not call Destroy directly, use Free method instead.

See Also

TCustomImgView32


GetViewportRect

TCustomImgView32.GetViewportRect

function GetViewportRect: TRect; override;

Description

This property is overriden to return the rectangle, corresponding to the control dimensions minus the area covered by the scroll bars.

See Also

TIVScrollProperties.Size, TRect


Loaded

TCustomImgView32.Loaded

procedure Loaded; override;

Description

Loaded is overriden to adjust positions of scroll bars after the control loads it properties from the DFM file.

Normally, you sould not use it in your application.


Resize

TCustomImgView32.Resize

procedure Resize; override;

Description

Resize is overriden to adjust positions of scroll bars after the control resizes.

Normally, you sould not use it in your application.


Scroll

TCustomImgView32.Scroll

procedure Scroll(Dx. Dy: Integer);

Description

Scrolls the viewport by the offsets given by the Dx and Dy parameters.


ScrollToCenter

TCustomImgView32.ScrollToCenter

procedure ScrollToCenter(X, Y: Integer);

Description

Relatively scrolls the center of the viewport to the X and Y coordinates.


OnScroll

TCustomImgView32.OnScroll

property OnScroll: TNotifyEvent;

Description

This event is generated when user scrolls the image using scroll bars.


TCustomPaintBox32

Hierarchy

TCustomControl

Description

TCustomPaintBox32 is a common ancestor for TPaintBox32 and TCustomImage32 objects.

In addition to properties, inherited from TCustomControl, it provides optimized double buffering. The back buffer is a TBitmap32 object, which stores an image data before flushing it to the screen.

Since TCustomPaintBox32 is double buffered, there is no need to redraw its contents every time the control receives WM_PAINT message, as with standard TPaintBox. The repainting is still required when the control is resized.

Reference

Properties | Methods | Events
In TCustomPaintBox32:
Buffer | Destroy | OnMouseEnter
BufferOversize | DoPaintBuffer | OnMouseLeave
BufferValid | Flush |
Options | GetViewportRect |
 | Invalidate |
 | Loaded |
 | Resize |
 | SetBounds |

See Also

TBitmap32, TCustomImage32, TPaintBox32


Buffer

TCustomPaintBox32.Buffer

property Buffer: TBitmap32; // Read only;

Description

Provides direct access to the back buffer.

Note that the actual size of the buffered may be up to BufferOversize pixels larger then the buffered area.

See Also

BufferOversize, BufferValid, TBitmap32


BufferOversize

TCustomPaintBox32.BufferOversize

property BufferOversize: Integer; // protected

Description

BufferOversize specifies how the back buffer is reallocated when the control is resized.

When BufferOversize equals 0, the back buffer is reallocated each time the control is resized to suite the new control dimensions.

When set to some positive value (40 by default), the back buffer is allowed to be up to BufferOversize pixels larger then the control is in each direction. The buffer resizing algorithm tracks size changes and reallocates the buffer only when its size becomes smaller than size of the buffered area or when the difference between the sizes exceeds the specified amount of pixels.

See Also

Buffer, GetViewportRect


BufferValid

TCustomPaintBox32.BufferValid

property BufferValid: Boolean; // protected

Description

BufferValid specifies if the current content of the Buffer bitmap is up-to-date and whether the buffer needs to be repainted.

When TCustomPaintBox32 repaints itself, it checks whether the buffer is valid. If BufferValid is True, the control simply flushes its contents to the screen, otherwise, it executes DoPaintBuffer method, which updates the buffer and sets BufferValid to True, then it copies content of the buffer to the screen.

Normally, this property should not be accessed in your application, since TCustomPaintBox32 tracks the buffer state and updates it automatically.

See Also

Buffer, DoPaintBuffer, TCustomPaintBox32


Options

TCustomPaintBox32.Options

property Options: TPaintBoxOptions;

type TPaintBoxOptions = set of (pboWantArrowKeys, pboAutoFocus);

Description

This property controls additional options of the paint box and its descendants:

pboWantArrowKeys - indicates whether the keyboard arrow keys appear in OnKeyDown event;

pboAutoFocus - indicates that the paint box automatically captures keyboard focus when clicked with the mouse. The focus is acquired before the OnMouseDown event is fired.

See Also

TPaintBoxOptions


Destroy

TCustomPaintBox32.Destroy

destructor Destroy; override;

Description

Destroys an instance of TCustomPaintBox32 object and frees all associated memory.

Do not call Destroy directly, use Free method instead.

See Also

TCustomPaintBox32


DoPaintBuffer

TCustomPaintBox32.DoPaintBuffer

procedure DoPaintBuffer; virtual;

Description

DoPaintBuffer is an abstract virtual method, called by the controll during its repainting.


Flush

TCustomPaintBox32.Flush

procedure Flush; overload;

procedure Flush(const SrcRect: TRect); overload;

Description

Immediately copies the contents of the buffer, or its part passed in SrcRect to the screen. Use this function when you want to bypass normal Windows invalidating/repainting procedure, for example when the buffer is painted by the other thread.

Both functions are thread-safe.

See Also

TRect


GetViewportRect

TCustomPaintBox32.GetViewportRect

function GetViewportRect: TRect; virtual; // protected

Description

Returns coordinates of the buffered area relative to control's client area. By default, it coincides with the control's client rectangle, that is, the function returns (0, 0, ClientWidth, ClientHeight) rectangle.

Descendants may override this method and return a different rectangle if they have unbuffered areas, like scroll bars.

See Also

TRect


Invalidate

TCustomPaintBox32.Invalidate

procedure Invalidate; override;

Description

Invalidate is overriden from TWinControl. In addition to standard behavior, it also invalidates the buffer content, so that the buffer gets actually updated during the following paint procedure.

You do not have to call this method explicitly in your application.


Loaded

TCustomPaintBox32.Loaded

procedure Loaded; override;

Description

Loaded is overriden from TWinControl to keep the buffer dimensions consistent with control's dimensions. You do not have to call this method explicitly in your application.


Resize

TCustomPaintBox32.Resize

procedure Resize; override;

Description

Resize is overriden from TWinControl. It keeps the size of the buffer consistent with control's dimensions after the control resizes. Normally, you will not call this method in your applications.

Whether the buffer is actually resized or not is influenced by the BufferOversize property.

Resizing of the control will also invalidate its buffer.

Resize generates the standard OnResize event as well.

See Also

BufferOversize


SetBounds

TCustomPaintBox32.SetBounds

procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;

Description

SetBounds is overriden from TWinControl to keep buffer dimensions consistent with the control size.

You do not have to call this method explicitly in your application.


OnMouseEnter

TCustomPaintBox32.OnMouseEnter

property OnMouseEnter: TNotifyEvent;

Description

OnMouseEnter is called by TPaintBox32 when the Mouse cursor has entered the control.

See Also

TCustomPaintBox32


OnMouseLeave

TCustomPaintBox32.OnMouseLeave

property OnMouseLeave: TNotifyEvent;

Description

OnMouseLeave is called by TPaintBox32 when the Mouse cursor has left the control.

See Also

TCustomPaintBox32


TImage32

Hierarchy

TCustomControl

|

TCustomPaintBox32

|

TCustomImage32

Description

An image displaying control.

TImage32 implements the generic behavior introduced in TCustomImage32. It publishes some inherited properties from TCustomImage32, but does not introduce any new behavior.

TImage32 allows loading of its Bitmap property from supported image files in design-time using a property editor, associated with TBitmap32 objects. The same property editor is activated when you double-click the control in design-time.

For more information on TImage32, see Using TImage32.

Reference

Properties | Methods | Events
In TCustomImage32:
Bitmap | BeginUpdate | OnBitmapResize
BitmapAlign | BitmapToControl | OnChange
Layers | Changed | OnGDIOverlay
OffsetHorz | ControlToBitmap | OnInitStages
OffsetVert | Create | OnMouseDown
PaintStages | Destroy | OnMouseMove
Scale | EndUpdate | OnMouseUp
ScaleMode | ExecBitmapFrame | OnPaintStage
 | ExecClearBackgnd | OnPixelCombine
 | ExecClearBuffer |
 | ExecControlFrame |
 | ExecCustom |
 | ExecDrawBitmap |
 | ExecDrawLayers |
 | GetPictureRect |
 | GetPictureSize |
 | Resize |
 | SetupBitmap |
In TCustomPaintBox32:
Buffer | DoPaintBuffer | OnMouseEnter
BufferOversize | Flush | OnMouseLeave
BufferValid | GetViewportRect |
Options | Invalidate |
 | Loaded |
 | SetBounds |

See Also

Image32 Example, ImgView and Layers Example, Sprites Example, TBitmap32, TCustomImage32, Using TImage32


TImgView32

Hierarchy

TCustomControl

|

TCustomPaintBox32

|

TCustomImage32

|

TCustomImgView32

Description

An image displaying control with scroll bars.

TImgView32 implements the generic behavior introduced in TCustomImgView32. It publishes some inherited properties from TCustomImgView32, but does not introduce any new behavior.

Reference

Properties | Methods | Events
In TCustomImgView32:
Centered | Create | OnScroll
OverSize | Destroy |
ScrollBars | GetViewportRect |
SizeGrip | Loaded |
 | Resize |
 | Scroll |
 | ScrollToCenter |
In TCustomImage32:
Bitmap | BeginUpdate | OnBitmapResize
BitmapAlign | BitmapToControl | OnChange
Layers | Changed | OnGDIOverlay
OffsetHorz | ControlToBitmap | OnInitStages
OffsetVert | EndUpdate | OnMouseDown
PaintStages | ExecBitmapFrame | OnMouseMove
Scale | ExecClearBackgnd | OnMouseUp
ScaleMode | ExecClearBuffer | OnPaintStage
 | ExecControlFrame | OnPixelCombine
 | ExecCustom |
 | ExecDrawBitmap |
 | ExecDrawLayers |
 | GetPictureRect |
 | GetPictureSize |
 | SetupBitmap |
In TCustomPaintBox32:
Buffer | DoPaintBuffer | OnMouseEnter
BufferOversize | Flush | OnMouseLeave
BufferValid | Invalidate |
Options | SetBounds |

See Also

TCustomImgView32


TIVScrollProperties

Hierarchy

TPersistent

Description

TIVScrollProperties is an auxiliary class for accessing properties of scroll bars (TCustomRangeBar controls) that are hosted by the TCustomImgView32 control. Basically, it just redirects writing and reading of properties to/from corresponding range bar controls, which allows changing their appearance at both design- and run-time.

Reference

Properties
In TIVScrollProperties:
Backgnd
BorderStyle
ButtonSize
HandleColor
Increment
ShowArrows
ShowHandleGrip
Size
Style

See Also

TCustomImgView32.ScrollBars, TCustomImgView32, TCustomRangeBar


Backgnd

TIVScrollProperties.Backgnd

property Backgnd: TRBBackgnd;

type TRBBackgnd = (bgPattern, bgSolid);

Description

Provides access to the Backgnd property in scroll bars.

See Also

TArrowBar.Backgnd, TRBBackgnd


BorderStyle

TIVScrollProperties.BorderStyle

property BorderStyle: TBorderStyle;
type TBorderStyle = (bsNone, bsSingle); // is declared in Forms.pas

Description

Provides access to the BorderStyle property in scroll bars.

See Also

TArrowBar.BorderStyle


ButtonSize

TIVScrollProperties.ButtonSize

property ButtonSize: Integer;

Description

Provides access to the ButtonSize property in scroll bars.

See Also

TArrowBar.ButtonSize


HandleColor

TIVScrollProperties.HandleColor

property HandleColor: TColor;

Description

Provides access to the HandleColor property in scroll bars.

See Also

TArrowBar.HandleColor


Increment

TIVScrollProperties.Increment

property Increment: Integer;

Description

Provides access to the Increment property in scroll bars.

See Also

TCustomRangeBar.Increment


ShowArrows

TIVScrollProperties.ShowArrows

property ShowArrows: Boolean;

Description

Provides access to the ShowArrows property in scroll bars.

See Also

ShowArrows


ShowHandleGrip

TIVScrollProperties.ShowHandleGrip

property ShowHandleGrip: Boolean;

Description

Provides access to the ShowHandleGrip property in scroll bars.

See Also

TArrowBar.ShowHandleGrip


Size

TIVScrollProperties.Size

property Size: Integer;

Description

Simultaneously controls the Height of horizontal and Width of veritical scroll bars.

If Size is 0 (default), the corresponding size is set to the default one, specified in current desktop settings.


Style

TIVScrollProperties.Style

property Style: TRBStyle;

Description

Provides access to the Style property in scroll bars.

See Also

TArrowBar.Style, TRBStyle


TPaintBox32

Hierarchy

TCustomControl

|

TCustomPaintBox32

Description

TPaintBox32 implements the generic behavior introduced in TCustomPaintBox32. It publishes some inherited properties from its ancestors and, in addition, it calls the OnPaintBuffer event when the buffer needs to be repainted.

Reference

Properties | Methods | Events
In TPaintBox32:
 | Create | OnPaintBuffer
 | DoPaintBuffer |
In TCustomPaintBox32:
Buffer | Destroy | OnMouseEnter
BufferOversize | Flush | OnMouseLeave
BufferValid | GetViewportRect |
Options | Invalidate |
 | Loaded |
 | Resize |
 | SetBounds |

See Also

TCustomPaintBox32


Create

TPaintBox32.Create

constructor Create(AOwner: TComponent);

Description

Creates an instance of TPaintBox32.

See Also

TPaintBox32


DoPaintBuffer

TPaintBox32.DoPaintBuffer

procedure DoPaintBuffer; override; // protected

Description

This method is overriden from TCustomPaintBox32, it calls the OnPaintBuffer event.

See Also

TCustomPaintBox32.DoPaintBuffer, OnPaintBuffer, TCustomPaintBox32


OnPaintBuffer

TPaintBox32.OnPaintBuffer

property OnPaintBuffer: TNotifyEvent;

Description

OnChange is called by TPaintBox32 when it needs to repaint its back buffer itself.

See Also

TCustomPaintBox32.Buffer, DoPaintBuffer, TCustomPaintBox32


TPaintStages

Hierarchy

TObject

Description

A dynamic list of paint stages.

This class is similar to standard TList, but instead of pointers, it holds an array of TPaintStage records.

Reference

Properties | Methods
In TPaintStages:
Items | Add
 | Clear
 | Count
 | Delete
 | Destroy
 | Insert

See Also

Paint Stages, TCustomImage32.PaintStages, TPaintStage


Items

TPaintStages.Items

property Items[Index: Integer]: PPaintStage; default; // Read only;

Description

The Items property can be used to obtain a pointer to the specified stage. The index of the first paint stage is 0.

See Also

TPaintStage


Add

TPaintStages.Add

function Add: PPaintStage;

Description

Adds a new stage to the list and returns pointer to stage record.

By default, new stages have their RunTime member set to True.

See Also

Delete, Insert, TPaintStage


Clear

TPaintStages.Clear

procedure Clear;

Description

Removes all stages from the list.

See Also

Delete


Count

TPaintStages.Count

function Count: Integer;

Description

Returns the number of stored stages.


Delete

TPaintStages.Delete

procedure Delete(Index: Integer);

Description

Removes the stage at the position specified by the Index parameter. The index of subsequent stages automatically decreases.

See Also

Add, Insert


Destroy

TPaintStages.Destroy

destructor Destroy; override;

Description

Destroys an instance of TPaintStages object and frees the memory allocated to stare the list of stages.

Do not call Destroy directly, call the standard Free method instead.

See Also

TPaintStages


Insert

TPaintStages.Insert

function Insert(Index: Integer): PPaintStage;

Description

Insert a new stage into the list at specified position and returns a pointer to it.

Index indicates the position, where the new stage is inserted. The item that occupied that position before insertion, is shifted up together with all subsequent items.

If Index is greater than the number of stages, the new stage will be added at the end of the list. Similarly, if Index is less or equal than zero, all previous elements are shifted up and the new stage is inserted in the beginning of the list.

By default, new stages have their RunTime member set to True.

See Also

Add, Delete, TPaintStage


TPaintBoxOptions

type TPaintBoxOptions = (pboWantArrowKeys, pboAutoFocus);

Description

TPaintBoxOptions is the type for the Options property in TCustomPaintBox32 and its descendants.

See Also

TCustomPaintBox32.Options, TCustomPaintBox32


TPaintStage

type TPaintStage = record
DsgnTime: Boolean;
RunTime: Boolean;
Stage: Cardinal; // a PST_* constant
Parameter: Cardinal; // an optional parameter
end;
type PPaintStage = ^TPaintStage;

Description

Defines a drawing stage in TCustomImage32.

DsgnTime — indicates that the stage must be executed at design-time;

RunTime — indicates that the stage must be executed at run-time;

Stage — is one of the Paint Stage Constants, which specifies the stage action;

Parameter — is an optional parameter used in some paint stages.

See Also

Paint Stage Constants, Paint Stages, TCustomImage32.PaintStages, TCustomImage32


TSizeGripStyle

type TSizeGripStyle = (sgAuto, sgNone, sgAlways);

Description

TSizeGripStyle is a type for the SizeGrip property in TCustomImgView, which determines appearance of a sizing grip at the bottom-right corner.

See Also

GR32_Image, TCustomImgView32.SizeGrip


Paint Stage Constants

Paint stage constants specify the type of operation associated with a paint stage in TCustomImage32 and its descendants.

There is seven types of paint stages, which can be used by TCustomImage32 to paint its contents. Each paint stage has 'PST_' prefix:

Stage Name | Value | Description
PST_CUSTOM | 1 | Calls the OnPaintStage event
PST_CLEAR_BUFFER | 2 | Clears the buffer
PST_CLEAR_BACKGND | 3 | Clears visible buffer area
PST_DRAW_BITMAP | 4 | Draws a scaled bitmap image
PST_DRAW_LAYERS | 5 | Draws layers
PST_CONTROL_FRAME | 6 | Draws a dotted frame around the control
PST_BITMAP_FRAME | 7 | Draws a dotted frame around the scaled bitmap image

See Also

Paint Stages, TCustomImage32


GR32_Layers

The GR32_Layers.pas unit contains layer classes, which can be attached to TCustomImage32 class and its descendants.

Contents

Classes | Types | Constants
TBitmapLayer | TRBHandles | Layer Options Bits
TCustomLayer |  |
TLayerCollection |  |
TPositionedLayer |  |
TRubberbandLayer |  |

See Also

ImgView and Layers Example, TCustomImage32, Using Layers


TBitmapLayer

Hierarchy

TPersistent

|

TCustomLayer

|

TPositionedLayer

Description

In addition to behavior inherited from TPositionedLayer, TBitmapLayer, stores and displays a TBitmap32 object.

The contained Bitmap is displayed and scaled using its DrawMode, MasterAlpha and StretchFilter properties.

Reference

Properties | Methods | Events
In TBitmapLayer:
AlphaHit | Create |
Bitmap | Destroy |
Cropped |  |
In TPositionedLayer:
Location | GetAdjustedLocation |
Scaled |  |
In TCustomLayer:
Cursor | BringToFront | OnHitTest
Index | HitTest | OnMouseDown
LayerCollection | SendToBack | OnMouseMove
LayerOptions |  | OnMouseUp
LayerStates |  | OnPaint
MouseEvents |  |
Tag |  |
Visible |  |

See Also

TBitmap32.DrawMode, TBitmap32.MasterAlpha, Sprites Example, TBitmap32.StretchFilter, TBitmap32, TPositionedLayer


AlphaHit

TBitmapLayer.AlphaHit

property AlphaHit: Boolean;

Description

AlphaHit determines how the layer performs its HitTest.

If AlphaHit=False, layer only passes points inside the rectangle returned by GetAdjustedLocation.

If AlphaHit=True, layer checks the opacity of the pixel lying under the specified point and passes the hit test only when the alpha channel of the pixel is greater when zero.

See Also

TPositionedLayer.GetAdjustedLocation, TCustomLayer.HitTest


Bitmap

TBitmapLayer.Bitmap

property Bitmap: TBitmap32;

Description

Specifies the contained image.

See Also

TBitmap32


Cropped

TBitmapLayer.Cropped

property Cropped: Boolean;

Description

When Cropped is True, layer will paint only the portion of its bitmap, that intersects with the bitmap image of the container:

See Also

Bitmap Image


Create

TBitmapLayer.Create

constructor Create(ALayerCollection: TLayerCollection); override;

Description

Creates an instance of TBitmapLayer.

After calling the inherited constructor, Create initializes the internal bitmap and returns an object with both AlphaHit and Cropped properties set to False.

See Also

AlphaHit, TCustomLayer.Create, Cropped, TBitmapLayer, TLayerCollection


Destroy

TBitmapLayer.Destroy

destructor Destroy; override;

Description

Removes the bitmap layer from the collection and destroys it. The memory allocated for the bitmap is freed as well.

Do not call Destroy in your application directly, use the standard Free method instead.


TCustomLayer

Hierarchy

TPersistent

Description

TCustomLayer is the base class for all layers. It does not perform any drawing itself, however it is capable of calling the OnPaint event, where you can perform cutom drawing.

Reference

Properties | Methods | Events
In TCustomLayer:
Cursor | BringToFront | OnHitTest
Index | Create | OnMouseDown
LayerCollection | Destroy | OnMouseMove
LayerOptions | HitTest | OnMouseUp
LayerStates | SendToBack | OnPaint
MouseEvents |  |
Tag |  |
Visible |  |

See Also

TCustomLayer, Using Layers


Cursor

TCustomLayer.Cursor

property Cursor: TCursor;

Description

Specifies the appearance of the mouse pointer, when it passes over the region covered by the layer. Whether this property used or not is influenced by LOB_MOUSE_EVENTS bit in LayerOptions, as well as by the hit test.

See Also

LayerOptions, Using Layers


Index

TCustomLayer.Index

property Index: Integer;

Description

Indicates the index of the layer in LayerCollection. This property is similar to Z-order of standard controls. Change Index if you want to reorder layers.

See Also

LayerCollection, Using Layers


LayerCollection

TCustomLayer.LayerCollection

property LayerCollection: TLayerCollection;

Description

A reference to collection, which contains the layer.

See Also

TLayerCollection, Using Layers


LayerOptions

TCustomLayer.LayerOptions

property LayerOptions: Cardinal;

Description

A 32-bit unsigned integer value composed of Layer Options Bits, which controls layer bahavior.

Note that lower 24-bits of LayerOptions have no predefined meaning, they are available for customization purposes, like layer categories, etc.

See Also

Layer Options Bits, Using Layers


LayerStates

TCustomLayer.LayerStates

property LayerStates: TLayerStates; // Read only

type TLayerState = (lsMouseLeft, lsMouseRight, lsMouseMiddle);

type TLayerStates = set of TLayerState;

Description

Indicates the current state of the layer. Currently this property contains only information on pressed mouse buttons, but it will be expanded in future versions.

See Also

Using Layers


MouseEvents

TCustomLayer.MouseEvents

property MouseEvents: Boolean;

Description

Using this property is the same as accessing LOB_MOUSE_EVENTS bit in LayerOptions.

See Also

Layer Options Bits, MouseEvents, Using Layers


Tag

TCustomLayer.Tag

property Tag: Integer;

Description

Tag has no predefined meaning, it can be used to store any 32-bit value together with the layer.

See Also

Using Layers


Visible

TCustomLayer.Visible

property Visible: Boolean;

Description

Using this property is the same as accessing LOB_VISIBLE bit in LayerOptions.

See Also

Layer Options Bits, MouseEvents, Using Layers


BringToFront

TCustomLayer.BringToFront

procedure BringToFront;

Description

Brings the layer on top of other layers in the collection. After calling BringToFront, layer's Index becomes the largest among the rest of the layers.

See Also

Index, LayerCollection, Using Layers


Create

TCustomLayer.Create

constructor Create(ALayerCollection: TLayerCollection); virtual;

Description

Creates an instance of TCustomLayer and adds it to the specified layer collection, for example:

var

MyLayer: TCustomLayer;

begin

MyLayer := TCustomLayer.Create(MyImage32.Layers);

...

end;

By default custom layers are created with only LOB_VISIBLE bit in their LayerOptions.

See Also

LayerOptions, TCustomLayer, TLayerCollection, Using Layers


Destroy

TCustomLayer.Destroy

destructor Destroy; override;

Description

Removes the layer from layer collection destroys the layer instance and frees all allocated memory.

Do not call Destroy directly in your applications, use the standard Free method instead.

See Also

LayerCollection, Using Layers


HitTest

TCustomLayer.HitTest

function HitTest(X, Y: Integer): Boolean;

Description

Performs a hit test of the layer at specified point and returns True if the point have passed the test.

After performing default hit test, specific for particular type of a layer, this method also calls OnHitTest event, in case you need some run-time customization.

By default:

  • TCustomLayer always passes the hit test;
  • TPositionedLayer passes only the points lying inside the rectangle, returned by GetAdjustedLocation;
  • Depending on the AlphaHit property, TBitmapLayer is capable of passing only coordinates corresponding to non-transparent pixels.

See Also

TBitmapLayer.AlphaHit, TPositionedLayer.GetAdjustedLocation, OnHitTest, TBitmapLayer, TCustomLayer, TPositionedLayer, Using Layers


SendToBack

TCustomLayer.SendToBack

procedure SendToBack;

Description

Sends the layer behind all other layers in layer collection. SendToBack performs the same action as assigning Index to 0.

See Also

Index, LayerCollection, Using Layers


OnHitTest

TCustomLayer.OnHitTest

property OnHitTest: THitTestEvent;

type THitTestEvent = procedure(Sender: TObject; X, Y: Integer; var Passed: Boolean) of object;

Description

Override this event to customize mouse hit testing at run-time. X and Y parameters indicate mouse position relative to TCustomImage32 (or its descendant) top-left corner.

See Also

TCustomImage32, Using Layers


OnMouseDown

TCustomLayer.OnMouseDown

property OnMouseDown: TMouseEvent;

type TMouseEvent = procedure (Sender: TObject; Button: TMouseButton ; Shift: TShiftState; X, Y: Integer) of object;

Description

This event is obsolete and remains here only for backward compatibility. Use the OnMouseDown event of TCustomImage32 instead.

[See also]: Using Layers, OnMouseMove, OnMouseUp

See Also

TCustomImage32.OnMouseDown, OnMouseMove, OnMouseUp, TCustomImage32, Using Layers


OnMouseMove

TCustomLayer.OnMouseMove

property OnMouseMove: TMouseMoveEvent;

type TMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState; X, Y: Integer) of object;

Description

This event is obsolete and remains here only for backward compatibility. Use the OnMouseMove event of TCustomImage32 instead.

See Also

OnMouseDown, TCustomImage32.OnMouseMove, OnMouseUp, TCustomImage32, Using Layers


OnMouseUp

TCustomLayer.OnMouseUp

property OnMouseUp: TMouseEvent;

type TMouseEvent = procedure (Sender: TObject; Button: TMouseButton ; Shift: TShiftState; X, Y: Integer) of object;

Description

This event is obsolete and remains here only for backward compatibility. Use the OnMouseUp event of TCustomImage32 instead.

See Also

OnMouseMove, TCustomImage32.OnMouseUp, TCustomImage32, Using Layers


OnPaint

TCustomLayer.OnPaint

property OnPaint: TPaintLayerEvent;

type TPaintLayerEvent = procedure(Sender: TObject; Buffer: TBitmap32) of object;

Description

Override this event to customize layer painting at run-time. Buffer specifies the back-buffer you should paint into.

See Also

TBitmap32, Using Layers


TLayerCollection

Hierarchy

TPersistent

Description

TLayerCollection is a container for TCustomLayer objects and their descendants.

Reference

Properties | Methods
In TLayerCollection:
Count | Add
Items | Clear
MouseEvents | Create
MouseListener | Delete
 | Destroy
 | Insert

See Also

TCustomLayer, Using Layers


Count

TLayerCollection.Count

property Count: Integer; // Read only

Description

Indicates the amount of layers stored in the collection.

See Also

Items, Using Layers


Items

TLayerCollection.Items

property Items[Index: Integer]: TCustomLayer;

Description

Provides indexed access to contained layers. Index of layers is zero-based.

See Also

Count, TCustomLayer, Using Layers


MouseEvents

TLayerCollection.MouseEvents

property MouseEvents: Boolean;

Description

Determines if mouse messages from the owner (TCustomImage32) do propagate to layers.

See Also

TCustomImage32, Using Layers


MouseListener

TLayerCollection.MouseListener

property MouseListener: TCustomLayer;

Description

Indicates the layer which has captured mouse messages. By default, the layer captures mouse if the left mouse button is pressed and releases it when the mouse button is released.

Note, that since layers have nothing to do with windowed controls, this property is just a simulation of standard mouse capturing. Windows still 'thinks' that the mouse is captured to the owner of the layer collection (TCustomImage32), which in turn redirects mouse messages to an appropriate layer.

See Also

TCustomImage32, TCustomLayer, Using Layers


Add

TLayerCollection.Add

function Add(ItemClass: TLayerClass): TCustomLayer;

type TLayerClass = class of TCustomLayer;

Description

Adds a new layer to the collection. The layer is added to the end of the list and it's Index property will become equal to Count - 1.

The class of the layer is specified in the ItemClass parameter and you will need to typecast the result to ItemClass if you need to access its specific properties, for example:

var

BL: TBitmapLayer;

begin

BL := TBitmapLayer(MyImage32.Layers.Add(TBitmapLayer));

...

end;

Alternatively, you can use another approach to add layers to the collection:

var

BL: TBitmapLayer;

begin

BL := TBitmapLayer.Create(MyImage32.Layers);

end;

See Also

Count, TCustomLayer.Index, TCustomLayer, Using Layers


Clear

TLayerCollection.Clear

procedure Clear;

Description

Removes and destroys all the layers from the collection.

See Also

Using Layers


Create

TLayerCollection.Create

constructor Create(AOwner: TComponent);

Description

Creates a new instance of TLayerCollection. This constructor is used internally in constructor of TCustomImage32 to initialize its Layers property.

See Also

TCustomImage32.Layers, TCustomImage32, TLayerCollection, Using Layers


Delete

TLayerCollection.Delete

procedure Delete(Index: Integer);

Description

Removes and destroy the layer with specified index from the collection.

See Also

Using Layers


Destroy

TLayerCollection.Destroy

destructor Destroy; override;

Description

Destroys an instance of TLayerCollection together with all contained layers. This destructor is used in the destructor of TCustomImage32 to property deallocate its Layers property.

See Also

TCustomImage32.Layers, TCustomImage32, TLayerCollection, Using Layers


Insert

TLayerCollection.Insert

function Insert(Index: Integer; ItemClass: TLayerClass): TCustomLayer;

type TLayerClass = class of TCustomLayer;

Description

Inserts a new layer at the specified position. Insert works similar to the Add method.

See Also

Add, TCustomLayer, Using Layers


TPositionedLayer

Hierarchy

TPersistent

|

TCustomLayer

Description

TPositionedLayer is the base class for layers that are positioned withing the boundaries of their container (TCustomImage32 or its descendant). The position and size is determined by the Location property.

When TPositionedLayer performs its HitTest, those points inside the rectangle returned by GetAdjustedLocation pass the test.

The class does not perform any drawing itself, however it is capable of calling the OnPaint event, where you can perform cutom drawing.

Reference

Properties | Methods | Events
In TPositionedLayer:
Location | Create |
Scaled | GetAdjustedLocation |
In TCustomLayer:
Cursor | BringToFront | OnHitTest
Index | Destroy | OnMouseDown
LayerCollection | HitTest | OnMouseMove
LayerOptions | SendToBack | OnMouseUp
LayerStates |  | OnPaint
MouseEvents |  |
Tag |  |
Visible |  |

See Also

TCustomImage32, Using Layers


Location

TPositionedLayer.Location

property Location: TFloatRect;

Description

Determines layer's position and size.

Note, that the layer is not constrained to lie entirely within the rectangle specified by Location. It may perform drawing outside the Location and may catch mouse messages from other areas.

When the layer is Scaled, its actual location its position after scaling may be obtained through GetAdjustedLocation method.

See Also

GetAdjustedLocation, Scaled, TFloatRect, Using Layers


Scaled

TPositionedLayer.Scaled

property Scaled: Boolean;

Description

Specifies if the layer is scaled and determines the result returned by GetAdjustedLocation. When set to True, scaling is influenced by the layout of bitmap image in the container (TCustomImage32 object or its descendant).

See Also

Bitmap Image, GetAdjustedLocation, TCustomImage32, Using Layers


Create

TPositionedLayer.Create

constructor Create(ALayerCollection: TLayerCollection); override;

Description

Creates the instance of TPositionedLayer.

After calling the inherited constructor, Create initializes the following properties:

  • LayerOptions to LOB_VISIBLE or LOB_MOUSE_EVENTS;
  • Scaled to False;
  • Location to FloatRect(0, 0, 64, 64);

See Also

TCustomLayer.Create, TCustomLayer.LayerOptions, Location, Scaled, TLayerCollection, TPositionedLayer, Using Layers


GetAdjustedLocation

TPositionedLayer.GetAdjustedLocation

function GetAdjustedLocation: TFloatRect;

Description

When the Scaled property is True, GetAdjustedLocation returns scaled Location, otherwise it returns Location as it is, without scaling.

It is up to you do decide if you want to use the result as a floating-point rectangle, to round the coordinates before painting:

procedure TForm1.OnLayerPaintHandler(Sender: TObject; Buffer: TBitmap32);

var

R: TRect;

begin

if Sender is TPositionedLayer then

with TPositionedLayer(Sender) do

begin

R := Rect(GetAdjustedLocation);

Buffer.FrameRectS(R.Left, R.Top, R.Right, R.Bottom, clRed32);

end;

end;

end;

See Also

Location, Scaled, TFloatRect, Using Layers


TRubberbandLayer

Hierarchy

TPersistent

|

TCustomLayer

|

TPositionedLayer

Description

This class implements a rubber band, allowing to move and resize other positioned layers at run-time. The layer paints itself at GDI Overlays stage, using the standard GDI methods.

It is a good idea to keep TRubberbandLayer on top of other layers so that thay don't intercept mouse messages.

Note, that this is a preliminary implementation of rubber banding, there is a lot to be done here to make its behavior more consistent, which will be done in future versions of the library. However, most likely I will keep names and general meaning of most properties and methods.

Reference

Properties | Methods | Events
In TRubberbandLayer:
ChildLayer | Create | OnResizing
FrameStippleStep | Destroy | OnUserChange
HandleFill | SetFrameStipple |
HandleFrame |  |
Handles |  |
HandleSize |  |
MaxHeight |  |
MaxWidth |  |
MinHeight |  |
MinWidth |  |
In TPositionedLayer:
Location | GetAdjustedLocation |
Scaled |  |
In TCustomLayer:
Cursor | BringToFront | OnHitTest
Index | HitTest | OnMouseDown
LayerCollection | SendToBack | OnMouseMove
LayerOptions |  | OnMouseUp
LayerStates |  | OnPaint
MouseEvents |  |
Tag |  |
Visible |  |

See Also

GDI Overlays, Using Layers


ChildLayer

TRubberbandLayer.ChildLayer

property ChildLayer: TPositionedLayer;

Description

Points to the position layer, controlled by the rubber band. TRubberbandLayer will keep Location of its child layer the same as its own Location.

See Also

TPositionedLayer.Location, TPositionedLayer, TRubberbandLayer


FrameStippleStep

TRubberbandLayer.FrameStippleStep

property FrameStippleStep: Single;

Description

Specifies the stepping for the stipple pattern of the surrounding frame.

See Also

SetFrameStipple


HandleFill

TRubberbandLayer.HandleFill

property HandleFill: TColor32;

Description

Specifies the color of the drag handle.


HandleFrame

TRubberbandLayer.HandleFrame

property HandleFrame: TColor32;

Description

Specifies the frame color of the drag handle.


Handles

TRubberbandLayer.Handles

property Handles: TRBHandles;

type TRBHandles = set of (rhCenter, rhSides, rhCorners, rhFrame,
rhNotLeftSide, rhNotRightSide, rhNotTopSide, rhNotBottomSide,
rhNotTLCorner, rhNotTRCorner, rhNotBLCorner, rhNotBRCorner);

Description

Determines which handles are visible and draggable by the mouse.

  • rhCenter – corresponds to the internal area of the control, that is the area inside the rectangle specified by Location;
  • rhSides – corresponds to the handles on the edges of the layer;
  • rhCorners – corresponds to the handles at the corners of the layer;
  • rhFrame - corresponds to the frame surrounding the layer;
  • rhNotLeftSide, rhNotRightSide, rhNotTopSide, rhNotBottomSide - set to disable one or more sides (needs rhSides);
  • rhNotTLCorner, rhNotTRCorner, rhNotBLCorner, rhNotBRCorner - set to disable one or more corners (needs rhCorners);

See Also

TPositionedLayer.Location, TRBHandles


HandleSize

TRubberbandLayer.HandleSize

property HandleSize: Integer;

Description

Determines the size of the handles. The actual size in pixels may be calculated as

HandleSize * 2 + 1


MaxHeight

TRubberbandLayer.MaxHeight

property MaxHeight: Single;

Description

Determines the maximum height of the rubber band while it resizes. When MaxHeight is less than or equal to MinHeight, this property is disregarded and the maximum height becomes unlimited.

See Also

MaxWidth, MinHeight


MaxWidth

TRubberbandLayer.MaxWidth

property MaxWidth: Single;

Description

Determines the maximum width of the rubber band while it resizes. When MaxWidth is less than or equal to MinWidth, this property is disregarded and the maximum width becomes unlimited.

See Also

MinWidth


MinHeight

TRubberbandLayer.MinHeight

property MinHeight: Single;

Description

Determines the minimum height of the rubber band while it resizes.

See Also

MinWidth


MinWidth

TRubberbandLayer.MinWidth

property MinWidth: Single;

Description

Determines the minimum width of the rubber band while it resizes.

See Also

MinHeight


Create

TRubberbandLayer.Create

constructor Create(ALayerCollection: TLayerCollection); override;

Description

Creates an instance of TRubberbandLayer and adds it into the specified collection.

See Also

TCustomLayer.Create, TLayerCollection, TRubberbandLayer


Destroy

TRubberbandLayer.Destroy

destructor Destroy; override;

Description

Removes the rubber band layer from the collection and destroys it .

Do not call Destroy directly in your application, use the standard Free method instead.


SetFrameStipple

TRubberbandLayer.SetFrameStipple

procedure SetFrameStipple(const Value: Array of TColor32);

Description

Sets the stipple pattern for the frame in the rubberband.

See Also

Color Types, FrameStippleStep


OnResizing

TRubberbandLayer.OnResizing

property OnResizing: TRBResizingEvent;

type TRBResizingEvent = procedure(

Sender: TObject;
const OldLocation: TFloatRect;
var NewLocation: TFloatRect;
DragState: TDragState;
Shift: TShiftState) of object;

type TDragState = (dsNone, dsMove, dsSizeL, dsSizeT, dsSizeR, dsSizeB, dsSizeTL, dsSizeTR, dsSizeBL, dsSizeBR);

Description

OnResizing allowes for runtime customization of the rubber band which is being moved or resized using the mouse. This event is called only when the user clicks and drags the layer with the mouse, it is not generated when you set the Location property explicitly.

OldLocation specifies location of the layer before the user started dragging it.

NewLocation determines the new location of the rubber band. You may change the coordinates in order to provide required responce to dragging or resizing operation.

The DragState parameter indicates how the layer is being dragged/resized.

Shift indicates the state of the Alt, Ctrl, and Shift keys.

See Also

TPositionedLayer.Location


OnUserChange

TRubberbandLayer.OnUserChange

property OnUserChange: TNotifyEvent;

Description

The event is called automatically when the layer is moved or resized with the mouse. OnUserChange is not colled when you change Location explicitly.

See Also

TPositionedLayer.Location


TRBHandles

type TRBHandles = set of (rhCenter, rhSides, rhCorners, rhFrame,
rhNotLeftSide, rhNotRightSide, rhNotTopSide, rhNotBottomSide,
rhNotTLCorner, rhNotTRCorner, rhNotBLCorner, rhNotBRCorner);

Description

A type for Handles property in TRubberbandLayer.

See Also

TRubberbandLayer.Handles, TRubberbandLayer


Layer Options Bits

The basic behavior of the layer is controlled by its LayerOptions property, an unsigned 32-bit integer field of bits. The upper 8 bits in this field are reserved for default options:

Bit # | Constant Name | Description
31 | LOB_VISIBLE | Controls the layer visibility
30 | LOB_GDI_OVERLAY | Indicates that the layer performs drawing when its owner (TCustomImage32 control or its descendant) draws its GDI Overlays. [ Note: Most likely, this constant will not be used in future versions. Do not use it ]
29 | LOB_MOUSE_EVENTS | Specifies whether the layer responds to mouse messages.
28 | LOB_NO_UPDATE | Disables automatic repainting when the layer changes its location or other properties.
27 | LOB_NO_CAPTURE | Allows to override automatic capturing of mouse messages when the left mouse is pressed on top of the layer. This bit has no effect if LOB_MOUSE_EVENTS is not set.
26 | LOB_RESERVED_26 | Reserved for future use
25 | LOB_RESERVED_25 | Reserved for future use
24 | LOB_RESERVED_24 | Reserved for future use

Other 24 bits can be used for any other purpose, as customized layer classification etc.

See Also

TCustomLayer.LayerOptions


GR32_Polygons

GR32_Polygons.pas provides functions and classes for drawing polygons and polylines.

Contents

Classes | Routines | Types | Constants
TBitmapPolygonFiller | Polygon | TAntialiasMode | DefaultAAMode
TCustomPolygonFiller | Polyline | TFillLineEvent |
TPolygon32 | PolyPolygon | TPolyFillMode |
 | PolyPolyline |  |
 | PtInPolygon |  |


TBitmapPolygonFiller

Hierarchy

TObject

|

TCustomPolygonFiller

Description

TBitmapPolygonFiller provides an easy way to have a polygon filled with a pattern (TBitmap32).

It fully supports the pattern's DrawMode setting. Custom pixel combiners are also supported.

You can directly use it in the DrawFill and Draw methods of TPolygon32 or in the Polygon and PolyPolygon routines.

Reference

Properties | Methods
In TBitmapPolygonFiller:
OffsetX |
OffsetY |
Pattern |
In TCustomPolygonFiller:
 | GetFillLine

See Also

TPolygon32.Draw, TPolygon32.DrawFill, TBitmap32.DrawMode, TBitmap32.OnPixelCombine, Polygon, PolyPolygon, TBitmap32, TCustomPolygonFiller, TPolygon32


OffsetX

TBitmapPolygonFiller.OffsetX

property OffsetX: Integer;

Description

Determines how much in pixels the tiling should be shifted in horizontal direction.

This is especially usefull if your polygon is moved and you want to move the pattern tiling relatively to it.


OffsetY

TBitmapPolygonFiller.OffsetY

property OffsetY: Integer;

Description

Determines how much in pixels the tiling should be shifted in vertical direction.

This is especially usefull if your polygon is moved and you want to move the pattern tiling relatively to it.


Pattern

TBitmapPolygonFiller.Pattern

property Pattern: TBitmap32;

Description

This property determines the pattern that is used to fill a polygon. The pattern will be tiled across the polygons.

Please note that the draw transformation won't have any effect on the polygon. For that purpose please preprocess your pattern accordingly.

See Also

TBitmap32


TCustomPolygonFiller

Hierarchy

TObject

Description

In addition to the standard color fillings for polygons, Graphics32 provides the ability to create new custom polygon fillers based on the TCustomPolygonFiller class or a TFillLineEvent-based callback.

If you want to create your own polygon filler, subclass from this class and override the GetFillLine method.

All classes based on TCustomPolygonFiller can be used with the DrawFill and Draw methods of TPolygon32 or with the Polygon and PolyPolygon routines.

Note: Don't use this class directly as it is partly abstract.

Reference

Methods
In TCustomPolygonFiller:
GetFillLine

See Also

TPolygon32.Draw, TPolygon32.DrawFill, Polygon, PolyPolygon, TBitmapPolygonFiller, TFillLineEvent, TPolygon32


GetFillLine

TCustomPolygonFiller.GetFillLine

function GetFillLine: TFillLineEvent; abstract;

Description

Descendants should override this abstract method. If overriden it should return a TFillLineEvent callback that is used to fill lines in a polygon.

See Also

TFillLineEvent


TPolygon32

Hierarchy

TPersistent

|

TThreadPersistent

Description

In addition to common polygon drawing functions, Graphics32 provides an auxiliary class TPolygon32, which may be used for storing and drawing polygons and polylines, allowes drawing of lines and polylines more than 1 pixel wide and provides some morphological modifications of polygons.

TPolygon32 is capable of storing more than a single polygon, it can represent a shape, outlines by several polygons, referred here as contours and specified in Points property. This allows rendering of comples shapes (with holes, etc.). In future versions we plan to implement direct TTF or Type1 font rendering.

Contour is considered as a closed polygon if the Closed property is True, otherwise it is treated as polyline. Each contour is, in turn, a dynamic array of TFixedPoint.

Polygons may be constructed by modifying other polygons using the Grow method or by adding sequentially new points with Add or starting new contours with NewLine.

Reference

Properties | Methods | Events
In TPolygon32:
Antialiased | Add |
AntialiasMode | AddPoints |
Closed | Assign |
FillMode | Clear |
Normals | ContainsPoint |
Points | Create |
 | Destroy |
 | Draw |
 | DrawEdge |
 | DrawFill |
 | GetBoundingRect |
 | Grow |
 | NewLine |
 | Offset |
 | Outline |
 | Transform |
In TThreadPersistent:
LockCount | BeginUpdate | OnChange
UpdateCount | Changed |
 | EndUpdate |
 | Lock |
 | Unlock |

See Also

Polygons Example, TFixedPoint


Antialiased

TPolygon32.Antialiased

property Antialiased: Boolean;

Description

Determines the quality of the shape when it is drawn with Draw, DrawFill or DrawEdge methods.

When Antialiased = False, the object uses PolyPolylineTS and PolyPolygonTS functions, otherwise, it uses PolyPolylineXS and PolyPolygonXS functions.

See Also

Draw, DrawEdge, DrawFill, PolyPolyline


AntialiasMode

TPolygon32.AntialiasMode

property AntialiasMode: TAntialiasMode;

Description

Determines how the shape is antialiased. See TAntialiasMode for details.

See Also

TAntialiasMode


Closed

TPolygon32.Closed

property Closed: Boolean;

Description

Specifies whether each contour defined by Points is a closed shape, or if it has to be considered as polyline.

This property is ignored by Draw and DrawFill methods, but it is important when using Outline method.

See Also

Draw, DrawFill, Outline, Points


FillMode

TPolygon32.FillMode

property FillMode: TPolyFIllMode;

Description

Determines the shape's fill mode.

See Also

TPolyFillMode


Normals

TPolygon32.Normals

property Normals: TArrayOfArrayOfFixedPoint;

Description

This array stores unit vectors showing the direction normal to each line in each contour. Normals are used in Grow.

See Also

Grow, Points, TArrayOfArrayOfFixedPoint


Points

TPolygon32.Points

property Points: TArrayOfArrayOfFixedPoint;

Description

This property defines an array of contours. Each contour is, in turn, an array of vertexes.

See Also

Normals, TArrayOfArrayOfFixedPoint


Add

TPolygon32.Add

procedure Add(const P: TFixedPoint);

Description

Adds a new vertex to the current contour in the polygon. In order to start a new contour, use the NewLine method.

See Also

NewLine, TFixedPoint


AddPoints

TPolygon32.AddPoints

procedure AddPoints(const First: TFixedPoint; Count: Integer);

Description

Copies Count number of points beginning at point First to the current outline.

See Also

TFixedPoint


Assign

TPolygon32.Assign

procedure Assign(Source: TPersistent); virtual;

Description

If Source is also of type TPolygon32, Assign copies all properties, points and normals over to the current instance. The old values are replaced in this process.

See Also

TPolygon32


Clear

TPolygon32.Clear

procedure Clear;

Description

Clears the information on all contours, associated with the polygon.


ContainsPoint

TPolygon32.ContainsPoint

function ContainsPoint(const P: TFixedPoint): Boolean;

Description

This method returns true if a point P is contained within any of the contours in the current TPolygon32 instance and false otherwise.

See Also

Point Types, PtInPolygon, TFixedPoint


Create

TPolygon32.Create

constructor Create; override;

Description

Creates and initializes an instance of TPolygon32.

After calling the inherited constructor, Create initializes the following properties:

  • Closed to True;
  • Antialiazed to False;
  • FillMode to pfAlternate;

See Also

Antialiased, Closed, FillMode, TPolygon32


Destroy

TPolygon32.Destroy

destructor Destroy; override;

Description

Destroys the polygon object and frees all associated memory.

Do not call Destroy directly, use Free method instead.


Draw

TPolygon32.Draw

procedure Draw(Bitmap: TBitmap32; OutlineColor, FillColor: TColor32; Transformation: TTransformation = nil); overload;

procedure Draw(Bitmap: TBitmap32; OutlineColor: TColor32; FillLineCallback: TFillLineEvent; Transformation: TTransformation = nil); overload;

procedure Draw(Bitmap: TBitmap32; OutlineColor: TColor32; Filler: TCustomPolygonFiller; Transformation: TTransformation = nil); overload;

Description

Fills the polygon and draws the outline transformed by Transformation. This method is a simple combination of DrawFill and DrawEdge methods.

See Also

DrawEdge, DrawFill, TBitmap32, TColor32, TCustomPolygonFiller, TFillLineEvent, TTransformation


DrawEdge

TPolygon32.DrawEdge

procedure DrawEdge(Bitmap: TBitmap32; Color: TColor32 ; Transformation: TTransformation = nil);

Description

Frames the edge of the polygon with specified color and uses the Transformation while drawing.

The quality of the line is determined by Antialiased property.

When Closed property is True, each polygon is automatically closed.

See Also

Antialiased, Closed, Draw, DrawFill, TBitmap32, TColor32, TTransformation


DrawFill

TPolygon32.DrawFill

procedure DrawFill(Bitmap: TBitmap32; Color: TColor32; Transformation: TTransformation = nil); overload;

procedure DrawFill(Bitmap: TBitmap32; FillLineCallback: TFillLineEvent; Transformation: TTransformation = nil); overload;

procedure DrawFill(Bitmap: TBitmap32; Filler: TCustomPolygonFiller; Transformation: TTransformation = nil); overload;

Description

Fills the polygon shape using one of the following options using the current FillMode:

  • simple color
  • custom fillline callback
  • custom filler object

Optionally a Transformation is applied while drawing.

The Closed property is ignored and all contours are automatically considered closed.

The edge quality of the filling is determined by the Antialiased property.

See Also

Antialiased, Closed, Draw, DrawEdge, FillMode, TBitmap32, TColor32, TCustomPolygonFiller, TFillLineEvent, TTransformation


GetBoundingRect

TPolygon32.GetBoundingRect

function GetBoundingRect: TFixedRect;

Description

Returns the common bounding rectangle for all outlines in the current polygon.

See Also

Rectangle Types


Grow

TPolygon32.Grow

function Grow(const Delta: TFixed; EdgeSharpness: Single = 0): TPolygon32;

Description

Creates a new instance of TPolygon32 object and changes its shape similar to dilation (or erosion when Delta is negative) morphological filters.

The direction of grouth is determined by the order of the points in the contour. Positive direction is to the left of each line (see image below).

Using Grow method with Delta = 0 will simply create a new instance of the polygon with the same data as in original polygon.

The EdgeSharpness parameter controls generation of new vertices. Its value range is [0…0.99].

See Also

TFixed, TPolygon32


NewLine

TPolygon32.NewLine

procedure NewLine;

Description

Starts a new contour. New points, introduced with Add function, will be inserted into the new contour.

See Also

Add


Offset

TPolygon32.Offset

procedure Offset(const Dx, Dy: TFixed);

Description

Shifts all the points in all contours Dx pixels right and Dy pixels down. Values of Dx and Dy can be negative.

See Also

TFixed


Outline

TPolygon32.Outline

function Outline: TPolygon32;

Description

This functions takes each contour (polyline) and constructs a new TPolygon32 object by outlining each contour.

The operation is similar to using morphological edge detection filter for bitmaps, but it operates over polygon vertices.

When outlining a closed polygon, this function actually returns two contours for each initial closed contour. In case of polylines (Closed property is False), it returns a single contour (see image below).

Note, this technique produces good results only for antialiased polygons.

This function is essential for thick line drawing, all you have to do, is to take an original polygon, build its outline and grow it to get the desired thickness:

var
P, Outline: TPolygon32;
begin
Outline := P.Outline; // create an outline
Outline.Grow(Fixed(1), 1); // make it 2-pixel wide outline (it grows in both directions)
Outline.DrawFill(DstBitmap, clBlack32);
end;

See Also

Closed, TPolygon32


Transform

TPolygon32.Transform

procedure Transform(Transformation: TTransformation);

Description

Transforms all points in the current instance using the supplied Transformation instance. This is different from the transformation while drawin because it is a permanent operation.

See Also

TTransformation


Polygon

procedure PolygonTS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Color: TColor32; Mode: TPolyFillMode = pfAlternate; Transformation: TTransformation = nil); overload;

procedure PolygonTS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; FillLineCallback: TFillLineEvent; Mode: TPolyFillMode = pfAlternate; Transformation: TTransformation = nil); overload;

procedure PolygonTS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Filler: TCustomPolygonFiller; Mode: TPolyFillMode = pfAlternate; Transformation: TTransformation = nil); overload;

procedure PolygonXS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Color: TColor32; Mode: TPolyFillMode = pfAlternate; AAMode: TAntialiasMode = DefaultAAMode; Transformation: TTransformation = nil); overload;

procedure PolygonXS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; FillLineCallback: TFillLineEvent; Mode: TPolyFillMode = pfAlternate; AAMode: TAntialiasMode = DefaultAAMode; Transformation: TTransformation = nil); overload;

procedure PolygonXS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Filler: TCustomPolygonFiller; Mode: TPolyFillMode = pfAlternate; AAMode: TAntialiasMode = DefaultAAMode; Transformation: TTransformation = nil); overload;

Description

Fills the shape defined by the Points parameter and (optionally) transformed by the Transformation parameter using one of the following options:

  • simple color
  • custom fillline callback
  • custom filler object

Unlike GDI polygons, this function allows for transparency and optional antialiasing.

PolygonTS draws a non-antialiased polygon with optional transparency. When drawing, fixed-point coordinates of vertices are rounded.

PolygonXS provides full antialiasing and does not perform rounding of vertex coordinates. You can also specify the antialias mode AAMode that should be used.

All functions perform clipping.

See Also

DefaultAAMode, Naming Conventions, TAntialiasMode, TArrayOfFixedPoint, TBitmap32, TColor32, TCustomPolygonFiller, TFillLineEvent, TPolyFillMode, TTransformation


Polyline

procedure PolyLineTS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Color: TColor32; Closed: Boolean=True; Transformation: TTransformation = nil);

procedure PolyLineAS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Color: TColor32; Closed: Boolean=True; Transformation: TTransformation = nil);

procedure PolyLineXS(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Color: TColor32; Closed: Boolean=True; Transformation: TTransformation = nil);

procedure PolyLineXSP(Bitmap: TBitmap32; const Points: TArrayOfFixedPoint; Closed: Boolean=True; Transformation: TTransformation = nil);

Description

Draws a series of lines, connecting points passed in. The points are transformed by Transformation. If Closed is True, the polygon is closed automatically by drawing a line from the last vertex to the first.

PolyLineTS draws a non-antialiased line with optional transparency. When drawing, fixed-point coordinates of vertixes are rounded.

PolyLineAS draws an antialiased line, fixed-point coordinates of vertexes are rounded.

PolyLineXS provides full antialiasing and does not perform rounding of vertexes' coordinates. PolyLineXSP uses the stipple pattern defined in the Bitmap instead of a color.

All functions perform clipping.

See Also

Naming Conventions, TArrayOfFixedPoint, TBitmap32, TColor32, TTransformation


PolyPolygon

procedure PolyPolygonTS(Bitmap: TBitmap32; const Points: TArrayOfArrayOfFixedPoint; Color: TColor32; Mode: TPolyFillMode = pfAlternate);

procedure PolyPolygonXS(Bitmap: TBitmap32; const Points: TArrayOfArrayOfFixedPoint; Color: TColor32; Mode: TPolyFillMode = pfAlternate; AAMode: TAntialiasMode = DefaultAAMode);

Description

Fills the shape similar to that done by Polygon function. The shape is constructed from several contours, which are specified in Points parameter. The filling is performed according to Mode parameter.

For PolyPolygonXS you can also specify the antialias mode that should be used.

See Also

DefaultAAMode, Naming Conventions, Polygon, PolyPolyline, TAntialiasMode, TArrayOfArrayOfFixedPoint, TBitmap32, TColor32, TPolyFillMode


PolyPolyline

procedure PolyPolylineTS(Bitmap: TBitmap32; const Points: TArrayOfArrayOfFixedPoint; Color: TColor32; Closed: Boolean=True; Transformation: TTransformation=nil);

procedure PolyPolylineAS(Bitmap: TBitmap32; const Points: TArrayOfArrayOfFixedPoint; Color: TColor32; Closed: Boolean=True; Transformation: TTransformation=nil);

procedure PolyPolylineXS(Bitmap: TBitmap32; const Points: TArrayOfArrayOfFixedPoint; Color: TColor32; Closed: Boolean=True; Transformation: TTransformation=nil);

procedure PolyPolylineXSP(Bitmap: TBitmap32; const Points: TArrayOfArrayOfFixedPoint; Closed: Boolean=True; Transformation: TTransformation=nil);

Description

PolyPolyline is the same as Polyline, but takes array of polylines as parameter. The Closed parameter influences all polylines in the array.

See Also

Naming Conventions, Polyline, PolyPolygon, TArrayOfArrayOfFixedPoint, TBitmap32, TColor32


PtInPolygon

function PtInPolygon(const Pt: TFixedPoint; const Points: TArrayOfFixedPoint): Boolean;

Description

Returns true if Pt is a coordinate within the the polygon region specified by an array of fixed-point coordinates.

See Also

TPolygon32.ContainsPoint, Point Types, TArrayOfFixedPoint, TFixedPoint


TAntialiasMode

type TAntialiasMode = (am16times, am8times, am4times);

Description

Specifies how polygons are antialiased.

Here is a small illustration that demonstrates the different modes and their output quality:

16x supersampling generally generates the best result, however, it's also the slowest mode.
8x supersampling is a good compromise between speed and quality.
4x supersampling - while being the worst quality-wise next to no antialiasing - is generally the fastest of the three.

If you need fast but still antialiased polygons (for example in an editor) we recommend using the 4x or 8x antialias mode.

See Also

Polygon


TFillLineEvent

type TFillLineEvent = procedure(Dst: PColor32; DstX, DstY, Length: Integer; AlphaValues: PColor32) of object;

Description

Use this definition to create custom fill line callbacks.

Dst specifies the first position in the destination buffer that needs to be drawn to. You can use the coordinates DstX and DstY for calculations.

Length determines the length of the line to draw.

AlphaValues is a pointer to the first alpha value of the edge for each pixel on that line. This is used by the PolygonXS and PolyPolygonXS procedures only. For PolygonTS and PolyPolygonTS this parameter is nil, so please do appropriate checks.

Callbacks based on this specification cann be used with the DrawFill and Draw methods of TPolygon32 or with the Polygon and PolyPolygon routines.

See Also

TPolygon32.Draw, TPolygon32.DrawFill, Polygon, PolyPolygon, TPolygon32


TPolyFillMode

type TPolyFillMode = (pfAlternate, pfWinding);

Description

Specifies how polygons are filled.

See Also

Polygon


DefaultAAMode

The DefaultAAMode constant of type TAntialiasMode sets the default antialias mode to am8times.

See Also

TAntialiasMode


GR32_RangeBars

GR32_RangeBars.pas provides controls similar to standard TScrollBar and TControlScrollBar. This unit is included into Graphics32 to provide customized scroll bars for TCustomImgView32 and TImgView32 to scroll their contents.

Contents

Classes | Types
TArrowBar | TRBBackgnd
TCustomGaugeBar | TRBStyle
TCustomRangeBar |
TGaugeBar |
TRangeBar |

See Also

TCustomImgView32, TImgView32


TArrowBar

Hierarchy

TCustomControl

Description

A common ancestor for range bars and gauge bars. Both its descendants are similar to standard windows scroll bars. TArrowBar declares common properties which define visual appearance of scroll bars.

Reference

Properties | Methods | Events
In TArrowBar:
Backgnd | Create | OnChange
BorderStyle | Destroy | OnUserChange
ButtonSize | Paint |
HandleColor |  |
Kind |  |
ShowArrows |  |
ShowHandleGrip |  |
Style |  |

See Also

TCustomGaugeBar, TCustomRangeBar


Backgnd

TArrowBar.Backgnd

property Backgnd: TRBBackgnd;

type TRBBackgnd = (bgPattern, bgSolid);

Description

Determines appearance of the background:

Note, that this property is available only when Style=rbsMac.

See Also

Style, TRBBackgnd


BorderStyle

TArrowBar.BorderStyle

property BorderStyle: TBorderStyle;

type TBorderStyle = (bsNone, bsSingle); // declared in Forms.pas

Description

When BorderStyle is bsSingle, control is painted with a recessed border.


ButtonSize

TArrowBar.ButtonSize

property ButtonSize: Integer;

Description

Specifies the size of the scroll button in pixels.

When ButtonSize is set to 0 (default), this size is calculated and updated automatically to keep the button square.

If you want to hide buttons set ShowArrows property to False.

See Also

ShowArrows


HandleColor

TArrowBar.HandleColor

property HandleColor: TColor;

Description

Specifies a color of the handle:

Although TArrowBar itself does not have any handles, this property is used in descendants TCustomRangeBar and TCustomGaugeBar.

Note, that this property is available only when Style=rbsMac.

See Also

Style, TArrowBar, TCustomGaugeBar, TCustomRangeBar


Kind

TArrowBar.Kind

property Kind: TScrollBarKind;

type TScrollBarKind = (sbHorizontal, sbVertical); // defined in Forms.pas

Description

Indicates orientation of the control.


ShowArrows

TArrowBar.ShowArrows

property ShowArrows: Boolean;

Description

Determines visibility of scrolling buttons.


ShowHandleGrip

TArrowBar.ShowHandleGrip

property ShowHandleGrip: Boolean;

Description

Determines visibility of a handle grip:

Although TArrowBar itself does not have any handles, this property is used in descendants TCustomRangeBar and TCustomGaugeBar.

Note, that this property is available only when Style=rbsMac.

See Also

Style, TArrowBar, TCustomGaugeBar, TCustomRangeBar


Style

TArrowBar.Style

property Style: TRBStyle;

type TRBStyle = (rbsDefault, rbsMac);

Description

Determines appearance of the control. Note that some properties are accessible only when Style is set to rbsMac.

The default value is rbsDefault;


Create

TArrowBar.Create

constructor Create(AOwner: TComponent); override;

Description

Creates and initializes an instance of TArrowBar.

After calling the inherited constructor, Create initializes the following properties:

  • Backgnd to bgPattern;
  • ButtonSize to 0;
  • Color to clBtnShadow;
  • Style to rbsDefault;
  • HandleColor to clBtnShadow;
  • Kind to sbHorizontal;
  • ShowArrows to True;
  • ShowHandleGrip to True;

See Also

Backgnd, ButtonSize, HandleColor, Kind, ShowArrows, ShowHandleGrip, Style, TArrowBar


Destroy

TArrowBar.Destroy

destructor Destroy; override;

Description

Destroys the arrowbar object and frees all associated memory.

Do not call Destroy directly, use Free method instead.


Paint

TArrowBar.Paint

procedure Paint; override;

Description

Paint is overriden from TCustomControl. It draws the bar and scroll buttons.


OnChange

TArrowBar.OnChange

property OnChange: TNotifyEvent;

Description

OnChange is called each time control changes.

This event is never called by TArrowBar itself, but it is shared by descendants TCustomRangeBar and TCustomGaugeBar.

See Also

OnUserChange, TArrowBar, TCustomGaugeBar, TCustomRangeBar


OnUserChange

TArrowBar.OnUserChange

property OnUserChange: TNotifyEvent;

Description

OnUserChange is called when control is changed by user, as reaction to mouse events. It is not called then the control is changed due to some internal program activity. This event is called after OnChange.

This event is never called by TArrowBar itself, but it is shared by descendants TCustomRangeBar and TCustomGaugeBar.

See Also

OnChange, TArrowBar, TCustomGaugeBar, TCustomRangeBar


TCustomGaugeBar

Hierarchy

TCustomControl

|

TArrowBar

Description

A base class for TGaugeBar objects.

Behavior and appearance of TCustomGaugeBar is very similar to standard TScrollBar, defined in StdCtrls.pas.

Reference

Properties | Methods | Events
In TCustomGaugeBar:
HandleSize | Create |
LargeChange | Paint |
Max |  |
Min |  |
Position |  |
SmallChange |  |
In TArrowBar:
Backgnd | Destroy | OnChange
BorderStyle |  | OnUserChange
ButtonSize |  |
HandleColor |  |
Kind |  |
ShowArrows |  |
ShowHandleGrip |  |
Style |  |

See Also

TGaugeBar


HandleSize

TCustomGaugeBar.HandleSize

property HandleSize: Integer;

Description

Specifies the size of the handle:

If HandleSize is 0 (default), the size is calculated and updated automatically to keep the handle square.

See Also

TArrowBar.ButtonSize


LargeChange

TCustomGaugeBar.LargeChange

property LargeChange: Integer;

Description

Determines how much Position changes when the user clicks the scroll bar on either side of the handle.

See Also

Position, SmallChange


Max

TCustomGaugeBar.Max

property Max: Integer;

Description

The Max and Min properties define the available range for Position.

See Also

Min, Position


Min

TCustomGaugeBar.Min

property Min: Integer;

Description

The Max and Min properties define the available range for Position.

See Also

Max, Position


Position

TCustomGaugeBar.Position

property Position: Integer;

Description

Specifies the current position of the scrollbar.

Read Position to determine the current position of the thumb tab.

Set Position to programmatically move the handle. The available range of positions is determined by the difference between the Max property and the Min property.

When Position is changed programmatically, gauge bar will generate OnChange event, when it is changed by user (by clicking scrolling buttons, dragging the handle or clicking on the background area), the control will additionally generate OnUserChange event.

See Also

Max, Min, TArrowBar.OnChange, TArrowBar.OnUserChange


SmallChange

TCustomGaugeBar.SmallChange

property SmallChange: Integer;

Description

Determines how much Position changes when the user clicks the scrolling buttons.

See Also

LargeChange, Position


Create

TCustomGaugeBar.Create

constructor Create(AOwner: TComponent); override;

Description

Creates and initializes an instance of TCustomGaugeBar.

After calling the inherited constructor, Create initializes the following properties:

  • HandleSize to 0;
  • LargeChange to 1;
  • Max to 100;
  • Min to 0;
  • Position to 0;

See Also

HandleSize, LargeChange, Max, Min, Position, TCustomGaugeBar


Paint

TCustomGaugeBar.Paint

procedure Paint; override;

Description

Paint is overriden from TArrowBar.Paint. In addition to bar and scrolling buttons, it paints the handle.

See Also

TArrowBar.Paint


TCustomRangeBar

Hierarchy

TCustomControl

|

TArrowBar

Description

A base class for TRangeBar objects.

Behavior and appearance of TCustomRangeBar is similar to standard TControlScrollBar, defined in Forms.pas, however it does not use the common control library.

Although range bar may operate as a stand-alone control, most of the time you will use it in conjunction with another control, which has a scrollable region:

Range bars are less limited compared to TControlScrollBar. For example, the size of the range bar can be different from the size of the scrollable control and it may be positioned anywhere in the form. Another difference is that range bars do not hide themselves when scrolling range is less than or equal to the size of the scrollable area, they just become disabled.

In addition, range bars have nothing to do with scrollable control's client arrea. They neigher shift client origin, nor determine their range automatically.

Reference

Properties | Methods | Events
In TCustomRangeBar:
Centered | Create |
Increment | Paint |
Position |  |
Range |  |
Window |  |
In TArrowBar:
Backgnd | Destroy | OnChange
BorderStyle |  | OnUserChange
ButtonSize |  |
HandleColor |  |
Kind |  |
ShowArrows |  |
ShowHandleGrip |  |
Style |  |

See Also

TRangeBar


Centered

TCustomRangeBar.Centered

property Centered: Boolean;

Description

Determines how the handle is repositioned when Range changes.

If Centered is False (default), the control behaves similar to standard TControlScrollBar. That is it tries to preserve the Position property.

If Centered is True, the control changes Position, trying to keep the centre at the same location.

This property also influences how the handle is adjusted when range bar changes its Window size.

See Also

Position, Range, Window


Increment

TCustomRangeBar.Increment

property Increment: Single;

Description

Determines the change in Position when user clicks scrolling arrows.

Default value is 8.

See Also

Position


Position

TCustomRangeBar.Position

property Position: Single;

Description

Determines the current position of the handle.

Note, that Position is a single precision floating-point value. Which allows for more predictable behavior then Centered property is set to True, since the handle won't drift due to rounding errors.

See Also

Centered, Range, Window


Range

TCustomRangeBar.Range

property Range: Single;

Description

Determines the scrollable range.

When range is less than the value stored in Window property(or the size of the control, in case Window = 0), the control draws itself disabled.

See Also

Position, Window


Window

TCustomRangeBar.Window

property Window: Single;

Description

The size of the associated visible area:

In case the value of the property is set to zero, range bar assumes that it is equal to its own size, as shown in the picture above.

Using this property is required when the size of the scrollable window is different from the size of the range bar.

See Also

Position, Range


Create

TCustomRangeBar.Create

constructor Create(AOwner: TComponent); override;

Description

Creates and initializes an instance of TCustomRangeBar.

After calling the inherited constructor, Create initializes the following properties:

  • Centered to False;
  • Increment to 8;
  • Position to 0;
  • Range to 0;

See Also

Centered, Increment, Position, Range, TCustomRangeBar


Paint

TCustomRangeBar.Paint

procedure Paint; override;

Description

Paint is overriden from TArrowBar.Paint. In addition to the bar itself and scrolling buttons, it paints the handle.

See Also

TArrowBar.Paint


TGaugeBar

Hierarchy

TCustomControl

|

TArrowBar

|

TCustomGaugeBar

Description

TGaugeBar is a control similar to standard TScrollBar.

TGaugeBar implements the generic behavior introduced in TCustomGaugeBar. It publishes some inherited properties from TCustomGaugeBar, but does not introduce any new behavior.

Reference

Properties | Methods | Events
In TCustomGaugeBar:
HandleSize | Create |
LargeChange | Paint |
Max |  |
Min |  |
Position |  |
SmallChange |  |
In TArrowBar:
Backgnd | Destroy | OnChange
BorderStyle |  | OnUserChange
ButtonSize |  |
HandleColor |  |
Kind |  |
ShowArrows |  |
ShowHandleGrip |  |
Style |  |

See Also

TCustomGaugeBar


TRangeBar

Hierarchy

TCustomControl

|

TArrowBar

|

TCustomRangeBar

Description

TRangeBar is a control similar to standard TControlScrollBar. Normally it is associated with some other control that has a scrollable region.

TRangeBar implements the generic behavior introduced in TCustomRangeBar. It publishes some inherited properties from TCustomRangeBar, but does not introduce any new behavior.

Reference

Properties | Methods | Events
In TCustomRangeBar:
Centered | Create |
Increment | Paint |
Position |  |
Range |  |
Window |  |
In TArrowBar:
Backgnd | Destroy | OnChange
BorderStyle |  | OnUserChange
ButtonSize |  |
HandleColor |  |
Kind |  |
ShowArrows |  |
ShowHandleGrip |  |
Style |  |

See Also

TCustomGaugeBar, TCustomRangeBar


TRBBackgnd

type TRBBackgnd = (bgPattern, bgSolid);

Description

Specifies a type of background filling of the arrow bar control and its descendants. See TArrowBar.Backgnd for more information.

See Also

TArrowBar.Backgnd


TRBStyle

type TRBStyle = (bgDefault, bgMac);

Description

Specifies the arrow bar style. See TArrowBar.Style for more information.

See Also

TArrowBar.Style


GR32_Transforms

GR32_Transforms.pas provides functions and classes for combining and transforming bitmap images and their fragments.

It also includes affine and pojective transformations of bitmaps.

Contents

Classes | Routines | Types | Constants
TAffineTransformation | BlockTransfer | TFloatMatrix | IdentityMatrix
TProjectiveTransformation | SetBorderTransparent |  |
TTransformation | StretchTransfer |  |
 | Transform |  |
 | TransformPoints |  |


TAffineTransformation

Hierarchy

TObject

|

TTransformation

Description

The transformation is defined by 3x3 homogeneous matrix of single-precision floats, TFloatMatrix:

Only the first two rows are used for coordinate transformation at the final stage.

Reference

Fields | Properties | Methods
In TAffineTransformation:
Matrix |  | Clear
 |  | Create
 |  | GetTransformedBounds
 |  | Rotate
 |  | Scale
 |  | Skew
 |  | Translate
In TTransformation:
 | SrcRect | ReverseTransform
 |  | Transform

See Also

ImgView and Layers Example, Rotate Example, RotLayer Example, TFloatMatrix, Transform Example


Matrix

TAffineTransformation.Matrix

Matrix: TFloatMatrix;

Description

Stores the transformation matrix. The matrix is accessed as a field instead of a property in order to make it Borland C++ Builder compatible.

See Also

TFloatMatrix


Clear

TAffineTransformation.Clear

procedure Clear;

Description

Resets the transformation (loads IdentityMatrix into the Matrix field).

See Also

IdentityMatrix, Matrix


Create

TAffineTransformation.Create

constructor Create; virtual;

Description

Creates and initializes an instance of TAffineTransformation.

Upon creation, the Matrix field is initialized to IdentityMatrix.

See Also

IdentityMatrix, Matrix, TAffineTransformation


GetTransformedBounds

TAffineTransformation.GetTransformedBounds

function GetTransformedBounds: TRect; override;

Description

Returns the bounding rectangle that surrounds the destination area affected by the transformation. The coordinates of the rectangle are specified relative to the destination bitmap origin.

See Also

TRect


Rotate

TAffineTransformation.Rotate

procedure Rotate(Cx, Cy, Alpha: Single);

Description

At first, the origin is translated to (Cx, Cy) point, then the image is rotated around the origin by Alpha degrees

and finally, the origin is shifted back.


Scale

TAffineTransformation.Scale

procedure Scale(Sx, Sy: Single);

Description

Adds scale to the transformation:


Skew

TAffineTransformation.Skew

procedure Skew(Fx, Fy: Single);

Description

Adds the skew to the transformation:


Translate

TAffineTransformation.Translate

procedure Translate(Dx, Dy: Single);

Description

Translates the image:


TProjectiveTransformation

Hierarchy

TObject

|

TTransformation

Description

This class specifies an arbitrary projective transformation. It transforms a rectangle from the source image into quadrilateral, defined by 4 points:

Note, that the destination quadrilateral has to be convex, otherwise the result is not specified.

Reference

Properties | Methods
In TProjectiveTransformation:
X0 | GetTransformedBounds
X1 |
X3 |
Y0 |
Y1 |
Y2 |
Y3 |
In TTransformation:
SrcRect | ReverseTransform
 | Transform

See Also

Transform Example


X0

TProjectiveTransformation.X0

property X0: Single;

Description

Specifies destination coordinate of the top-left point of the source rectangle.


X1

TProjectiveTransformation.X1

property X1: Single;

Description

Specifies destination coordinate of the top-right point of the source rectangle.


X3

TProjectiveTransformation.X3

property X3: Single;

Description

Specifies destination coordinate of the bottom-right point of the source rectangle.


Y0

TProjectiveTransformation.Y0

property Y0: Single;

Description

Specifies destination coordinate of the top-left point of the source rectangle.


Y1

TProjectiveTransformation.Y1

property Y0: Single;

Description

Specifies destination coordinate of the top-right point of the source rectangle.


Y2

TProjectiveTransformation.Y2

propertyY2: Single;

Description

Specifies destination coordinate of the bottom-left point of the source rectangle.


Y3

TProjectiveTransformation.Y3

property Y3: Single;

Description

Specifies destination coordinate of the bottom-right point of the source rectangle.


GetTransformedBounds

TProjectiveTransformation.GetTransformedBounds

function GetTransformedBounds: TRect; override;

Description

Returns the bounding rectangle that surrounds the destination area affected by the transformation. The coordinates of the rectangle are specified relative to the destination bitmap origin.

See Also

TRect


TTransformation

Hierarchy

TObject

Description

TTransformation is an abstract ancestor for bitmap transformation classes. TTransformation objects are passed as parameter in the Transform function, which actually performs the bitmap transformation.

Reference

Properties | Methods
In TTransformation:
SrcRect | GetTransformedBounds
 | ReverseTransform
 | Transform

See Also

TAffineTransformation, Transform, TTransformation


SrcRect

TTransformation.SrcRect

property SrcRect: TFloatRect;

Description

SrcRect specifies the boundary of the incoming image fragment.

Since it is a TFloatRect, the boundary has floating point coordinates.

See Also

TFloatRect


GetTransformedBounds

TTransformation.GetTransformedBounds

function GetTransformedBounds: TRect; virtual; abstract;

Description

Returns the bounding rectangle that surrounds the destination area affected by the transformation. The coordinates of the rectangle are specified relative to the destination bitmap origin.

See Also

TRect


ReverseTransform

TTransformation.ReverseTransform

function ReverseTransform(const P: TPoint): TPoint; overload; virtual;

function ReverseTransform(const P: TFixedPoint): TFixedPoint; overload; virtual;

function ReverseTransform(const P: TFloatPoint): TFloatPoint; overload; virtual;

Description

Reverse-transforms the supplied point P and returns the result.


Transform

TTransformation.Transform

function Transform(const P: TPoint): TPoint; overload; virtual;

function Transform(const P: TFixedPoint): TFixedPoint; overload; virtual;

function Transform(const P: TFloatPoint): TFloatPoint; overload; virtual;

Description

Transforms the supplied point P and returns the result.


BlockTransfer

procedure BlockTransfer(
Dst: TBitmap32;
DstX: Integer;
DstY: Integer;
DstClip: TRect;
Src: TBitmap32;
SrcRect: TRect;
CombineOp: TDrawMode;
CombineCallBack: TPixelCombineEvent = nil);

Description

BlockTransfer is similar to the BitBlt function from Windows GDI. It performs copying of a bitmap fragment specified by SrcRect into location (DstX, DstY) with optional alpha blending or using user-specified combining function. This operation is constrained to the DstClip rectangle specified in the destination bitmap coordinates.

If CombineOp=dmOpaque, the fragment simply replaces destination pixels. In dmBlend mode it is blended to destination using its alpha channel and MasterAlpha property. In dmCusom mode, the function calls CombineCallBack function for pixel combining.

It is not required for DstRect and SrcRect to lie entirely inside the corresponding bitmap, since the function provides necessary clipping.

The result is not specified when transferring data inside the same bitmap (Src=Dst) and if in the same time SrcRect intersects with DstRect. In this case it is recommended to use a temporary bitmap buffer.

Neither Src nor Dst bitmaps may be equal to nil. In this case, function will generate an exception. They may be empty however, in this case no transformation will be performed.

This routine used in TBitmap32.Draw and TBitmap32.DrawTo methods.

See Also

TBitmap32.Draw, TBitmap32.DrawTo, TBitmap32.MasterAlpha, StretchTransfer, TBitmap32, TDrawMode, TPixelCombineEvent, TRect


SetBorderTransparent

procedure SetBorderTransparent(ABitmap: TBitmap32; ARect: TRect);

Description

This is an auxiliary function that sets the alpha channel along the edges of specified rectangle to zero. It may be used on a bitmap before passing it to Transform function as a workarownd to the edge antialiasing problem.

See Also

TBitmap32, Transform, TRect


StretchTransfer

procedure StretchTransfer(
Dst: TBitmap32;
DstRect: TRect;
DstClip: TRect;
Src: TBitmap32;
SrcRect: TRect;
StretchFilter: TStretchFilter;
CombineOp: TDrawMode;
CombineCallBack: TPixelCombineEvent = nil);

Description

StretchTransfer is similar to StretchBlt or StretchDIBits functions from WindowsGDI. This procedure performs copying and, if necessary, stretching of the bitmap fragment specified by SrcRect into location in Dst specified by DstRect. This operation is constrained to the DstClip rectangle specified in the destination bitmap coordinates.

For more information on the stretch filters take a look here.

Unlike in BlockTransfer function, SrcRect must lie inside the Src bitmap boundaries, otherwise function will generate an exception. The result is not specified when transferring data inside the same bitmap (Src=Dst) and if in the same time SrcRect intersects with DstRect. In this case it is recommended to use a temporary bitmap buffer.

This routine used in TBitmap32.Draw and TBitmap32.DrawTo methods.

See Also

BlockTransfer, TBitmap32.Draw, TBitmap32.DrawTo, TBitmap32, TDrawMode, TPixelCombineEvent, TRect, TStretchFilter


Transform

procedure Transform(Dst, Src: TBitmap32; Transformation: TTransformation);

Description

Transform is responsible for arbitrary geometrical transformations of bitmaps or their fragments. The current version supports only affine and projective transformations.

The Transformation parameter is a reference to a descendant of an abstract TTransformation class. It specifies all necessary transformation parameters.

When Src.StretchFilter is different from sfNearest, Transform uses bilinear interpolation for magnification (along any axis) as for minification, it is not as accurate as StretchTransfer function. If you need better quality when minimizing the bitmaps, transform them into the temporary buffer so that there is no minification invlolved, then StretchTransfer to a final bitmap.

The function does not support spline interpolation, if Src.StretchFilter is sfSpline, Transform operates as if it were sfLinear.

There is an issue with antialiasing and edges. How to make them antialiased and still keep the performance? The solution implemented in Graphics32 is similar to the one used in OpenGL. You just have to provide the source bitmap (or its region) with transparent edges. In the original image, you’ll have to force the alpha channel on its edges to zeroes, for example, using the SetBorderTransparent method.

Remember, that color is interpolated as well, it means that for nice fadeout the color on the border should match the color of pixels lying next to the border.

In case the bitmap is transformed in dmOpaque mode, it might be better to keep the color on the edge close to the color of the background.

See Also

SetBorderTransparent, TBitmap32.StretchFilter, StretchTransfer, TAffineTransformation, TBitmap32, TProjectiveTransformation, Transform Example, TTransformation


TransformPoints

function TransformPoints(Points: TArrayOfArrayOfFixedPoint; Transformation: TTransformation): TArrayOfArrayOfFixedPoint;

Description

Transforms all Points using the supplied Transformation instance and returns the new set of transformed points.

See Also

TTransformation


TFloatMatrix

type TFloatMatrix = array [0..2, 0..2] of Single;

Description

A 3x3 transformation matrix used in affine transformations.

See Also

TAffineTransformation


IdentityMatrix

const IdentityMatrix: TFloatMatrix =(
(1, 0, 0),
(0, 1, 0),
(0, 0, 1));

Description

An identity matrix, which is loaded in Matrix field of TAffineTransformation class when calling its Clear method.

See Also

TAffineTransformation.Clear, TAffineTransformation.Matrix, TAffineTransformation