Changeset 33 for trunk/UCore.pas
- Timestamp:
- Jan 5, 2017, 11:48:36 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r31 r33 13 13 14 14 type 15 TFloatPoint = record16 X, Y: Double;17 end;18 19 15 { TCore } 20 16 … … 67 63 public 68 64 LastColorFormat: string; 65 LastImageSize: TPoint; 69 66 Project: TProject; 70 67 RegistryContext: TRegistryContext; 71 68 procedure ProjectOpen(FileName: string); 69 procedure ProjectNew; 72 70 procedure Init; 73 71 procedure LoadConfig; … … 85 83 UFormNew, UFormMain, Forms, UColorRGBA8, UColorGray8, UColorGray1, UColorGray4, 86 84 UColorRGB565; 87 88 function FloatPoint(AX, AY: Double): TFloatPoint;89 begin90 Result.X := AX;91 Result.Y := AY;92 end;93 85 94 86 { TCore } … … 120 112 //Image.Picture.Bitmap.EndUpdate; 121 113 Image.Free; 122 AZoomAll.Execute;114 Project.View.ZoomAll(Project.Bitmap.Size); 123 115 FormMain.Redraw; 124 116 Project.FileName := FileName; 117 end; 118 119 procedure TCore.ProjectNew; 120 var 121 ColorFormatIndex: Integer; 122 begin 123 // Set default 124 ColorFormatIndex := ColorFormatManager.FindByName(LastColorFormat); 125 if ColorFormatIndex < ColorFormatManager.Formats.Count then 126 Project.Bitmap.ColorFormat := ColorFormatManager.Formats[ColorFormatIndex] 127 else Project.Bitmap.ColorFormat := ColorFormatManager.Formats[0]; 128 Project.Bitmap.Size := LastImageSize; 129 130 Project.View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height); 131 Project.View.ZoomAll(Project.Bitmap.Size); 125 132 end; 126 133 … … 130 137 LoadConfig; 131 138 132 // Set default 133 Project.Bitmap.ColorFormat := ColorFormatManager.Formats[0]; 134 Project.Bitmap.Size := Point(200, 100); 135 Project.View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height); 136 Core.AZoomAll.Execute; 139 ProjectNew; 140 FormMain.Redraw; 137 141 end; 138 142 … … 145 149 146 150 LastColorFormat := ReadStringWithDefault('LastColorFormat', ''); 151 LastImageSize.X := ReadIntegerWithDefault('LastImageSizeX', 600); 152 LastImageSize.Y := ReadIntegerWithDefault('LastImageSizeY', 400); 147 153 finally 148 154 Free; … … 158 164 159 165 WriteString('LastColorFormat', LastColorFormat); 166 WriteInteger('LastImageSizeX', LastImageSize.X); 167 WriteInteger('LastImageSizeY', LastImageSize.Y); 160 168 finally 161 169 Free; … … 165 173 procedure TCore.AFileNewExecute(Sender: TObject); 166 174 begin 175 FormNew.DefaultSize := LastImageSize; 167 176 if FormNew.ShowModal = mrOk then begin 168 177 Project.Bitmap.ColorFormat := TColorFormat.Create; … … 173 182 // Project.Bitmap.BackgroundColor.FromTColor(clBlack); 174 183 // Project.Bitmap.DPI := FormNew.SpinEditDPI.Value; 175 AZoomAll.Execute; 184 Project.View.ZoomAll(Project.Bitmap.Size); 185 FormMain.Redraw; 186 LastImageSize := Project.Bitmap.Size; 176 187 end; 177 188 end; 178 189 179 190 procedure TCore.AZoomAllExecute(Sender: TObject); 180 var 181 Factor: TFloatPoint; 182 begin 183 with Core.Project, View do begin 184 Factor := FloatPoint((DestRect.Right - DestRect.Left) / Bitmap.Size.X, 185 (DestRect.Bottom - DestRect.Top) / Bitmap.Size.Y); 186 if Factor.X < Factor.Y then Zoom := Factor.X 187 else Zoom := Factor.Y; 188 Center(Rect(0, 0, Bitmap.Size.X, Bitmap.Size.Y)); 189 end; 191 begin 192 with Core.Project do 193 View.ZoomAll(Bitmap.Size); 190 194 FormMain.Redraw; 191 195 end;
Note:
See TracChangeset
for help on using the changeset viewer.