Author Topic: Graphics To DATA  (Read 2709 times)

MrTAToad

  • Guest
Graphics To DATA
« on: 2010-Jul-10 »
Finally finished the program to convert PNG and BMP files to data statements. 

This program creates RLE hexadecimal data from the graphics and writes a routine to read it all in.

The file created is called temp.gbas

I've also include an example of the output


[attachment deleted by admin]

Offline monono

  • Mr. Polyvector
  • ***
  • Posts: 213
    • View Profile
    • Sockel Lernmedien
Re: Graphics To DATA
« Reply #1 on: 2010-Jul-11 »
Exactly what I just was looking for. Good work! :happy:

MrTAToad

  • Guest
Re: Graphics To DATA
« Reply #2 on: 2010-Jul-11 »
Quote
have multiple bitmaps processed and dumped within a single file
It does already - just keep adding files!  However, SPR2MEM may sometimes reject it for some reason...

Quote
user configurable function name(s)
Yes, needs adding...

Quote
user configurable data segment name(s)
Good idea!
« Last Edit: 2010-Jul-11 by MrTAToad »

MrTAToad

  • Guest
Re: Graphics To DATA
« Reply #3 on: 2010-Jul-11 »
Here is an update to the program that lets you select the output gbas file and the base label name.

The resulting label text is labelname_file processed count, eg : graphic_1, graphic_2 etc

As I've mentioned elsewhere there is a slight problem with SPR2MEM at the moment, as you may well find out, each conversion outputs two bits of text.  These are needed to make sure the SPR2MEM works with more than one sprite  :P

I've also included my test program (to test the resulting code), which rotates through 3 example graphics.



[attachment deleted by admin]
« Last Edit: 2010-Jul-11 by MrTAToad »

MrTAToad

  • Guest
Re: Graphics To DATA
« Reply #4 on: 2010-Jul-13 »
One last update :

  • Write directly to a file instead of buffering and then writing (saves a bit of memory)
  • More detail about how far the data is to being completely compressed

I've been experimenting with file sizes.  The maximum that my graphics card can cope with is 4096x4096, which takes a fair while to compress and 29 seconds to decompress if its all one colour.  A file 5460 x 8730 wont load correctly and thus wont compress correctly.

[attachment deleted by admin]

MrTAToad

  • Guest
Re: Graphics To DATA
« Reply #5 on: 2010-Jul-13 »
It would need to be an option - as transfer from main memory to graphics card is slow, it wouldn't be an ideal default :)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Graphics To DATA
« Reply #6 on: 2010-Jul-14 »
The bottleneck on your img 2 data program is the compression algo. I see if there's anything I could speed up.

MrTAToad

  • Guest
Re: Graphics To DATA
« Reply #7 on: 2010-Jul-14 »
That would be handy if you can...