Changeset 36 for trunk


Ignore:
Timestamp:
May 4, 2018, 1:36:00 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Drawing using pen with connected lines instead of individual pixels.
  • Added: Negative image function for RGB8 format.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r35 r36  
    11object FormMain: TFormMain
    2   Left = 648
     2  Left = 546
    33  Height = 640
    4   Top = 323
     4  Top = 316
    55  Width = 920
    66  Caption = 'LibrePaint'
  • trunk/Forms/UFormMain.pas

    r35 r36  
    223223      P := Core.Project.View.DestToSrcPos(Point(X, Y));
    224224      if (P.X >= 0) and (P.X < Core.Project.Bitmap.Size.X) and (P.Y >= 0) and (P.Y < Core.Project.Bitmap.Size.Y) then
    225         Core.Project.Bitmap.Pixels[P.X, P.Y] := TFColor.Create(Core.Project.Bitmap.ColorFormat, ColorButton1.ButtonColor);
     225        Core.Project.Bitmap.Canvas.Pen.MoveTo(Point(P.X, P.Y));
    226226      Redraw;
    227227    end;
     
    253253    if ImageTool = itPen then begin
    254254      P := Core.Project.View.DestToSrcPos(Point(X, Y));
    255       if (P.X >= 0) and (P.X < Core.Project.Bitmap.Size.X) and (P.Y >= 0) and (P.Y < Core.Project.Bitmap.Size.Y) then
    256         Core.Project.Bitmap.Pixels[P.X, P.Y] := TFColor.Create(Core.Project.Bitmap.ColorFormat, ColorButton1.ButtonColor);
     255      if (P.X >= 0) and (P.X < Core.Project.Bitmap.Size.X) and (P.Y >= 0) and (P.Y < Core.Project.Bitmap.Size.Y) then begin
     256        Core.Project.Bitmap.Canvas.Pen.Color := TFColor.Create(Core.Project.Bitmap.ColorFormat, ColorButton1.ButtonColor);
     257        Core.Project.Bitmap.Canvas.Pen.LineTo(Point(P.X, P.Y));
     258      end;
    257259      Redraw;
    258260    end;
  • trunk/Packages/FastGraphics/ColorFormats/UColorRGB8.pas

    r31 r36  
    4747    FillCallBack: TGetColorPos;
    4848    function FillGetColor(Position: TPoint): TColorRGB8;
     49    function NegativeFunc(Position: TPoint): TColorRGB8;
    4950  protected
    5051    function GetPixel(X, Y: Integer): IBColor;  override;
     
    5556    procedure Mirror; override;
    5657    procedure Flip; override;
     58    procedure Negative; override;
    5759    procedure Fill(Color: IBColor); override;
    5860    procedure Fill(Func: TGetColorPos); override;
     61    procedure Line(P1, P2: TPoint; Color: IBColor); override;
    5962    procedure PaintToCanvas(Canvas: TCanvas); override;
    6063    procedure PaintToCanvas(Canvas: TCanvas; Rect: TRect); override;
     
    143146end;
    144147
     148function TBPixmapRGB8.NegativeFunc(Position: TPoint): TColorRGB8;
     149var
     150  C: TColorRGB8;
     151begin
     152  C := Pixmap.Pixels[Position.X, Position.Y];
     153  Result.R := 255 - C.R;
     154  Result.G := 255 - C.G;
     155  Result.B := 255 - C.B;
     156end;
     157
    145158function TBPixmapRGB8.GetPixel(X, Y: Integer): IBColor;
    146159begin
     
    169182end;
    170183
     184procedure TBPixmapRGB8.Negative;
     185begin
     186  Pixmap.Fill(NegativeFunc);
     187end;
     188
    171189procedure TBPixmapRGB8.Fill(Color: IBColor);
    172190begin
     
    181199end;
    182200
     201procedure TBPixmapRGB8.Line(P1, P2: TPoint; Color: IBColor);
     202begin
     203  Pixmap.Canvas.Pen.Color := (Color as TBColorRGB8).Value;
     204  Pixmap.Canvas.Pen.MoveTo(P1);
     205  Pixmap.Canvas.Pen.LineTo(P2);
     206end;
     207
    183208procedure TBPixmapRGB8.PaintToCanvas(Canvas: TCanvas);
    184209begin
  • trunk/Packages/FastGraphics/UFGraphics.pas

    r33 r36  
    4242    procedure Mirror; virtual;
    4343    procedure Flip; virtual;
     44    procedure Negative; virtual;
    4445    procedure Fill(Color: IBColor); virtual; overload;
    4546    procedure Fill(Func: TGetColorPos); virtual; overload;
     
    391392procedure TBImage.Mirror;
    392393begin
    393 
    394394end;
    395395
    396396procedure TBImage.Flip;
     397begin
     398end;
     399
     400procedure TBImage.Negative;
    397401begin
    398402end;
     
    505509procedure TFPixmap.Negative;
    506510begin
    507 
     511  FBackend.Negative;
    508512end;
    509513
  • trunk/Packages/FastGraphics/UGGraphics.pas

    r35 r36  
    344344      for X := 0 to FSize.X - 1 do begin
    345345        if (X >= 0) and (X < FSize.X) and (Y >= 0) and (Y < FSize.Y) then
    346           PInteger(DstPtr.Pixel)^ := ColorConvertFunc(PInteger(SrcPtr.Pixel)^);
     346          PGColor(DstPtr.Pixel)^ := ColorConvertFunc(PInteger(SrcPtr.Pixel)^);
    347347        SrcPtr.NextPixel;
    348348        DstPtr.NextPixel;
  • trunk/UCore.lfm

    r31 r36  
    33  OnDestroy = DataModuleDestroy
    44  OldCreateOrder = False
    5   Height = 491
    6   HorizontalOffset = 838
    7   VerticalOffset = 420
    8   Width = 857
     5  Height = 614
     6  HorizontalOffset = 799
     7  VerticalOffset = 416
     8  Width = 1071
     9  PPI = 120
    910  object ActionList1: TActionList
    1011    Images = ImageList1
    11     left = 201
    12     top = 160
     12    left = 251
     13    top = 200
    1314    object AExit: TAction
    1415      Caption = 'Exit'
     
    107108  end
    108109  object ImageList1: TImageList
    109     left = 200
    110     top = 240
     110    left = 250
     111    top = 300
    111112  end
    112113  object OpenPictureDialog1: TOpenPictureDialog
    113     left = 462
    114     top = 126
     114    left = 578
     115    top = 158
    115116  end
    116117  object SavePictureDialog1: TSavePictureDialog
    117     left = 462
    118     top = 208
     118    left = 578
     119    top = 260
    119120  end
    120121  object PersistentForm1: TPersistentForm
    121122    MinVisiblePart = 50
    122123    EntireVisible = False
    123     left = 64
    124     top = 48
     124    left = 80
     125    top = 60
    125126  end
    126127  object ApplicationInfo1: TApplicationInfo
     
    139140    RegistryRoot = rrKeyCurrentUser
    140141    License = 'CC0'
    141     left = 62
    142     top = 133
     142    left = 78
     143    top = 166
    143144  end
    144145end
  • trunk/UCore.pas

    r33 r36  
    234234procedure TCore.AFileSaveAsExecute(Sender: TObject);
    235235begin
    236   SavePictureDialog1.FileName := Project.FileName;
     236  SavePictureDialog1.InitialDir := ExtractFileDir(Project.FileName);
     237  SavePictureDialog1.FileName := ExtractFileName(Project.FileName);
    237238  if SavePictureDialog1.Execute then begin
    238239    Project.FileName := SavePictureDialog1.FileName;
     
    251252    Image := TImage.Create(nil);
    252253    Image.Picture.Bitmap.SetSize(Project.Bitmap.Size.X, Project.Bitmap.Size.Y);
    253     Project.Bitmap.PaintToCanvas(Image.Picture.Bitmap.Canvas,
     254    Project.Bitmap.PaintToBitmap(Image.Picture.Bitmap,
    254255      Rect(0, 0, Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height));
    255256    Image.Picture.SaveToFile(SavePictureDialog1.FileName);
Note: See TracChangeset for help on using the changeset viewer.