I want to create simple tile-package editor. It has to load pictures into DXImageList, and save them into one file.
I was trying to do such thing:
Code:
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
if FileExists('test.gfx') then
IL.Items.LoadFromFile('test.gfx');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
IL.Items.SaveToFile('test.gfx');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Item: TPictureCollectionItem;
picture : TPicture;
begin
if openDlg.Execute then
begin
picture := TPicture.Create;
picture.LoadFromFile(openDlg.Filename);
try
Item := TPictureCollectionItem.Create(IL.Items);
Item.Picture.Graphic := picture.Graphic;
Item.Name:=InputBox('Name','Name:','');
Item.Restore;
finally
picture.Free;
end;
end;
end;
But package files never get saved or loaded. (I've got images in imagelist, cause I can draw them).
This SaveToFile works only when I add images to component (before running application). After such save it is possible to load these images back to component.
I don't know to add or replace image. Deleting existing images works fine.
How can I dynamically add images _and_ save them?
Bookmarks