Using TerraBits Packer to load and draw image to a

BlitzPlus Forums/BlitzPlus Programming/Using TerraBits Packer to load and draw image to a

William Miller(Posted 2004) [#1]
To Lee and anyone else who would know,

How do I load an image from a Pak file into a canvas in Blitz Plus? I have no problem loading a picture into memory and setting a hangle in B3D [handle=LoadImage(Pak(picname) )], but when using the 'SetPanelImage' command how would one pull a picture out of the Pak file and place it on the canvas?

TIA,
William Miller


VIP3R(Posted 2004) [#2]
If the pak function doesn't work within the SetPanelImage command directly (I haven't tried it) you could do this instead:

pak("yourpic.png")
SetPanelImage yourpanel,"yourpic.png.tmp"

The first line just unpacks the image into the current folder, which can then be read using the SetPanelImage command. Remember that when the files unpack, they have '.tmp' added to the filename (unless you've manually changed it) hence the reason for adding '.tmp' to the SetPanelImage filename.

BTW, the SetPanelImage command doesn't place images onto a canvas, only onto a panel. But I think that's probably what you meant.


William Miller(Posted 2004) [#3]
Hi VIP3R,

Yes, I did mean a panel.
I did finally get it figured out thanks to your post -- the Packer actually adds "TMP" to the -start- of the filename when it pulls it out of the pak file and writes it tothe disk, so with that info I was able to get it working.

Thanks,
William Miller


TeraBit(Posted 2004) [#4]
Hi,

Glad you got it working. Personally I would have done this:


SetPanelImage yourpanel,pak$("yourpic.png")

Since the Pak function returns the unpacked file name.

:)


William Miller(Posted 2004) [#5]
Hi Lee,

Ahh, I forgot the function returned the filename -- that
is certainly more efficient than my appending the temp
name to it. I changed the code to your suggested method,
more efficient code is better code as 'they' say :-)


Thanks,
William Miller