picture from stream

BlitzMax Forums/BlitzMax Programming/picture from stream

KamaShin(Posted 2007) [#1]
The question has probably already been asked a couple of times but i couldn't find anything with the "search" method... is it possible to read some binary data from a file and, knowing that this data is in fact a png for example, to convert it in a TImage thing? One "ugly" way to do so would be reading the wanted part as a binary stream, then save it as a temp file wich then would be loaded with the LoadPNG function... this is "ugly" and probably slow since it requires 2 hard drive access which could be time consuming if the pictures I want to load are big or numerous or both.
So i m looking for a cleanert way, the objective being to encapsulate my game data in a single binary file

Thanks in advance :)


ImaginaryHuman(Posted 2007) [#2]
Load it into a bank and then use a bank stream as the source of LoadImage()

?


impixi(Posted 2007) [#3]
Funny you should ask this question, as I was recently working on a similar problem.

It's as AngelDaniel suggests.

Here's some sample code ripped from an encoder/decoder I wrote.



Hope it helps.

EDIT: Simplified initial example.


Beaker(Posted 2007) [#4]
This might also help:
File nibbler


Yan(Posted 2007) [#5]
Just to clarify the simplest solution...

http://www.blitzbasic.com/Community/posts.php?topic=50729#565158


KamaShin(Posted 2007) [#6]
wow, thanks for all the replies :)