Changeset 39 for trunk


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.
Location:
trunk
Files:
6 edited

Legend:

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

    r32 r39  
    3636  { TBPixmapGray1 }
    3737
    38   TBPixmapGray1 = class(TBImage)
     38  TBPixmapGray1 = class(TBPixmap)
    3939  private
    4040    FillCallBack: TGetColorPos;
     
    7373  BitDepth := 1;
    7474  BackendColorClass := TBColorGray1;
    75   BackendImageClass := TBPixmapGray1;
     75  BackendPixmapClass := TBPixmapGray1;
    7676  AddChannel('Gray', 0, 1);
    7777end;
  • trunk/Packages/FastGraphics/ColorFormats/UColorGray2.pas

    r30 r39  
    3535  { TBPixmapGray2 }
    3636
    37   TBPixmapGray2 = class(TBImage)
     37  TBPixmapGray2 = class(TBPixmap)
    3838  private
    3939    FillCallBack: TGetColorPos;
     
    7171  BitDepth := 2;
    7272  BackendColorClass := TBColorGray2;
    73   BackendImageClass := TBPixmapGray2;
     73  BackendPixmapClass := TBPixmapGray2;
    7474  AddChannel('Gray', 0, 2);
    7575end;
  • 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
  • trunk/Packages/FastGraphics/ColorFormats/UColorRGB8.pas

    r36 r39  
    4343  { TBPixmapRGB8 }
    4444
    45   TBPixmapRGB8 = class(TBImage)
     45  TBPixmapRGB8 = class(TBPixmap)
    4646  private
    4747    FillCallBack: TGetColorPos;
     
    8181  BitDepth := 24;
    8282  Name := 'RGB8';
    83   BackendImageClass := TBPixmapRGB8;
     83  BackendPixmapClass := TBPixmapRGB8;
    8484  BackendColorClass := TBColorRGB8;
    8585  AddChannel('Red', 0, 8);
  • trunk/Packages/FastGraphics/UFGraphics.pas

    r36 r39  
    2727  IBColorClass = class of TBColor;
    2828
    29   { TBImage }
    30 
    31   TBImage = class
     29  { TBPixmap }
     30
     31  TBPixmap = class
    3232  public
    3333    type
     
    5757  end;
    5858
    59   TBPixmapClass = class of TBImage;
     59  TBPixmapClass = class of TBPixmap;
    6060
    6161  { TColorFormatChannel }
     
    7474    Channels: array of TColorFormatChannel;
    7575    BackendColorClass: IBColorClass;
    76     BackendImageClass: TBPixmapClass;
     76    BackendPixmapClass: TBPixmapClass;
    7777    procedure AddChannel(Name: string; Position, BitWidth: Integer);
    7878    function GetBackendColor: IBColor;
    79     function GetBackendImage: TBImage;
     79    function GetBackendImage: TBPixmap;
    8080    constructor Create; virtual;
    8181    function GetChannelStateCount(Channel: Integer): Integer;
     
    117117    procedure SetColorName(ColorName: TColorName);
    118118    procedure SetRandom;
     119    procedure SetColor(Color: TColor);
    119120    constructor Create; overload;
    120121    constructor Create(ColorFormat: TColorFormat; ColorName: TColorName); overload;
     
    161162      TGetColorPos = function (Position: TPoint; ColorFormat: TColorFormat): IFColor of object;
    162163  private
    163     FBackend: TBImage;
     164    FBackend: TBPixmap;
    164165    FCanvas: TFCanvas;
    165166    FColorFormat: TColorFormat;
     
    190191    destructor Destroy; override;
    191192    property Canvas: TFCanvas read FCanvas;
    192     property Backend: TBImage read FBackend;
     193    property Backend: TBPixmap read FBackend;
    193194    property ColorFormat: TColorFormat read FColorFormat write SetColorFormat;
    194195    property Size: TPoint read FSize write SetSize;
     
    313314end;
    314315
    315 function TColorFormat.GetBackendImage: TBImage;
    316 begin
    317   Result := BackendImageClass.Create;
     316function TColorFormat.GetBackendImage: TBPixmap;
     317begin
     318  Result := BackendPixmapClass.Create;
    318319end;
    319320
     
    323324  BitDepth := 0;
    324325  BackendColorClass := TBColor;
    325   BackendImageClass := TBImage;
     326  BackendPixmapClass := TBPixmap;
    326327end;
    327328
     
    350351end;
    351352
     353procedure TFColor.SetColor(Color: TColor);
     354begin
     355  Backend.SetColor(Color);
     356end;
     357
    352358constructor TFColor.Create;
    353359begin
     
    373379end;
    374380
    375 { TBImage }
    376 
    377 function TBImage.GetPixel(X, Y: Integer): IBColor;
     381{ TBPixmap }
     382
     383function TBPixmap.GetPixel(X, Y: Integer): IBColor;
    378384begin
    379385  Result := TBColor.Create;
    380386end;
    381387
    382 procedure TBImage.SetPixel(X, Y: Integer; AValue: IBColor);
    383 begin
    384 end;
    385 
    386 procedure TBImage.SetSize(AValue: TPoint);
     388procedure TBPixmap.SetPixel(X, Y: Integer; AValue: IBColor);
     389begin
     390end;
     391
     392procedure TBPixmap.SetSize(AValue: TPoint);
    387393begin
    388394  if (FSize.X = AValue.X) and (FSize.Y = AValue.Y) then Exit;
     
    390396end;
    391397
    392 procedure TBImage.Mirror;
    393 begin
    394 end;
    395 
    396 procedure TBImage.Flip;
    397 begin
    398 end;
    399 
    400 procedure TBImage.Negative;
    401 begin
    402 end;
    403 
    404 procedure TBImage.Fill(Color: IBColor);
    405 begin
    406 end;
    407 
    408 procedure TBImage.Fill(Func: TGetColorPos);
    409 begin
    410 end;
    411 
    412 procedure TBImage.Line(P1, P2: TPoint; Color: IBColor);
    413 begin
    414 end;
    415 
    416 procedure TBImage.PaintToCanvas(Canvas: TCanvas);
    417 begin
    418 end;
    419 
    420 procedure TBImage.PaintToCanvas(Canvas: TCanvas; Rect: TRect);
    421 begin
    422 end;
    423 
    424 procedure TBImage.PaintToBitmap(Bitmap: TBitmap; Rect: TRect);
    425 begin
    426 end;
    427 
    428 procedure TBImage.LoadFromCanvas(Canvas: TCanvas);
    429 begin
    430 end;
    431 
    432 procedure TBImage.LoadFromBitmap(Bitmap: TBitmap);
    433 begin
    434 end;
    435 
    436 function TBImage.GetDataSize: Integer;
     398procedure TBPixmap.Mirror;
     399begin
     400end;
     401
     402procedure TBPixmap.Flip;
     403begin
     404end;
     405
     406procedure TBPixmap.Negative;
     407begin
     408end;
     409
     410procedure TBPixmap.Fill(Color: IBColor);
     411begin
     412end;
     413
     414procedure TBPixmap.Fill(Func: TGetColorPos);
     415begin
     416end;
     417
     418procedure TBPixmap.Line(P1, P2: TPoint; Color: IBColor);
     419begin
     420end;
     421
     422procedure TBPixmap.PaintToCanvas(Canvas: TCanvas);
     423begin
     424end;
     425
     426procedure TBPixmap.PaintToCanvas(Canvas: TCanvas; Rect: TRect);
     427begin
     428end;
     429
     430procedure TBPixmap.PaintToBitmap(Bitmap: TBitmap; Rect: TRect);
     431begin
     432end;
     433
     434procedure TBPixmap.LoadFromCanvas(Canvas: TCanvas);
     435begin
     436end;
     437
     438procedure TBPixmap.LoadFromBitmap(Bitmap: TBitmap);
     439begin
     440end;
     441
     442function TBPixmap.GetDataSize: Integer;
    437443begin
    438444  Result := 0;
    439445end;
    440446
    441 constructor TBImage.Create;
     447constructor TBPixmap.Create;
    442448begin
    443449  Size := Point(0, 0);
     
    503509
    504510procedure TFPixmap.Gradient;
    505 begin
    506 
     511var
     512  X, Y: Integer;
     513  Color: IFColor;
     514begin
     515  Color := TFColor.Create;
     516  (Color as TFColor).ColorFormat := ColorFormat;
     517  for Y := 0 to Size.Y div 4 - 1 do
     518    for X := 0 to Size.X - 1 do begin
     519      (Color as TFColor).SetColor(RGBToColor(
     520        Trunc(X / Size.X * 256),
     521        0,
     522        0
     523      ));
     524      Pixels[X, Y] := Color;
     525    end;
     526  for Y := Size.Y div 4 to 2 * Size.Y div 4 - 1 do
     527    for X := 0 to Size.X - 1 do begin
     528      (Color as TFColor).SetColor(RGBToColor(
     529        0,
     530        Trunc(X / Size.X * 256),
     531        0
     532      ));
     533      Pixels[X, Y] := Color;
     534    end;
     535  for Y := 2 * Size.Y div 4 to 3 * Size.Y div 4 - 1 do
     536    for X := 0 to Size.X - 1 do begin
     537      (Color as TFColor).SetColor(RGBToColor(
     538        0,
     539        0,
     540        Trunc(X / Size.X * 256)
     541      ));
     542      Pixels[X, Y] := Color;
     543    end;
     544  for Y := 3 * Size.Y div 4 to Size.Y - 1 do
     545    for X := 0 to Size.X - 1 do begin
     546      (Color as TFColor).SetColor(RGBToColor(
     547        Trunc(X / Size.X * 256),
     548        Trunc(X / Size.X * 256),
     549        Trunc(X / Size.X * 256)
     550      ));
     551      Pixels[X, Y] := Color;
     552    end;
    507553end;
    508554
     
    561607begin
    562608  inherited;
    563   FBackend := TBImage.Create;
     609  FBackend := TBPixmap.Create;
    564610  FCanvas := TFCanvas.Create;
    565611  FCanvas.Pixmap := Self;
  • trunk/UCore.pas

    r38 r39  
    8585
    8686uses
    87   UFormNew, UFormMain, Forms, UColorRGBA8, UColorGray8, UColorGray1, UColorGray4,
    88   UColorRGB565, UFormSettings;
     87  UFormNew, UFormMain, Forms, UFormSettings;
    8988
    9089{ TCore }
Note: See TracChangeset for help on using the changeset viewer.