Results 1 to 2 of 2

Thread: DXImagelist > LoadFromFile & SaveToFile

  1. #1

    DXImagelist > LoadFromFile & SaveToFile

    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?

  2. #2

    DXImagelist > LoadFromFile & SaveToFile

    uhm, haven't used DXImageLists for any dinamic loading, buuut... I faintly remember having to load to a DIB object and put the image in from there... However for dinamicly loading pics, I'd say you should use a list of TDirectDrawSurfaces... You can work with them more or less how you'd work with TBitmaps and the Windows Canvas... (In other words, using the DXDraw1.Surface methods to draw, supplying a TDirectDrawSurface)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •