lazimageeditor: Adds menu entry to export to windows icon

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2287 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2012-02-14 15:34:28 +00:00
parent effe4ebbdb
commit ef78c4e923
4 changed files with 663 additions and 602 deletions

View File

@ -84,14 +84,17 @@ type
procedure PageCloseQuery(var CanClose: Boolean); dynamic;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure New(AWidth, AHeight: Integer; APaperColor: TColor);
procedure Load(const FileName: String);
procedure Save;
procedure Save(const FileName: String);
procedure ExportAsLazarusResource(const AFileName, AName: String);
procedure ExportAsWindowsIcon(const AFileName: String);
procedure Close;
procedure CloseAll;
procedure Paste;
function GetPicturePageByIndex(AIndex: Integer): TPicturePage;
function CanEdit: Boolean;
published
@ -222,6 +225,11 @@ begin
PageClass := TPicturePage;
end;
destructor TPictureManager.Destroy;
begin
inherited Destroy;
end;
procedure TPictureManager.New(AWidth, AHeight: Integer; APaperColor: TColor);
var
NewPage: TPicturePage;
@ -321,6 +329,31 @@ begin
end;
end;
procedure TPictureManager.ExportAsWindowsIcon(const AFileName: String);
var
lIcon: TIcon;
lPicturePage: TPicturePage;
i, lWidth, lHeight: Integer;
begin
lIcon := TIcon.Create;
try
for i := 0 to Self.PageCount - 1 do
begin
lPicturePage := GetPicturePageByIndex(i);
if lPicturePage = nil then Continue;
lWidth := lPicturePage.PictureEdit.Picture.Width;
lHeight := lPicturePage.PictureEdit.Picture.height;
lIcon.Add(pf24bit, 16, 16);
lIcon.Current:=i;
lIcon.Canvas.Draw(0, 0, lPicturePage.PictureEdit.Picture); // Currently this crashes due to a bug in TIcon
end;
lIcon.SaveToFile(AFileName);
finally
lIcon.Free;
end;
end;
procedure TPictureManager.Close;
var
CanClose: Boolean;
@ -355,6 +388,11 @@ begin
ActivePicturePage.PictureEdit.Paste;
end;
function TPictureManager.GetPicturePageByIndex(AIndex: Integer): TPicturePage;
begin
Result := TPicturePage(Self.GetPage(AIndex));
end;
function TPictureManager.CanEdit: Boolean;
begin
Result := ActivePicturePage <> nil;