Changeset 13 for trunk/UCore.pas
- Timestamp:
- Sep 22, 2014, 5:25:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r11 r13 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, ActnList, UProject, UGraphic, Controls, Graphics; 8 Classes, SysUtils, FileUtil, ActnList, UProject, UGraphic, Controls, Graphics, 9 ExtDlgs, ExtCtrls; 9 10 10 11 const … … 19 20 20 21 TCore = class(TDataModule) 22 AImageNegative: TAction; 21 23 AImageGradient: TAction; 22 24 AImageMirror: TAction; … … 36 38 ActionList1: TActionList; 37 39 ImageList1: TImageList; 40 OpenPictureDialog1: TOpenPictureDialog; 41 SavePictureDialog1: TSavePictureDialog; 38 42 procedure AExitExecute(Sender: TObject); 43 procedure AFileCloseExecute(Sender: TObject); 44 procedure AFileOpenExecute(Sender: TObject); 45 procedure AFileSaveAsExecute(Sender: TObject); 46 procedure AFileSaveExecute(Sender: TObject); 39 47 procedure AImageClearExecute(Sender: TObject); 40 48 procedure AImageFlipExecute(Sender: TObject); 41 49 procedure AImageGradientExecute(Sender: TObject); 42 50 procedure AImageMirrorExecute(Sender: TObject); 51 procedure AImageNegativeExecute(Sender: TObject); 43 52 procedure AImageRandomExecute(Sender: TObject); 44 53 procedure AFileNewExecute(Sender: TObject); … … 146 155 end; 147 156 157 procedure TCore.AFileCloseExecute(Sender: TObject); 158 begin 159 if not Project.Saved then AFileSave.Execute; 160 Project.Free; 161 FormMain.Redraw; 162 end; 163 164 procedure TCore.AFileOpenExecute(Sender: TObject); 165 var 166 Image: TImage; 167 begin 168 if OpenPictureDialog1.Execute then begin 169 Image := TImage.Create(nil); 170 Image.Picture.LoadFromFile(OpenPictureDialog1.FileName); 171 Image.Picture.Bitmap.BeginUpdate(True); 172 Project.Bitmap.LoadFromCanvas(Image.Picture.Bitmap.Canvas, 173 Point(Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height)); 174 Image.Picture.Bitmap.EndUpdate; 175 Image.Free; 176 FormMain.Redraw; 177 Project.FileName := OpenPictureDialog1.FileName; 178 end; 179 end; 180 181 procedure TCore.AFileSaveAsExecute(Sender: TObject); 182 begin 183 SavePictureDialog1.FileName := Project.FileName; 184 if SavePictureDialog1.Execute then begin 185 Project.FileName := SavePictureDialog1.FileName; 186 AFileSave.Execute; 187 end; 188 end; 189 190 procedure TCore.AFileSaveExecute(Sender: TObject); 191 var 192 Image: TImage; 193 begin 194 if Project.FileName = '' then AFileSaveAs.Execute 195 else begin 196 Image := TImage.Create(nil); 197 Image.Picture.Bitmap.SetSize(Project.Bitmap.Size.X, Project.Bitmap.Size.Y); 198 Project.Bitmap.PaintToCanvas(Image.Picture.Bitmap.Canvas, 199 Rect(0, 0, Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height)); 200 Image.Picture.SaveToFile(SavePictureDialog1.FileName); 201 Image.Free; 202 Project.Saved := True; 203 end; 204 end; 205 148 206 procedure TCore.AImageClearExecute(Sender: TObject); 149 207 begin … … 174 232 end; 175 233 234 procedure TCore.AImageNegativeExecute(Sender: TObject); 235 begin 236 Project.Bitmap.Negative; 237 FormMain.Redraw; 238 end; 239 176 240 procedure TCore.AImageRandomExecute(Sender: TObject); 177 241 begin
Note:
See TracChangeset
for help on using the changeset viewer.