Packed Record TGSBAPixel

Hierarchy
Properties

Unit

Declaration

type TGSBAPixel = packed record

Description

Pixel color defined in corrected HSL colorspace.

G stands for corrected hue and B stands for actual brightness. Values range from 0 to 65535.

See THSLAPixel for this colorspace without hue and brightness correction.

Example of drawing a gradient in GSB colorspace:

gsbapixel_gradient

procedure TForm1.FormPaint(Sender: TObject);
var x,y: integer;
    p: PBGRAPixel;
    image: TBGRABitmap;
    gsba: TGSBAPixel;
begin
  image := TBGRABitmap.Create(ClientWidth,ClientHeight);
  gsba.lightness := 32768;
  gsba.alpha := 65535;
  for y := 0 to image.Height-1 do
  begin
    p := image.Scanline[y];
    gsba.saturation := y*65536 div image.Height;
    for x := 0 to image.Width-1 do
    begin
      gsba.hue := x*65536 div image.Width;
      pˆ:= GSBAToBGRA(gsba);
      inc(p);
    end;
  end;
  image.InvalidateBitmap; // changed by direct access

  image.Draw(Canvas,0,0,True);
  image.free;
end;

Overview

Fields

Public hue: word;
Public saturation: word;
Public lightness: word;
Public alpha: word;

Methods

Public class function New(const AHue,ASaturation,ABrightness:word): TGSBAPixel; overload; static;
Public class function New(const AHue,ASaturation,ABrightness,AAlpha:word): TGSBAPixel; overload; static;

Description

Fields

Public hue: word;

Corrected hue of the pixel. Extremum values 0 and 65535 are red. G is corrected in the sense that each segment does not have the same size. green-cyan and violet-red ranges are shorter, while red-yellow and cyan-blue are wider.

Public saturation: word;

Saturation of the color. 0 is gray and 65535 is the brightest color (excluding white). Given a certain lightness, it is not always possible to have the full saturation of the color.

Public lightness: word;

Actual perceived brightness. 0 is black, 32768 is normal, and 65535 is white. At 32768, depending on the hue, contrary to THSLAPixel, the color may or may not be mixed with black/white. Blue colors have a lower brightness and thus the full saturation is achieved under 32768. Conversely yellow colors have higher brightness and thus the full saturation is achieved over 32768.

Public alpha: word;

Opacity of the pixel. 0 is transparent and 65535 is opaque

Methods

Public class function New(const AHue,ASaturation,ABrightness:word): TGSBAPixel; overload; static;

This item has no description.

Public class function New(const AHue,ASaturation,ABrightness,AAlpha:word): TGSBAPixel; overload; static;

This item has no description.