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/UColorRGBA8.pas

    r9 r14  
    1212
    1313  TGColorFormatRGBA8 = 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{ TGColorFormatRGBA8 }
    2521
    26 function TGColorFormatRGBA8.GetPixelSize: Integer;
     22constructor TGColorFormatRGBA8.Create;
    2723begin
    28   Result := 32;
    29 end;
    30 
    31 function TGColorFormatRGBA8.GetBitDepth: Integer;
    32 begin
    33   Result := 32;
    34 end;
    35 
    36 function TGColorFormatRGBA8.GetName: string;
    37 begin
    38   Result := 'RGBA8';
    39 end;
    40 
    41 function TGColorFormatRGBA8.GetChannelBitPos(Channel: TGColorChannel): Integer;
    42 begin
    43   case Channel of
    44     ccRed: Result := 0;
    45     ccGreen: Result := 8;
    46     ccBlue: Result := 16;
    47     ccOpacity: Result := 24;
    48     else Result := 0;
    49   end;
    50 end;
    51 
    52 function TGColorFormatRGBA8.GetChannelBitWidth(Channel: TGColorChannel
    53   ): Integer;
    54 begin
    55   if (Channel = ccBlue) or (Channel = ccRed) or (Channel = ccGreen) then
    56     Result := 8 else Result := 0;
     24  inherited Create;
     25  BitDepth := 32;
     26  Name := 'RGBA8';
     27  Channels[ccRed].Position := 0;
     28  Channels[ccRed].BitWidth := 8;
     29  Channels[ccGreen].Position := 8;
     30  Channels[ccGreen].BitWidth := 8;
     31  Channels[ccBlue].Position := 16;
     32  Channels[ccBlue].BitWidth := 8;
     33  Channels[ccOpacity].Position := 24;
     34  Channels[ccOpacity].BitWidth := 8;
    5735end;
    5836
Note: See TracChangeset for help on using the changeset viewer.