Changeset 31 for trunk/Packages


Ignore:
Timestamp:
Jan 4, 2017, 11:49:56 PM (8 years ago)
Author:
chronos
Message:
  • Added: Pen tool to draw pixels by mouse with selected color.
  • Added: Mirror and Flip image operation.
Location:
trunk/Packages/FastGraphics
Files:
3 edited

Legend:

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

    r29 r31  
    3737    constructor Create(Color: TColorRGB8);
    3838    procedure SetColorName(ColorName: TColorName); override;
     39    procedure SetColor(Color: TColor); override;
    3940    procedure SetRandom; override;
    4041  end;
     
    4748    function FillGetColor(Position: TPoint): TColorRGB8;
    4849  protected
     50    function GetPixel(X, Y: Integer): IBColor;  override;
     51    procedure SetPixel(X, Y: Integer; AValue: IBColor); override;
    4952    procedure SetSize(AValue: TPoint); override;
    5053  public
    5154    Pixmap: TPixmapRGB8;
     55    procedure Mirror; override;
     56    procedure Flip; override;
    5257    procedure Fill(Color: IBColor); override;
    5358    procedure Fill(Func: TGetColorPos); override;
     
    121126end;
    122127
     128procedure TBColorRGB8.SetColor(Color: TColor);
     129begin
     130  Value := TColorRGB8.Create((Color shr 0) and $ff, (Color shr 8) and $ff, (Color shr 16) and $ff);
     131end;
     132
    123133procedure TBColorRGB8.SetRandom;
    124134begin
     
    131141begin
    132142  Result := (FillCallBack(Position) as TBColorRGB8).Value;
     143end;
     144
     145function TBPixmapRGB8.GetPixel(X, Y: Integer): IBColor;
     146begin
     147  Result := TBColorRGB8.Create(Pixmap.Pixels[X, Y]);
     148end;
     149
     150procedure TBPixmapRGB8.SetPixel(X, Y: Integer; AValue: IBColor);
     151begin
     152  Pixmap.Pixels[X, Y] := (AValue as TBColorRGB8).Value;
    133153end;
    134154
     
    139159end;
    140160
     161procedure TBPixmapRGB8.Mirror;
     162begin
     163  Pixmap.Mirror;
     164end;
     165
     166procedure TBPixmapRGB8.Flip;
     167begin
     168  Pixmap.Flip;
     169end;
     170
    141171procedure TBPixmapRGB8.Fill(Color: IBColor);
    142172begin
  • trunk/Packages/FastGraphics/UFGraphics.pas

    r29 r31  
    1313  IBColor = interface
    1414    procedure SetColorName(ColorName: TColorName);
     15    procedure SetColor(Color: TColor);
    1516    procedure SetRandom;
    1617  end;
     
    2021  TBColor = class(TInterfacedObject, IBColor)
    2122    procedure SetColorName(ColorName: TColorName); virtual;
     23    procedure SetColor(Color: TColor); virtual;
    2224    procedure SetRandom; virtual;
    2325  end;
     
    3840    procedure SetSize(AValue: TPoint); virtual;
    3941  public
     42    procedure Mirror; virtual;
     43    procedure Flip; virtual;
    4044    procedure Fill(Color: IBColor); virtual; overload;
    4145    procedure Fill(Func: TGetColorPos); virtual; overload;
     
    110114    constructor Create; overload;
    111115    constructor Create(ColorFormat: TColorFormat; ColorName: TColorName); overload;
     116    constructor Create(ColorFormat: TColorFormat; Color: TColor); overload;
    112117    destructor Destroy; override;
    113118  end;
     
    239244end;
    240245
     246procedure TBColor.SetColor(Color: TColor);
     247begin
     248end;
     249
    241250procedure TBColor.SetRandom;
    242251begin
     
    334343end;
    335344
     345constructor TFColor.Create(ColorFormat: TColorFormat; Color: TColor);
     346begin
     347  Self.ColorFormat := ColorFormat;
     348  Backend.SetColor(Color);
     349end;
     350
    336351destructor TFColor.Destroy;
    337352begin
     
    355370  if (FSize.X = AValue.X) and (FSize.Y = AValue.Y) then Exit;
    356371  FSize := AValue;
     372end;
     373
     374procedure TBImage.Mirror;
     375begin
     376
     377end;
     378
     379procedure TBImage.Flip;
     380begin
    357381end;
    358382
     
    449473procedure TFPixmap.Flip;
    450474begin
    451 
     475  FBackend.Flip;
    452476end;
    453477
    454478procedure TFPixmap.Mirror;
    455479begin
    456 
     480  FBackend.Mirror;
    457481end;
    458482
  • trunk/Packages/FastGraphics/UGGraphics.pas

    r30 r31  
    7171    procedure Fill(Color: TGColor); overload;
    7272    procedure Fill(Func: TGGetColor); overload;
     73    procedure Mirror;
     74    procedure Flip;
    7375    function GetDataSize: Int64; virtual;
    7476    property Canvas: TGCanvas<TGColor> read FCanvas;
     
    278280end;
    279281
     282procedure TGPixmap<TGColor>.Mirror;
     283var
     284  X, Y: Integer;
     285  Color: TGColor;
     286begin
     287  for Y := 0 to FSize.Y - 1 do
     288    for X := 0 to FSize.X div 2 - 1 do begin
     289      Color := Pixels[X, Y];
     290      Pixels[X, Y] := Pixels[Size.X - 1 - X, Y];
     291      Pixels[Size.X - 1 - X, Y] := Color;
     292    end;
     293end;
     294
     295procedure TGPixmap<TGColor>.Flip;
     296var
     297  X, Y: Integer;
     298  Color: TGColor;
     299begin
     300  for Y := 0 to FSize.Y div 2 - 1 do
     301    for X := 0 to FSize.X - 1 do begin
     302      Color := Pixels[X, Y];
     303      Pixels[X, Y] := Pixels[X, Size.Y - 1 - Y];
     304      Pixels[X, Size.Y - 1 - Y] := Color;
     305    end;
     306end;
     307
    280308{ TGPen }
    281309
Note: See TracChangeset for help on using the changeset viewer.