Changeset 29 for trunk/UCore.pas


Ignore:
Timestamp:
Dec 22, 2016, 9:46:17 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Load image data from file quickly using Bitmap RawImage.
  • Modified: Remember last selected color format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r28 r29  
    77uses
    88  Classes, SysUtils, FileUtil, ActnList, UProject, UFGraphics, UPersistentForm,
    9   Controls, Graphics, ExtDlgs, ExtCtrls, UREgistry, UApplicationInfo, Registry;
     9  Controls, Graphics, ExtDlgs, ExtCtrls, URegistry, UApplicationInfo, Registry;
    1010
    1111const
     
    6262  private
    6363  public
     64    LastColorFormat: string;
    6465    Project: TProject;
     66    RegistryContext: TRegistryContext;
    6567    procedure ProjectOpen(FileName: string);
    6668    procedure Init;
     69    procedure LoadConfig;
     70    procedure SaveConfig;
    6771  end;
    6872
     
    8892procedure TCore.DataModuleCreate(Sender: TObject);
    8993begin
     94  RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot),
     95    ApplicationInfo1.RegistryKey);
    9096  Project := TProject.Create;
    9197end;
     
    9399procedure TCore.DataModuleDestroy(Sender: TObject);
    94100begin
    95   Project.Free;
     101  FreeAndNil(Project);
     102  SaveConfig;
    96103end;
    97104
     
    103110  Image := TImage.Create(nil);
    104111  Image.Picture.LoadFromFile(FileName);
    105   Image.Picture.Bitmap.BeginUpdate(True);
     112  //Image.Picture.Bitmap.BeginUpdate(True);
    106113  Project.Bitmap.Size := Point(Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height);
    107   Project.Bitmap.LoadFromCanvas(Image.Picture.Bitmap.Canvas);
    108   Image.Picture.Bitmap.EndUpdate;
     114  //Project.Bitmap.LoadFromCanvas(Image.Picture.Bitmap.Canvas);
     115  Project.Bitmap.LoadFromBitmap(Image.Picture.Bitmap);
     116  //Image.Picture.Bitmap.EndUpdate;
    109117  Image.Free;
    110118  AZoomAll.Execute;
     
    115123procedure TCore.Init;
    116124begin
    117   PersistentForm1.RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot),
    118     ApplicationInfo1.RegistryKey);
     125  PersistentForm1.RegistryContext := RegistryContext;
     126  LoadConfig;
    119127
    120128  // Set default
     
    123131  Project.View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height);
    124132  Core.AZoomAll.Execute;
     133end;
     134
     135procedure TCore.LoadConfig;
     136begin
     137  with TRegistryEx.Create do
     138  try
     139    RootKey := RegistryContext.RootKey;
     140    OpenKey(RegistryContext.Key, True);
     141
     142    LastColorFormat := ReadStringWithDefault('LastColorFormat', '');
     143  finally
     144    Free;
     145  end;
     146end;
     147
     148procedure TCore.SaveConfig;
     149begin
     150  with TRegistryEx.Create do
     151  try
     152    RootKey := RegistryContext.RootKey;
     153    OpenKey(RegistryContext.Key, True);
     154
     155    WriteString('LastColorFormat', LastColorFormat);
     156  finally
     157    Free;
     158  end;
    125159end;
    126160
Note: See TracChangeset for help on using the changeset viewer.