From f0b8257f5a7a58c1665dafc75d6b9a6c8c7ed9e4 Mon Sep 17 00:00:00 2001 From: yangjixian Date: Fri, 18 Mar 2011 15:37:47 +0000 Subject: [PATCH] the copy, paste, delete, save, open functions has be completed. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1534 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/lazimageeditor/bmprgbgraph.pas | 6 +- .../lazimageeditor/lazimageeditor.lpi | 145 +++++++++--------- .../lazimageeditor/lazimageeditor.pas | 5 +- applications/lazimageeditor/main.lfm | 4 +- applications/lazimageeditor/main.lrs | 4 +- applications/lazimageeditor/main.pas | 17 +- applications/lazimageeditor/picturectrls.pas | 9 +- .../lazimageeditor/picturemanager.pas | 28 ++-- 8 files changed, 122 insertions(+), 96 deletions(-) diff --git a/applications/lazimageeditor/bmprgbgraph.pas b/applications/lazimageeditor/bmprgbgraph.pas index 3c4d53b51..937f2916c 100644 --- a/applications/lazimageeditor/bmprgbgraph.pas +++ b/applications/lazimageeditor/bmprgbgraph.pas @@ -189,7 +189,7 @@ begin end; constructor TRGB32Bitmap.CreateFromBitmap(ABitmap: TRasterImage); -var +{var Image: TLazIntfImage; begin Image := ABitmap.CreateIntfImage; @@ -198,6 +198,10 @@ begin finally Image.Free; end; +end; } +begin + Create(ABitmap.Width, ABitmap.Height); + Canvas.Draw(0,0,ABitmap); end; destructor TRGB32Bitmap.Destroy; diff --git a/applications/lazimageeditor/lazimageeditor.lpi b/applications/lazimageeditor/lazimageeditor.lpi index 8e27157ed..1fccc0843 100644 --- a/applications/lazimageeditor/lazimageeditor.lpi +++ b/applications/lazimageeditor/lazimageeditor.lpi @@ -47,9 +47,9 @@ - - - + + + @@ -58,23 +58,23 @@ + - - - + + + - - + - - - + + + @@ -169,19 +169,21 @@ + - - + + + - + - - - + + + @@ -278,7 +280,7 @@ - + @@ -302,19 +304,19 @@ - - - + + + - + - - - + + + @@ -331,13 +333,10 @@ - - - - + @@ -350,124 +349,124 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - + diff --git a/applications/lazimageeditor/lazimageeditor.pas b/applications/lazimageeditor/lazimageeditor.pas index 8c225d77a..a339db360 100644 --- a/applications/lazimageeditor/lazimageeditor.pas +++ b/applications/lazimageeditor/lazimageeditor.pas @@ -23,7 +23,10 @@ begin // show new picture dialog MainForm.Show; //MainForm.FileNewExecute(nil); - MainForm.FileNewOnStart; + if ParamCount > 0 then + MainForm.OpenImageFile(ParamStr(1)) + else + MainForm.FileNewOnStart; Application.Run; end. diff --git a/applications/lazimageeditor/main.lfm b/applications/lazimageeditor/main.lfm index 086a97720..9e99c4eed 100644 --- a/applications/lazimageeditor/main.lfm +++ b/applications/lazimageeditor/main.lfm @@ -1281,9 +1281,9 @@ TabOrder = 5 object checkFuzzy: TCheckBox Left = 4 - Height = 23 + Height = 19 Top = 9 - Width = 24 + Width = 20 OnChange = checkFuzzyChange TabOrder = 0 end diff --git a/applications/lazimageeditor/main.lrs b/applications/lazimageeditor/main.lrs index b57de906f..232b64f04 100644 --- a/applications/lazimageeditor/main.lrs +++ b/applications/lazimageeditor/main.lrs @@ -728,8 +728,8 @@ LazarusResources.Add('TMainForm','FORMDATA',[ +'ht'#2' '#6'Layout'#7#8'tlCenter'#11'ParentColor'#8#0#0#6'TPanel'#15'PanelTo' +'lerance2'#4'Left'#3#134#2#6'Height'#2'"'#3'Top'#2#0#5'Width'#2#30#5'Align'#7 +#6'alLeft'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2'"'#11'ClientWidth'#2 - +#30#8'TabOrder'#2#5#0#9'TCheckBox'#10'checkFuzzy'#4'Left'#2#4#6'Height'#2#23 - +#3'Top'#2#9#5'Width'#2#24#8'OnChange'#7#16'checkFuzzyChange'#8'TabOrder'#2#0 + +#30#8'TabOrder'#2#5#0#9'TCheckBox'#10'checkFuzzy'#4'Left'#2#4#6'Height'#2#19 + +#3'Top'#2#9#5'Width'#2#20#8'OnChange'#7#16'checkFuzzyChange'#8'TabOrder'#2#0 +#0#0#0#0#0#6'TPanel'#13'PanelPictures'#4'Left'#2'('#6'Height'#3#5#2#3'Top'#2 +'i'#5'Width'#3#22#3#5'Align'#7#8'alClient'#10'BevelOuter'#7#9'bvLowered'#8'T' +'abOrder'#2#3#0#0#9'TMainMenu'#8'MainMenu'#6'Images'#7#16'ImageListActions'#4 diff --git a/applications/lazimageeditor/main.pas b/applications/lazimageeditor/main.pas index d6b742e00..65b59ce85 100644 --- a/applications/lazimageeditor/main.pas +++ b/applications/lazimageeditor/main.pas @@ -292,6 +292,7 @@ type procedure UpdateAll; public procedure FileNewOnStart; + procedure OpenImageFile(FileName: string); property ActivePicture: TPictureBitmap read GetActivePicture; property ActivePicturePage: TPicturePage read GetActivePicturePage; property ActivePictureEdit: TPictureEdit read GetActivePictureEdit; @@ -1023,7 +1024,7 @@ end; procedure TMainForm.FileNewOnStart; begin - Pictures.New(640, 480, clTeal); + Pictures.New(520, 390, $F1EFDA); end; procedure TMainForm.FileOpenExecute(Sender: TObject); @@ -1033,10 +1034,16 @@ begin if OpenPictureDialog.Execute then begin for I := 0 to Pred(OpenPictureDialog.Files.Count) do - Pictures.Load(OpenPictureDialog.Files[I]); + //Pictures.Load(OpenPictureDialog.Files[I]); + OpenImageFile(OpenPictureDialog.Files[I]); end; end; +procedure TMainForm.OpenImageFile(FileName: string); +begin + Pictures.Load(FileName); +end; + procedure TMainForm.FileSaveAsExecute(Sender: TObject); begin if SavePictureDialog.Execute then @@ -1153,9 +1160,9 @@ begin if not Pictures.CanEdit then Exit; ActivePictureEdit.SelectAll; - MenuItemCopy.Enabled:=True; - MenuItemPaste.Enabled:=True; - MenuItemDelete.Enabled:=True; + MenuItemCopy.Enabled := True; + MenuItemPaste.Enabled := True; + MenuItemDelete.Enabled := True; MenuItemCopy.OnClick := @EditCopyExecute; MenuItemPaste.OnClick := @EditPasteExecute; MenuItemDelete.OnClick := @EditDeleteExecute; diff --git a/applications/lazimageeditor/picturectrls.pas b/applications/lazimageeditor/picturectrls.pas index 1c9e2f4c9..46f008d95 100644 --- a/applications/lazimageeditor/picturectrls.pas +++ b/applications/lazimageeditor/picturectrls.pas @@ -521,8 +521,15 @@ begin end; procedure TCustomPictureView.SavePicture(const FileName: String); +var Pic: TPicture; begin - Picture.SaveToFile(FileName); + Pic := TPicture.Create; + //Picture.SaveToFile(UTF8Decode(FileName)); + Pic.Bitmap.Width := Picture.Width; + Pic.Bitmap.Height := Picture.Height; + Pic.Bitmap.Canvas.Draw(0,0,Picture); + Pic.SaveToFile(FileName); + Pic.Free; end; procedure TCustomPictureView.ExportPictureAsLazarusResource(const AFileName, diff --git a/applications/lazimageeditor/picturemanager.pas b/applications/lazimageeditor/picturemanager.pas index be07a3f54..71fd21894 100644 --- a/applications/lazimageeditor/picturemanager.pas +++ b/applications/lazimageeditor/picturemanager.pas @@ -31,7 +31,7 @@ interface uses Classes, SysUtils, LResources, Controls, Graphics, ExtCtrls, ComCtrls, - Forms, PictureCtrls; + Forms, PictureCtrls, RGBDrawUtils; type @@ -235,20 +235,25 @@ end; procedure TPictureManager.Load(const FileName: String); var NewPage: TPicturePage; - Icon: TIcon; + Icon: TCustomRGBBitmapCore; I: Integer; + Pic: TPicture; begin - if SameText(ExtractFileExt(FileName), '.ico') then - begin - Icon := TIcon.Create; + //if SameText(ExtractFileExt(FileName), '.ico') then + //begin + Icon := TCustomRGBBitmapCore.Create; try // First image in std bitmap - Icon.LoadFromFile(FileName); - +// Icon.LoadFromFile(FileName); + Pic := TPicture.Create; + Pic.LoadFromFile(FileName); + Icon.Width:=Pic.Width; + Icon.Height:=Pic.Height; + Icon.Canvas.Draw(0,0,Pic.Graphic); // other images - for I := 0 to Pred(Icon.Count) do + //for I := 0 to Pred(Icon.Count) do begin - Icon.Current := I; + // Icon.Current := I; NewPage := CreatePage(Icon); NewPage.Parent := Self; ActivePage := NewPage; @@ -257,15 +262,16 @@ begin end; finally Icon.Free; + Pic.Free; end; - end + {end else begin NewPage := CreatePage(FileName); NewPage.Parent := Self; ActivePage := NewPage; Change; - end; + end; } end; procedure TPictureManager.Save;