Unit PXL.Formats

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Information, utilities and conversion between different pixel formats.

Overview

Classes, Interfaces, Objects and Records

Name Description
record TPixelFormatColorBits Channel bit information.
record TPixelFormatDescription Complete information about specific pixel format.
record TPixelFormatHelper Extension for TPixelFormat to provide number of bits, bytes and string conversion.
Class TPixelFormatList List of one or more pixel format elements.

Functions and Procedures

function FindClosestPixelFormat(const Format: TPixelFormat; const ExistingFormats: TPixelFormatList): TPixelFormat;
function GetMatchingPixelFormat(const Description: TPixelFormatDescription): TPixelFormat;
function GetPixelFormatDescription(const Format: TPixelFormat; out Description: TPixelFormatDescription): Boolean;
procedure Pixel32ToX(const Source: TIntColor; const Dest: Pointer; const DestFormat: TPixelFormat);
procedure Pixel32ToXArray(const Source: PIntColor; const Dest: Pointer; const DestFormat: TPixelFormat; const ElementCount: Integer);
function PixelXTo32(const Source: Pointer; const SourceFormat: TPixelFormat): TIntColor;
procedure PixelXTo32Array(const Source: Pointer; const Dest: PIntColor; const SourceFormat: TPixelFormat; const ElementCount: Integer);

Types

PPixelFormatColorBits = ˆTPixelFormatColorBits;
PPixelFormatDescription = ˆTPixelFormatDescription;
TPixelFormatType = (...);

Description

Functions and Procedures

function FindClosestPixelFormat(const Format: TPixelFormat; const ExistingFormats: TPixelFormatList): TPixelFormat;

Takes a list of existing pixel formats and tries to find in it a format that closely resembles the provided format sample. The heuristics used by this function tries not to add new channels and will never return a format that has less channels than the sample; it also tries to avoid converting between different format types like integer and floating-point formats.

function GetMatchingPixelFormat(const Description: TPixelFormatDescription): TPixelFormat;

Takes the provided pixel format description and tries to find a pixel format that matches this description.

function GetPixelFormatDescription(const Format: TPixelFormat; out Description: TPixelFormatDescription): Boolean;

Provides detailed description regarding the specified pixel format. Returns True when successful and False when such information is not available (e.g. for non-standard pixel formats).

procedure Pixel32ToX(const Source: TIntColor; const Dest: Pointer; const DestFormat: TPixelFormat);

Converts a single pixel from 32-bit RGBA format (TPixelFormat.A8R8G8B8) to an arbitrary format. If the specified format is not supported, this function does nothing.

Parameters
Source
Source pixel specified in 32-bit RGBA format (TPixelFormat.A8R8G8B8).
Dest
Pointer to the memory block where the resulting pixel should be written to. This memory should be previously allocated.
DestFormat
Pixel format that is used to describe the destination pixel.
procedure Pixel32ToXArray(const Source: PIntColor; const Dest: Pointer; const DestFormat: TPixelFormat; const ElementCount: Integer);

Converts an array of pixels from 32-bit RGBA format (TPixelFormat.A8R8G8B8) to an arbitrary format. If the specified format is not supported, this function does nothing.

Parameters
Source
Pointer to a valid memory block that holds the source pixels.
Dest
Pointer to a valid memory block where destination pixels will be written to.
DestFormat
Pixel format that is used to describe the destination pixels.
Elements
The number of pixels to convert.
function PixelXTo32(const Source: Pointer; const SourceFormat: TPixelFormat): TIntColor;

Converts a single pixel from an arbitrary pixel format back to 32-bit RGBA format (TPixelFormat.A8R8G8B8). If the specified format is not supported, this function returns zero.

Parameters
Source
Pointer to a valid block of memory where the source pixel is located at.
SourceFormat
Pixel format that is used to describe the source pixel.
Returns

Resulting pixel in 32-bit RGBA format (TPixelFormat.A8R8G8B8).

procedure PixelXTo32Array(const Source: Pointer; const Dest: PIntColor; const SourceFormat: TPixelFormat; const ElementCount: Integer);

Converts an array of pixels from an arbitrary format back to 32-bit RGBA format (TPixelFormat.A8R8G8B8). If the specified format is not supported, this function does nothing.

Parameters
Source
Pointer to a valid memory block that holds the source pixels.
Dest
Pointer to a valid memory block where destination pixels will be written to.
SourceFormat
Pixel format that is used to describe the source pixels.
Elements
The number of pixels to convert.

Types

PPixelFormatColorBits = ˆTPixelFormatColorBits;

Pointer to TPixelFormatColorBits.

PPixelFormatDescription = ˆTPixelFormatDescription;

Pointer to TPixelFormatDescription.

TPixelFormatType = (...);

Classification type of pixel format.

Values
  • Normal: Typical integer pixel format (e.g. RGBA).
  • Float: Floating-point pixel format.
  • Luminance: Luminance pixel format (e.g. L8A8).
  • Indexed: Indexed (palettized) pixel format.

Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.