- Timestamp:
- Jan 4, 2017, 11:49:56 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r30 r31 5 5 Width = 920 6 6 Caption = 'LibrePaint' 7 ClientHeight = 6 157 ClientHeight = 608 8 8 ClientWidth = 920 9 9 Menu = MainMenu1 … … 13 13 OnDestroy = FormDestroy 14 14 OnShow = FormShow 15 LCLVersion = '1.6. 2.0'15 LCLVersion = '1.6.0.4' 16 16 object PaintBox1: TPaintBox 17 17 Left = 0 18 Height = 5 6118 Height = 554 19 19 Top = 26 20 20 Width = 920 … … 32 32 Left = 0 33 33 Height = 28 34 Top = 58 734 Top = 580 35 35 Width = 920 36 36 Panels = < … … 51 51 Top = 2 52 52 Action = Core.AFileNew 53 end 54 object ColorButton1: TColorButton 55 Left = 24 56 Height = 22 57 Top = 2 58 Width = 43 59 BorderWidth = 2 60 ButtonColorSize = 16 61 ButtonColor = clMaroon 62 end 63 object ToolButton2: TToolButton 64 Left = 67 65 Top = 2 66 Action = Core.AToolMove 67 end 68 object ToolButton3: TToolButton 69 Left = 90 70 Top = 2 71 Action = Core.AToolPen 53 72 end 54 73 end … … 82 101 object MenuItem2: TMenuItem 83 102 Action = Core.AExit 103 end 104 end 105 object MenuItem21: TMenuItem 106 Caption = 'Tool' 107 object MenuItem23: TMenuItem 108 Action = Core.AToolMove 109 end 110 object MenuItem22: TMenuItem 111 Action = Core.AToolPen 84 112 end 85 113 end -
trunk/Forms/UFormMain.pas
r30 r31 11 11 type 12 12 13 TImageTool = (itMoveView, itPen); 14 13 15 { TFormMain } 14 16 15 17 TFormMain = class(TForm) 18 ColorButton1: TColorButton; 16 19 LastOpenedList1: TLastOpenedList; 17 20 MainMenu1: TMainMenu; … … 26 29 MenuItem19: TMenuItem; 27 30 MenuItem20: TMenuItem; 31 MenuItem21: TMenuItem; 32 MenuItem22: TMenuItem; 33 MenuItem23: TMenuItem; 28 34 MenuItemRecentFiles: TMenuItem; 29 35 MenuItem15: TMenuItem; … … 42 48 ToolBar1: TToolBar; 43 49 ToolButton1: TToolButton; 50 ToolButton2: TToolButton; 51 ToolButton3: TToolButton; 44 52 procedure FormActivate(Sender: TObject); 45 53 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); … … 66 74 StartMousePoint: TPoint; 67 75 StartViewPoint: TPoint; 68 Mo veActive: Boolean;76 MouseButtonDown: Boolean; 69 77 MousePos: TPoint; 70 78 Activated: Boolean; 71 79 procedure OpenRecentClick(Sender: TObject); 72 80 public 81 ImageTool: TImageTool; 73 82 procedure EraseBackground(DC: HDC); override; 74 83 procedure UpdateStatusBar; … … 82 91 83 92 uses 84 UCore ;93 UCore, UFGraphics; 85 94 86 95 {$R *.lfm} … … 184 193 procedure TFormMain.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 185 194 Shift: TShiftState; X, Y: Integer); 195 var 196 P: TPoint; 186 197 begin 187 198 if Button = mbLeft then begin 188 StartMousePoint := Point(X, Y); 189 StartViewPoint := Core.Project.View.SrcRect.TopLeft; 190 MoveActive := True; 199 if ImageTool = itMoveView then begin 200 StartMousePoint := Point(X, Y); 201 StartViewPoint := Core.Project.View.SrcRect.TopLeft; 202 end else 203 if ImageTool = itPen then begin 204 P := Core.Project.View.DestToSrcPos(Point(X, Y)); 205 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 206 Core.Project.Bitmap.Pixels[P.X, P.Y] := TFColor.Create(Core.Project.Bitmap.ColorFormat, ColorButton1.ButtonColor); 207 Redraw; 208 end; 209 MouseButtonDown := True; 191 210 end; 192 211 end; … … 194 213 procedure TFormMain.PaintBox1MouseLeave(Sender: TObject); 195 214 begin 196 Mo veActive:= False;215 MouseButtonDown := False; 197 216 end; 198 217 199 218 procedure TFormMain.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, 200 219 Y: Integer); 220 var 221 P: TPoint; 201 222 begin 202 223 MousePos := Point(X, Y); 203 if Assigned(Core.Project) then begin 204 if MoveActive then 205 with Core.Project do begin 224 if MouseButtonDown then 225 if Assigned(Core.Project) then 226 with Core.Project do begin 227 if Imagetool = itMoveView then begin 206 228 View.SrcRect := Bounds(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom), 207 229 Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom), … … 209 231 View.SrcRect.Bottom - View.SrcRect.Top); 210 232 Redraw; 233 end else 234 if ImageTool = itPen then begin 235 P := Core.Project.View.DestToSrcPos(Point(X, Y)); 236 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 237 Core.Project.Bitmap.Pixels[P.X, P.Y] := TFColor.Create(Core.Project.Bitmap.ColorFormat, ColorButton1.ButtonColor); 238 Redraw; 211 239 end; 212 240 end; … … 217 245 Shift: TShiftState; X, Y: Integer); 218 246 begin 219 Mo veActive:= False;247 MouseButtonDown := False; 220 248 end; 221 249 -
trunk/Packages/FastGraphics/ColorFormats/UColorRGB8.pas
r29 r31 37 37 constructor Create(Color: TColorRGB8); 38 38 procedure SetColorName(ColorName: TColorName); override; 39 procedure SetColor(Color: TColor); override; 39 40 procedure SetRandom; override; 40 41 end; … … 47 48 function FillGetColor(Position: TPoint): TColorRGB8; 48 49 protected 50 function GetPixel(X, Y: Integer): IBColor; override; 51 procedure SetPixel(X, Y: Integer; AValue: IBColor); override; 49 52 procedure SetSize(AValue: TPoint); override; 50 53 public 51 54 Pixmap: TPixmapRGB8; 55 procedure Mirror; override; 56 procedure Flip; override; 52 57 procedure Fill(Color: IBColor); override; 53 58 procedure Fill(Func: TGetColorPos); override; … … 121 126 end; 122 127 128 procedure TBColorRGB8.SetColor(Color: TColor); 129 begin 130 Value := TColorRGB8.Create((Color shr 0) and $ff, (Color shr 8) and $ff, (Color shr 16) and $ff); 131 end; 132 123 133 procedure TBColorRGB8.SetRandom; 124 134 begin … … 131 141 begin 132 142 Result := (FillCallBack(Position) as TBColorRGB8).Value; 143 end; 144 145 function TBPixmapRGB8.GetPixel(X, Y: Integer): IBColor; 146 begin 147 Result := TBColorRGB8.Create(Pixmap.Pixels[X, Y]); 148 end; 149 150 procedure TBPixmapRGB8.SetPixel(X, Y: Integer; AValue: IBColor); 151 begin 152 Pixmap.Pixels[X, Y] := (AValue as TBColorRGB8).Value; 133 153 end; 134 154 … … 139 159 end; 140 160 161 procedure TBPixmapRGB8.Mirror; 162 begin 163 Pixmap.Mirror; 164 end; 165 166 procedure TBPixmapRGB8.Flip; 167 begin 168 Pixmap.Flip; 169 end; 170 141 171 procedure TBPixmapRGB8.Fill(Color: IBColor); 142 172 begin -
trunk/Packages/FastGraphics/UFGraphics.pas
r29 r31 13 13 IBColor = interface 14 14 procedure SetColorName(ColorName: TColorName); 15 procedure SetColor(Color: TColor); 15 16 procedure SetRandom; 16 17 end; … … 20 21 TBColor = class(TInterfacedObject, IBColor) 21 22 procedure SetColorName(ColorName: TColorName); virtual; 23 procedure SetColor(Color: TColor); virtual; 22 24 procedure SetRandom; virtual; 23 25 end; … … 38 40 procedure SetSize(AValue: TPoint); virtual; 39 41 public 42 procedure Mirror; virtual; 43 procedure Flip; virtual; 40 44 procedure Fill(Color: IBColor); virtual; overload; 41 45 procedure Fill(Func: TGetColorPos); virtual; overload; … … 110 114 constructor Create; overload; 111 115 constructor Create(ColorFormat: TColorFormat; ColorName: TColorName); overload; 116 constructor Create(ColorFormat: TColorFormat; Color: TColor); overload; 112 117 destructor Destroy; override; 113 118 end; … … 239 244 end; 240 245 246 procedure TBColor.SetColor(Color: TColor); 247 begin 248 end; 249 241 250 procedure TBColor.SetRandom; 242 251 begin … … 334 343 end; 335 344 345 constructor TFColor.Create(ColorFormat: TColorFormat; Color: TColor); 346 begin 347 Self.ColorFormat := ColorFormat; 348 Backend.SetColor(Color); 349 end; 350 336 351 destructor TFColor.Destroy; 337 352 begin … … 355 370 if (FSize.X = AValue.X) and (FSize.Y = AValue.Y) then Exit; 356 371 FSize := AValue; 372 end; 373 374 procedure TBImage.Mirror; 375 begin 376 377 end; 378 379 procedure TBImage.Flip; 380 begin 357 381 end; 358 382 … … 449 473 procedure TFPixmap.Flip; 450 474 begin 451 475 FBackend.Flip; 452 476 end; 453 477 454 478 procedure TFPixmap.Mirror; 455 479 begin 456 480 FBackend.Mirror; 457 481 end; 458 482 -
trunk/Packages/FastGraphics/UGGraphics.pas
r30 r31 71 71 procedure Fill(Color: TGColor); overload; 72 72 procedure Fill(Func: TGGetColor); overload; 73 procedure Mirror; 74 procedure Flip; 73 75 function GetDataSize: Int64; virtual; 74 76 property Canvas: TGCanvas<TGColor> read FCanvas; … … 278 280 end; 279 281 282 procedure TGPixmap<TGColor>.Mirror; 283 var 284 X, Y: Integer; 285 Color: TGColor; 286 begin 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; 293 end; 294 295 procedure TGPixmap<TGColor>.Flip; 296 var 297 X, Y: Integer; 298 Color: TGColor; 299 begin 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; 306 end; 307 280 308 { TGPen } 281 309 -
trunk/UCore.lfm
r30 r31 95 95 OnExecute = AImageNegativeExecute 96 96 end 97 object AToolPen: TAction 98 Category = 'Tool' 99 Caption = 'Pen' 100 OnExecute = AToolPenExecute 101 end 102 object AToolMove: TAction 103 Category = 'Tool' 104 Caption = 'Move' 105 OnExecute = AToolMoveExecute 106 end 97 107 end 98 108 object ImageList1: TImageList -
trunk/UCore.pas
r30 r31 20 20 21 21 TCore = class(TDataModule) 22 AToolMove: TAction; 23 AToolPen: TAction; 22 24 AImageNegative: TAction; 23 25 AImageGradient: TAction; … … 54 56 procedure AImageNegativeExecute(Sender: TObject); 55 57 procedure AImageRandomExecute(Sender: TObject); 58 procedure AToolMoveExecute(Sender: TObject); 59 procedure AToolPenExecute(Sender: TObject); 56 60 procedure AZoomAllExecute(Sender: TObject); 57 61 procedure AZoomInExecute(Sender: TObject); … … 291 295 end; 292 296 297 procedure TCore.AToolMoveExecute(Sender: TObject); 298 begin 299 FormMain.ImageTool := itMoveView; 300 end; 301 302 procedure TCore.AToolPenExecute(Sender: TObject); 303 begin 304 FormMain.ImageTool := itPen; 305 end; 306 293 307 end. 294 308
Note:
See TracChangeset
for help on using the changeset viewer.