Changeset 9 for trunk/ColorFormats/UColorRGBA8.pas
- Timestamp:
- Sep 21, 2014, 8:11:48 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 2 2 LibrePaint 3 3 lib 4 backup
-
- Property svn:ignore
-
trunk/ColorFormats/UColorRGBA8.pas
r7 r9 6 6 7 7 uses 8 Classes, SysUtils, Graphics, UGraphic ;8 Classes, SysUtils, Graphics, UGraphic, UMemory; 9 9 10 10 type … … 17 17 function GetChannelBitPos(Channel: TGColorChannel): Integer; override; 18 18 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;22 19 end; 23 20 … … 29 26 function TGColorFormatRGBA8.GetPixelSize: Integer; 30 27 begin 31 Result := 4;28 Result := 32; 32 29 end; 33 30 … … 49 46 ccBlue: Result := 16; 50 47 ccOpacity: Result := 24; 51 else raise Exception.Create('Unsupported color channel');48 else Result := 0; 52 49 end; 53 50 end; … … 60 57 end; 61 58 62 function TGColorFormatRGBA8.ColorToTColor(Color: TGColor): TColor;63 begin64 Result := PByte(Color.Data + (GetChannelBitPos(ccRed) shr 3))^ or65 (PByte(Color.Data + (GetChannelBitPos(ccGreen) shr 3))^ shl 8) or66 (PByte(Color.Data + (GetChannelBitPos(ccBlue) shr 3))^ shl 16);67 end;68 69 procedure TGColorFormatRGBA8.ColorFromTColor(GColor: TGColor; Color: TColor);70 begin71 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 begin78 Result := TGColor;79 end;80 81 82 59 end. 83 60
Note:
See TracChangeset
for help on using the changeset viewer.