Changeset 7 for trunk/ColorFormats/UColorRGBA8.pas
- Timestamp:
- Sep 19, 2014, 9:25:56 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ColorFormats/UColorRGBA8.pas
r4 r7 15 15 function GetBitDepth: Integer; override; 16 16 function GetName: string; override; 17 function GetChannelB ytePos(Channel: TGColorChannel): Integer; override;17 function GetChannelBitPos(Channel: TGColorChannel): Integer; override; 18 18 function GetChannelBitWidth(Channel: TGColorChannel): Integer; override; 19 19 function ColorToTColor(Color: TGColor): TColor; override; … … 42 42 end; 43 43 44 function TGColorFormatRGBA8.GetChannelB ytePos(Channel: TGColorChannel): Integer;44 function TGColorFormatRGBA8.GetChannelBitPos(Channel: TGColorChannel): Integer; 45 45 begin 46 46 case Channel of 47 47 ccRed: Result := 0; 48 ccGreen: Result := 1;49 ccBlue: Result := 2;50 ccOpacity: Result := 3;48 ccGreen: Result := 8; 49 ccBlue: Result := 16; 50 ccOpacity: Result := 24; 51 51 else raise Exception.Create('Unsupported color channel'); 52 52 end; … … 62 62 function TGColorFormatRGBA8.ColorToTColor(Color: TGColor): TColor; 63 63 begin 64 Result := PByte(Color.Data + GetChannelBytePos(ccRed))^ or65 (PByte(Color.Data + GetChannelBytePos(ccGreen))^ shl 8) or66 (PByte(Color.Data + GetChannelBytePos(ccBlue))^ shl 16);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 67 end; 68 68 69 69 procedure TGColorFormatRGBA8.ColorFromTColor(GColor: TGColor; Color: TColor); 70 70 begin 71 PByte(GColor.Data + GetChannelBytePos(ccRed))^ := Color and $ff;72 PByte(GColor.Data + GetChannelBytePos(ccGreen))^ := (Color shr 8) and $ff;73 PByte(GColor.Data + GetChannelBytePos(ccBlue))^ := (Color shr 16) and $ff;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 74 end; 75 75
Note:
See TracChangeset
for help on using the changeset viewer.