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/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;
Note: See TracChangeset for help on using the changeset viewer.