Ignore:
Timestamp:
Sep 22, 2014, 5:40:17 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Color format properties are now initialized as variables instead by executing function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ColorFormats/UColorRGB565.pas

    r11 r14  
    66
    77uses
    8   Classes, SysUtils, Graphics, UGraphic, UMemory;
     8  Classes, SysUtils, Graphics, UGraphic;
    99
    1010type
     
    1212
    1313  TGColorFormatRGB565 = class(TGColorFormat)
    14     function GetPixelSize: Integer; override;
    15     function GetBitDepth: Integer; override;
    16     function GetName: string; override;
    17     function GetChannelBitPos(Channel: TGColorChannel): Integer; override;
    18     function GetChannelBitWidth(Channel: TGColorChannel): Integer; override;
     14    constructor Create; override;
    1915  end;
    2016
     
    2420{ TGColorFormatRGB565 }
    2521
    26 function TGColorFormatRGB565.GetPixelSize: Integer;
     22constructor TGColorFormatRGB565.Create;
    2723begin
    28   Result := 16;
    29 end;
    30 
    31 function TGColorFormatRGB565.GetBitDepth: Integer;
    32 begin
    33   Result := 16;
    34 end;
    35 
    36 function TGColorFormatRGB565.GetName: string;
    37 begin
    38   Result := 'RGB565';
    39 end;
    40 
    41 function TGColorFormatRGB565.GetChannelBitPos(Channel: TGColorChannel): Integer;
    42 begin
    43   case Channel of
    44     ccRed: Result := 0;
    45     ccGreen: Result := 5;
    46     ccBlue: Result := 11;
    47     else Result := 0;
    48   end;
    49 end;
    50 
    51 function TGColorFormatRGB565.GetChannelBitWidth(Channel: TGColorChannel
    52   ): Integer;
    53 begin
    54   case Channel of
    55     ccRed: Result := 5;
    56     ccGreen: Result := 6;
    57     ccBlue: Result := 5;
    58     else Result := 0;
    59   end;
     24  inherited Create;
     25  BitDepth := 16;
     26  Name := 'RGB565';
     27  Channels[ccRed].Position := 0;
     28  Channels[ccRed].BitWidth := 5;
     29  Channels[ccGreen].Position := 5;
     30  Channels[ccGreen].BitWidth := 6;
     31  Channels[ccBlue].Position := 9;
     32  Channels[ccBlue].BitWidth := 6;
    6033end;
    6134
Note: See TracChangeset for help on using the changeset viewer.