Ignore:
Timestamp:
Oct 10, 2018, 3:48:47 PM (6 years ago)
Author:
chronos
Message:
  • Added: Mirror, Flip, Gradient, Negative for 4-bit gray image.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/FastGraphics/ColorFormats/UColorGray4.pas

    r30 r39  
    3131    procedure SetColorName(ColorName: TColorName); override;
    3232    procedure SetRandom; override;
     33    procedure SetColor(Color: TColor); override;
    3334  end;
    3435
    3536  { TBPixmapGray4 }
    3637
    37   TBPixmapGray4 = class(TBImage)
     38  TBPixmapGray4 = class(TBPixmap)
    3839  private
    3940    FillCallBack: TGetColorPos;
    4041    function FillGetColor(Position: TPoint): TColorGray4;
     42    function NegativeFunc(Position: TPoint): TColorGray4;
    4143  protected
    4244    procedure SetSize(AValue: TPoint); override;
     
    4547  public
    4648    Pixmap: TPixmapGray4;
     49    procedure Flip; override;
     50    procedure Mirror; override;
     51    procedure Negative; override;
    4752    procedure Fill(Color: IBColor); override;
    4853    procedure Fill(Func: TGetColorPos); override;
     
    7075  BitDepth := 4;
    7176  BackendColorClass := TBColorGray4;
    72   BackendImageClass := TBPixmapGray4;
     77  BackendPixmapClass := TBPixmapGray4;
    7378  AddChannel('Gray', 0, 4);
    7479end;
     
    110115end;
    111116
     117procedure TBColorGray4.SetColor(Color: TColor);
     118begin
     119  Value := ((Color shr 0) and $ff + (Color shr 8) and $ff + (Color shr 16) and $ff) div (3 * 16);
     120end;
     121
    112122{ TBPixmapGray2 }
    113123
     
    115125begin
    116126  Result := (FillCallBack(Position) as TBColorGray4).Value;
     127end;
     128
     129function TBPixmapGray4.NegativeFunc(Position: TPoint): TColorGray4;
     130var
     131  C: TColorGray4;
     132begin
     133  C := Pixmap.Pixels[Position.X, Position.Y];
     134  Result := 16 - (C and $f);
    117135end;
    118136
     
    131149begin
    132150  Pixmap.Pixels[X, Y] := (AValue as TBColorGray4).Value;
     151end;
     152
     153procedure TBPixmapGray4.Flip;
     154begin
     155  Pixmap.Flip;
     156end;
     157
     158procedure TBPixmapGray4.Mirror;
     159begin
     160  Pixmap.Mirror;
     161end;
     162
     163procedure TBPixmapGray4.Negative;
     164begin
     165  Pixmap.Fill(NegativeFunc);
    133166end;
    134167
Note: See TracChangeset for help on using the changeset viewer.