BGRABitmap Miscellaneous types
From Free Pascal wiki
Jump to navigationJump to searchMiscellaneous types in BGRABitmap. They are provided by BGRABitmapTypes unit.
Miscellaneous types
TFloodfillMode = ( | ||
Options when doing a floodfill (also called bucket fill) | ||
fmSet, | ||
Pixels that are filled are replaced | ||
fmDrawWithTransparency, | ||
Pixels that are filled are drawn upon with the fill color | ||
fmProgressive); | ||
Pixels that are filled are drawn upon to the extent that the color underneath is similar to the start color. The more different the different is, the less it is drawn upon | ||
TMedianOption = (moNone, moLowSmooth, moMediumSmooth, moHighSmooth); | ||
Specifies how much smoothing is applied to the computation of the median | ||
TRadialBlurType = ( | ||
Specifies the shape of a predefined blur | ||
rbNormal, | ||
Gaussian-like, pixel importance decreases progressively | ||
rbDisk, | ||
Disk blur, pixel importance does not decrease progressively | ||
rbCorona, | ||
Pixel are considered when they are at a certain distance | ||
rbPrecise, | ||
Gaussian-like, but 10 times smaller than rbNormal | ||
rbFast, | ||
Gaussian-like but simplified to be computed faster | ||
rbBox); | ||
Box blur, pixel importance does not decrease progressively and the pixels are included when they are in a square. This is much faster than rbFast however you may get square shapes in the resulting image | ||
Imported from GraphType
TRawImageLineOrder = ( | ||
Order of the lines in an image | ||
riloTopToBottom, | ||
The first line in memory (line 0) is the top line | ||
riloBottomToTop); | ||
The first line in memory (line 0) is the bottom line | ||
TRawImageBitOrder = ( | ||
Order of the bits in a byte containing pixel values | ||
riboBitsInOrder, | ||
The lowest bit is on the left. So with a monochrome picture, bit 0 would be pixel 0 | ||
riboReversedBits); | ||
The lowest bit is on the right. So with a momochrome picture, bit 0 would be pixel 7 (bit 1 would be pixel 6, ...) | ||
TRawImageByteOrder = ( | ||
Order of the bytes in a group of byte containing pixel values | ||
riboLSBFirst, | ||
Least significant byte first (little endian) | ||
riboMSBFirst); | ||
most significant byte first (big endian) | ||
TGraphicsBevelCut = | ||
Definition of a single line 3D bevel | ||
bvNone, | ||
No bevel | ||
bvLowered, | ||
Shape is lowered, light is on the bottom-right corner | ||
bvRaised, | ||
Shape is raised, light is on the top-left corner | ||
bvSpace); | ||
Shape is at the same level, there is no particular lighting | ||
Integer math
function PositiveMod(value, cycle: Int32or64): Int32or64; inline; overload; | ||
Computes the value modulo cycle, and if the value is negative, the result is still positive | ||
function Sin65536(value: word): Int32or64; inline; | ||
Returns an integer approximation of the sine. Value ranges from 0 to 65535, where 65536 corresponds to the next cycle | ||
function Cos65536(value: word): Int32or64; inline; | ||
Returns an integer approximation of the cosine. Value ranges from 0 to 65535, where 65536 corresponds to the next cycle | ||
function ByteSqrt(value: byte): byte; inline; | ||
Returns the square root of the given byte, considering that 255 is equal to unity | ||
Types provided for fonts
TBGRAFontQuality = ( | ||
Quality to be used to render text | ||
fqSystem, | ||
Use the system capabilities. It is rather fast however it may be not be smoothed. | ||
fqSystemClearType, | ||
Use the system capabilities to render with ClearType. This quality is of course better than fqSystem however it may not be perfect. | ||
fqFineAntialiasing, | ||
Garanties a high quality antialiasing. | ||
fqFineClearTypeRGB, | ||
Fine antialiasing with ClearType in assuming an LCD display in red/green/blue order | ||
fqFineClearTypeBGR); | ||
Fine antialiasing with ClearType in assuming an LCD display in blue/green/red order | ||
TFontPixelMetric = record | ||
Measurements of a font | ||
Defined: boolean; | ||
The values have been computed | ||
Baseline, | ||
Position of the baseline, where most letters lie | ||
xLine, | ||
Position of the top of the small letters (x being one of them) | ||
CapLine, | ||
Position of the top of the UPPERCASE letters | ||
DescentLine, | ||
Position of the bottom of letters like g and p | ||
Lineheight: integer; | ||
Total line height including line spacing defined by the font | ||
TFontVerticalAnchor = ( | ||
Vertical anchoring of the font. When text is drawn, a start coordinate is necessary. Text can be positioned in different ways. This enum defines what position it is regarding the font | ||
fvaTop, | ||
The top of the font. Everything will be drawn below the start coordinate. | ||
fvaCenter, | ||
The center of the font | ||
fvaCapLine, | ||
The top of capital letters | ||
fvaCapCenter, | ||
The center of capital letters | ||
fvaXLine, | ||
The top of small letters | ||
fvaXCenter, | ||
The center of small letters | ||
fvaBaseline, | ||
The baseline, the bottom of most letters | ||
fvaDescentLine, | ||
The bottom of letters that go below the baseline | ||
fvaBottom); | ||
The bottom of the font. Everything will be drawn above the start coordinate | ||
TWordBreakHandler = procedure(var ABeforeUTF8, AAfterUTF8: string) of object; | ||
Definition of a function that handles work-break | ||
TBGRATypeWriterAlignment = (twaTopLeft, twaTop, twaTopRight, twaLeft, twaMiddle, twaRight, twaBottomLeft, twaBottom, twaBottomRight); | ||
Alignment for a typewriter, that does not have any more information than a square shape containing glyphs | ||
TBGRATypeWriterOutlineMode = (twoPath, twoFill, twoStroke, twoFillOverStroke, twoStrokeOverFill, twoFillThenStroke, twoStrokeThenFill); | ||
How a typewriter must render its content on a Canvas2d | ||
TBGRACustomFontRenderer = class | ||
Abstract class for all font renderers | ||
FontName: string; | ||
Specifies the font to use. Unless the font renderer accept otherwise, the name is in human readable form, like 'Arial', 'Times New Roman', ... | ||
FontStyle: TFontStyles; | ||
Specifies the set of styles to be applied to the font. These can be fsBold, fsItalic, fsStrikeOut, fsUnderline. So the value [fsBold,fsItalic] means that the font must be bold and italic | ||
FontQuality : TBGRAFontQuality; | ||
Specifies the quality of rendering. Default value is fqSystem | ||
FontOrientation: integer; | ||
Specifies the rotation of the text, for functions that support text rotation. It is expressed in tenth of degrees, positive values going counter-clockwise | ||
FontEmHeight: integer; | ||
Specifies the height of the font without taking into account additional line spacing. A negative value means that it is the full height instead | ||
function GetFontPixelMetric: TFontPixelMetric; virtual; abstract; | ||
Returns measurement for the current font in pixels | ||
function TextSize(sUTF8: string): TSize; virtual; abstract; | ||
Returns the total size of the string provided using the current font. Orientation is not taken into account, so that the width is along the text | ||
procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment); virtual; abstract; | ||
Draws the UTF8 encoded string, with color c. If align is taLeftJustify, (x,y) is the top-left corner. If align is taCenter, (x,y) is at the top and middle of the text. If align is taRightJustify, (x,y) is the top-right corner. The value of FontOrientation is taken into account, so that the text may be rotated | ||
procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment); virtual; abstract; | ||
Same as above functions, except that the text is filled using texture. The value of FontOrientation is taken into account, so that the text may be rotated | ||
procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment); virtual; abstract; | ||
Same as above, except that the orientation is specified, overriding the value of the property FontOrientation | ||
procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientationTenthDegCCW: integer; sUTF8: string; texture: IBGRAScanner; align: TAlignment); virtual; abstract; | ||
Same as above, except that the orientation is specified, overriding the value of the property FontOrientation | ||
procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; c: TBGRAPixel); virtual; abstract; | ||
Draw the UTF8 encoded string at the coordinate (x,y), clipped inside the rectangle ARect. Additional style information is provided by the style parameter. The color c is used to fill the text. No rotation is applied. | ||
procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; texture: IBGRAScanner); virtual; abstract; | ||
Same as above except a texture is used to fill the text | ||
procedure CopyTextPathTo({%H-}ADest: IBGRAPath; {%H-}x, {%H-}y: single; {%H-}s: string; {%H-}align: TAlignment); virtual; //optional | ||
Copy the path for the UTF8 encoded string into ADest. If align is taLeftJustify, (x,y) is the top-left corner. If align is taCenter, (x,y) is at the top and middle of the text. If align is taRightJustify, (x,y) is the top-right corner. | ||
TBGRATextOutImproveReadabilityMode = (irMask, irNormal, irClearTypeRGB, irClearTypeBGR); | ||
Output mode for the improved renderer for readability. This is used by the font renderer based on LCL in BGRAText | ||
function CleanTextOutString(s: string): string; | ||
Removes line ending and tab characters from a string (for a function like TextOut that does not handle this). this works with UTF8 strings as well | ||
function RemoveLineEnding(var s: string; indexByte: integer): boolean; | ||
Remove the line ending at the specified position or return False. This works with UTF8 strings however the index is the byte index | ||
function RemoveLineEndingUTF8(var sUTF8: string; indexUTF8: integer): boolean; | ||
Remove the line ending at the specified position or return False. The index is the character index, that may be different from the byte index | ||
procedure BGRADefaultWordBreakHandler(var ABefore, AAfter: string); | ||
Default word break handler, that simply divide when there is a space | ||
Images and resampling
TResampleMode = ( | ||
How the resample is to be computed | ||
rmSimpleStretch, | ||
Low quality resample by repeating pixels, stretching them | ||
rmFineResample); | ||
Use resample filters. This gives high quality resampling however this the proportion changes slightly because the first and last pixel are considered to occupy only half a unit as they are considered as the border of the picture (pixel-centered coordinates) | ||
TResampleFilter = ( | ||
List of resample filter to be used with rmFineResample | ||
rfBox, | ||
Equivalent of simple stretch with high quality and pixel-centered coordinates | ||
rfLinear, | ||
Linear interpolation giving slow transition between pixels | ||
rfHalfCosine, | ||
Mix of rfLinear and rfCosine giving medium speed stransition between pixels | ||
rfCosine, | ||
Cosine-like interpolation giving fast transition between pixels | ||
rfBicubic, | ||
Simple bi-cubic filter (blurry) | ||
rfMitchell, | ||
Mitchell filter, good for downsizing interpolation | ||
rfSpline, | ||
Spline filter, good for upsizing interpolation, however slightly blurry | ||
rfLanczos2, | ||
Lanczos with radius 2, blur is corrected | ||
rfLanczos3, | ||
Lanczos with radius 3, high contrast | ||
rfLanczos4, | ||
Lanczos with radius 4, high contrast | ||
rfBestQuality); | ||
Best quality using rfMitchell or rfSpline | ||
ResampleFilterStr : array[TResampleFilter] of string = | ||
List of strings to represent resample filters | ||
function StrToResampleFilter(str: string): TResampleFilter; | ||
Gives the sample filter represented by a string | ||
TBGRAImageFormat = ( | ||
List of image formats | ||
ifUnknown, | ||
Unknown format | ||
ifJpeg, | ||
JPEG format, opaque, lossy compression | ||
ifPng, | ||
PNG format, transparency, lossless compression | ||
ifGif, | ||
GIF format, single transparent color, lossless in theory but only low number of colors allowed | ||
ifBmp, | ||
BMP format, transparency, no compression. Note that transparency is not supported by all BMP readers so it is not recommended to avoid storing images with transparency in this format | ||
ifIco, | ||
ICO format, contains different sizes of the same image | ||
ifPcx, | ||
PCX format, opaque, rudimentary lossless compression | ||
ifPaintDotNet, | ||
Paint.NET format, layers, lossless compression | ||
ifLazPaint, | ||
LazPaint format, layers, lossless compression | ||
ifOpenRaster, | ||
OpenRaster format, layers, lossless compression | ||
ifPsd, | ||
Photoshop format, layers, rudimentary lossless compression | ||
ifTarga, | ||
Targa format (TGA), transparency, rudimentary lossless compression | ||
ifTiff, | ||
TIFF format, limited support | ||
ifXwd, | ||
X-Window capture, limited support | ||
ifXPixMap, | ||
X-Pixmap, text encoded image, limited support | ||
ifBmpMioMap); | ||
iGO BMP, limited support | ||
DefaultBGRAImageReader: array[TBGRAImageFormat] of TFPCustomImageReaderClass; | ||
List of stream readers for images | ||
DefaultBGRAImageWriter: array[TBGRAImageFormat] of TFPCustomImageWriterClass; | ||
List of stream writers for images | ||
function DetectFileFormat(AFilenameUTF8: string): TBGRAImageFormat; | ||
Detect the file format of a given file | ||
function DetectFileFormat(AStream: TStream; ASuggestedExtensionUTF8: string = ): TBGRAImageFormat; | ||
Detect the file format of a given stream. ASuggestedExtensionUTF8 can be provided to guess the format | ||
function SuggestImageFormat(AFilenameOrExtensionUTF8: string): TBGRAImageFormat; | ||
Returns the file format that is most likely to be stored in the given filename (according to its extension) | ||
function SuggestImageExtension(AFormat: TBGRAImageFormat): string; | ||
Returns a likely image extension for the format | ||
function CreateBGRAImageReader(AFormat: TBGRAImageFormat): TFPCustomImageReader; | ||
Create an image reader for the given format | ||
function CreateBGRAImageWriter(AFormat: TBGRAImageFormat; AHasTransparentPixels: boolean): TFPCustomImageWriter; | ||
Create an image writer for the given format. AHasTransparentPixels specifies if alpha channel must be supported | ||