PDA

View Full Version : UnDelphiX: Filling DXImageList at runtime



bjrtap
21-12-2003, 05:54 PM
Hello,

does anybody konw how to fill the DXImageList on runtime?
I was possible to load pictures at the Form.OnCreate event,
but not later. Any ideas?

cairnswm
21-12-2003, 07:41 PM
I use normal delphiX and use the DXG lists. These load fine during runtime. using a standard DXImageList.LoadfromFile call.

I have not tried loading single Images at run time.

bjrtap
22-12-2003, 10:13 AM
but creating this DXG file is kinda difficult, isn't it?

Useless Hacker
22-12-2003, 06:39 PM
To load an individual image at runtime, you can use something like this:

var
DIB: TDIB;
Item: TPictureCollectionItem;
fs: TFileStream;
...
Item := TPictureCollectionItem.Create(DXImageList.Items);
with Item do begin
PatternWidth := 64;
PatternHeight := 32;
SkipWidth := 0;
SkipHeight := 0;
SystemMemory := False;
Transparent := True;
TransparentColor := clFuschia;

DIB := TDIB.Create;
fs := TFileStream.Create('image.bmp');

DIB.LoadFromStream(fs);
Picture.Assign(DIB);
Restore;

fs.Free;
DIB.Free;
end;
That may not be the bast way to do it, though. You could load the patternwidth, etc. values from the stream as well.

To create a DXG file, you can use one of the utillities listed here (http://turbo.gamedev.net/delphix.asp), such as DXG Edit (http://www.wummy-online.de/index_e.html). This file can be loaded using DXImageList.LoadFromFile as cairnswm says. Note that loading a DXG file will clear any images already in the list.

bjrtap
22-12-2003, 07:20 PM
Thank you very much!
Merry Chrismas!