Class TBGRACustomColorQuantizer
Unit
Declaration
type TBGRACustomColorQuantizer = class(TObject)
Description
Abstract class for color quantization.
Quantization is the process by which each color is reduced to an index into a palette. Surrounding pixels can affect the approximate color, an effect called dithering.
Hierarchy
- TObject
- TBGRACustomColorQuantizer
Overview
Methods
constructor Create(ABitmap: TBGRACustomBitmap; AAlpha: TAlphaChannelPaletteOption); overload; virtual; abstract; |
|
constructor Create(AColors: array of TBGRAPixel; ASeparateAlphaChannel: boolean); overload; |
|
constructor Create(APalette: TBGRACustomPalette; ASeparateAlphaChannel: boolean); overload; virtual; abstract; |
|
constructor Create(ABitmap: TBGRACustomBitmap; AAlpha: TAlphaChannelPaletteOption; AReductionColorCount: integer); overload; virtual; abstract; |
|
constructor Create(AColors: array of TBGRAPixel; ASeparateAlphaChannel: boolean; AReductionColorCount: integer); overload; |
|
constructor Create(APalette: TBGRACustomPalette; ASeparateAlphaChannel: boolean; AReductionColorCount: integer); overload; virtual; abstract; |
|
function GetDitheredBitmap(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; ABounds: TRect): TBGRACustomBitmap; overload; virtual; abstract; |
|
function GetDitheredBitmap(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap): TBGRACustomBitmap; overload; |
|
function GetDitheredBitmapIndexedData(ABitDepth: integer; AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap): Pointer; overload; |
|
function GetDitheredBitmapIndexedData(ABitDepth: integer; AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; out AScanlineSize: PtrInt): Pointer; overload; |
|
function GetDitheredBitmapIndexedData(ABitDepth: integer; AByteOrder: TRawImageByteOrder; AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; out AScanlineSize: PtrInt): Pointer; overload; virtual; abstract; |
|
function GetDominantColor: TBGRAPixel; virtual; |
|
function GetPalette: TBGRACustomApproxPalette; virtual; abstract; |
|
function GetReductionColorCount: integer; virtual; abstract; |
|
function GetSourceColor(AIndex: integer): TBGRAPixel; virtual; abstract; |
|
function GetSourceColorCount: Integer; virtual; abstract; |
|
procedure ApplyDitheringInplace(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; ABounds: TRect); overload; virtual; abstract; |
|
procedure ApplyDitheringInplace(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap); overload; |
|
procedure SaveBitmapToFile(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; AFilenameUTF8: string); overload; |
|
procedure SaveBitmapToFile(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; AFilenameUTF8: string; AFormat: TBGRAImageFormat); overload; |
|
procedure SaveBitmapToStream(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; AStream: TStream; AFormat: TBGRAImageFormat); virtual; abstract; |
|
procedure SetReductionColorCount(AValue: Integer); virtual; abstract; |
Properties
property DominantColor: TBGRAPixel read GetDominantColor; |
|
property ReducedPalette: TBGRACustomApproxPalette read GetPalette; |
|
property ReductionColorCount: Integer read GetReductionColorCount write SetReductionColorCount; |
|
property SourceColor[AIndex: integer]: TBGRAPixel read GetSourceColor; |
|
property SourceColorCount: Integer read GetSourceColorCount; |
Description
Methods
constructor Create(ABitmap: TBGRACustomBitmap; AAlpha: TAlphaChannelPaletteOption); overload; virtual; abstract; |
|
This item has no description. |
constructor Create(AColors: array of TBGRAPixel; ASeparateAlphaChannel: boolean); overload; |
|
This item has no description. |
constructor Create(APalette: TBGRACustomPalette; ASeparateAlphaChannel: boolean); overload; virtual; abstract; |
|
This item has no description. |
constructor Create(ABitmap: TBGRACustomBitmap; AAlpha: TAlphaChannelPaletteOption; AReductionColorCount: integer); overload; virtual; abstract; |
|
This item has no description. |
constructor Create(AColors: array of TBGRAPixel; ASeparateAlphaChannel: boolean; AReductionColorCount: integer); overload; |
|
This item has no description. |
constructor Create(APalette: TBGRACustomPalette; ASeparateAlphaChannel: boolean; AReductionColorCount: integer); overload; virtual; abstract; |
|
This item has no description. |
function GetDitheredBitmap(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; ABounds: TRect): TBGRACustomBitmap; overload; virtual; abstract; |
|
This item has no description. |
function GetDitheredBitmap(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap): TBGRACustomBitmap; overload; |
|
This item has no description. |
function GetDitheredBitmapIndexedData(ABitDepth: integer; AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap): Pointer; overload; |
|
This item has no description. |
function GetDitheredBitmapIndexedData(ABitDepth: integer; AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; out AScanlineSize: PtrInt): Pointer; overload; |
|
This item has no description. |
function GetDitheredBitmapIndexedData(ABitDepth: integer; AByteOrder: TRawImageByteOrder; AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; out AScanlineSize: PtrInt): Pointer; overload; virtual; abstract; |
|
This item has no description. |
function GetDominantColor: TBGRAPixel; virtual; |
|
This item has no description. |
function GetPalette: TBGRACustomApproxPalette; virtual; abstract; |
|
This item has no description. |
function GetReductionColorCount: integer; virtual; abstract; |
|
This item has no description. |
function GetSourceColor(AIndex: integer): TBGRAPixel; virtual; abstract; |
|
This item has no description. |
function GetSourceColorCount: Integer; virtual; abstract; |
|
This item has no description. |
procedure ApplyDitheringInplace(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; ABounds: TRect); overload; virtual; abstract; |
|
This item has no description. |
procedure ApplyDitheringInplace(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap); overload; |
|
This item has no description. |
procedure SaveBitmapToFile(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; AFilenameUTF8: string); overload; |
|
This item has no description. |
procedure SaveBitmapToFile(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; AFilenameUTF8: string; AFormat: TBGRAImageFormat); overload; |
|
This item has no description. |
procedure SaveBitmapToStream(AAlgorithm: TDitheringAlgorithm; ABitmap: TBGRACustomBitmap; AStream: TStream; AFormat: TBGRAImageFormat); virtual; abstract; |
|
This item has no description. |
procedure SetReductionColorCount(AValue: Integer); virtual; abstract; |
|
This item has no description. |
Properties
property DominantColor: TBGRAPixel read GetDominantColor; |
|
Colors that is the most represented in the source |
property ReducedPalette: TBGRACustomApproxPalette read GetPalette; |
|
Palette with reduced number of colors after applying quantization |
property ReductionColorCount: Integer read GetReductionColorCount write SetReductionColorCount; |
|
Number of different colors in the reduced palette.
By default, there are 256 colors. Example to reduce an image to 16 colors: uses BGRAColorQuantization, BGRABitmapTypes, BGRABitmap; var quant : TBGRAColorQuantizer; sourceBmp: TBGRABitmap; begin sourceBmp := TBGRABitmap.Create('picture.jpg'); quant := TBGRAColorQuantizer.Create(sourceBmp, acIgnore); quant.ReductionColorCount := 16; quant.SaveBitmapToFile(daFloydSteinberg, sourceBmp, 'picture_in_4_bits.bmp'); quant.Free; sourceBmp.Free; end; |
property SourceColor[AIndex: integer]: TBGRAPixel read GetSourceColor; |
|
Value of a color in the source |
property SourceColorCount: Integer read GetSourceColorCount; |
|
Number colors provided in the source |