Ignore:
Timestamp:
Sep 21, 2014, 8:11:48 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Not TGBitmap and TGColor data are stored as TBitMemory to support color formats with lower bit width size then 8.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        22LibrePaint
        33lib
         4backup
  • trunk/ColorFormats/UColorRGBA8.pas

    r7 r9  
    66
    77uses
    8   Classes, SysUtils, Graphics, UGraphic;
     8  Classes, SysUtils, Graphics, UGraphic, UMemory;
    99
    1010type
     
    1717    function GetChannelBitPos(Channel: TGColorChannel): Integer; override;
    1818    function GetChannelBitWidth(Channel: TGColorChannel): Integer; override;
    19     function ColorToTColor(Color: TGColor): TColor; override;
    20     procedure ColorFromTColor(GColor: TGColor; Color: TColor); override;
    21     function GetColorClass: TGColorClass; override;
    2219  end;
    2320
     
    2926function TGColorFormatRGBA8.GetPixelSize: Integer;
    3027begin
    31   Result := 4;
     28  Result := 32;
    3229end;
    3330
     
    4946    ccBlue: Result := 16;
    5047    ccOpacity: Result := 24;
    51     else raise Exception.Create('Unsupported color channel');
     48    else Result := 0;
    5249  end;
    5350end;
     
    6057end;
    6158
    62 function TGColorFormatRGBA8.ColorToTColor(Color: TGColor): TColor;
    63 begin
    64   Result := PByte(Color.Data + (GetChannelBitPos(ccRed) shr 3))^ or
    65     (PByte(Color.Data + (GetChannelBitPos(ccGreen) shr 3))^ shl 8) or
    66     (PByte(Color.Data + (GetChannelBitPos(ccBlue) shr 3))^ shl 16);
    67 end;
    68 
    69 procedure TGColorFormatRGBA8.ColorFromTColor(GColor: TGColor; Color: TColor);
    70 begin
    71   PByte(GColor.Data + (GetChannelBitPos(ccRed) shr 3))^ := Color and $ff;
    72   PByte(GColor.Data + (GetChannelBitPos(ccGreen) shr 3))^ := (Color shr 8) and $ff;
    73   PByte(GColor.Data + (GetChannelBitPos(ccBlue) shr 3))^ := (Color shr 16) and $ff;
    74 end;
    75 
    76 function TGColorFormatRGBA8.GetColorClass: TGColorClass;
    77 begin
    78   Result := TGColor;
    79 end;
    80 
    81 
    8259end.
    8360
Note: See TracChangeset for help on using the changeset viewer.