Changeset 9 for trunk/ColorFormats/UColorGray8.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/UColorGray8.pas
r7 r9 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 … … 28 25 function TGColorFormatGray8.GetPixelSize: Integer; 29 26 begin 30 Result := 1;27 Result := 8; 31 28 end; 32 29 … … 45 42 case Channel of 46 43 ccGray: Result := 0; 47 else raise Exception.Create('Unsupported color channel');44 else Result := 0; 48 45 end; 49 46 end; … … 56 53 end; 57 54 58 function TGColorFormatGray8.ColorToTColor(Color: TGColor): TColor;59 begin60 Result := $010101 * PByte(Color.Data + (GetChannelBitPos(ccGray) shr 3))^;61 end;62 63 procedure TGColorFormatGray8.ColorFromTColor(GColor: TGColor; Color: TColor);64 begin65 PByte(GColor.Data + (GetChannelBitPos(ccGray) shr 3))^ := ((Color and $ff) +66 ((Color shr 8) and $ff) +67 ((Color shr 16) and $ff)) div 3;68 end;69 70 function TGColorFormatGray8.GetColorClass: TGColorClass;71 begin72 Result := TGColor;73 end;74 75 55 76 56 end.
Note:
See TracChangeset
for help on using the changeset viewer.