Display jpeg as jpeg, not video memory

BlitzMax Forums/BlitzMax Programming/Display jpeg as jpeg, not video memory

Czar Flavius(Posted 2011) [#1]
I have some high-res menu backgrounds stored as jpegs. Each one is 1024x768 and about 120kb in size. They are never used in any speed critical task just menus. Is there a way to load them to regular ram only and display them "as a jpeg"? They take a second or two to load on a slower computer, which is a bit annoying. I'm guessing it spends the time decompressing the jpeg and turning it into a giant bitmap on the video card for display.


ima747(Posted 2011) [#2]
Pixmaps would keep them out of the VRAM, but take much longer to draw (every frame they have to be sent through the graphics card) but if memory location is more critical than speed there you go.

You can't draw a jpeg, in the same way you can't view something inside a zip. Compression works by removing things to save space, younhave to calculate those missing bits back in to interact with the data.

Some hardware may be able to decode on the graphics chip (such as on mobile devices, or accelerator friendly compression formats for OpenGL etc.) but it still has to get decoded somewhere.

You could try another image format that perhaps decompresses faster on the slower hardware you're targeting... Raw bitmaps are probably the fastest, pngs might be a middle ground, but I have never tested decompression speeds, I just work around the delays with the most appropriate format for whatever I'm doing...

You could also try incbin to be able to load them from ram but then the application will be bigger and have a larger footprint...


Czar Flavius(Posted 2011) [#3]
Ok thanks for the info. Other formats are a no-no, as a bitmap would be mb in disk size!


ima747(Posted 2011) [#4]
It's the turning that 120kb into the 1mb of usable data that takes the extra time :0)

Always a trade off, just gotta find how to balance, CPU, memory and disc storage for the situation.


ImaginaryHuman(Posted 2011) [#5]
compress the pixel data with Compress2() and the decompress as needed?


xlsior(Posted 2011) [#6]
You videoadapter can't 'draw jpegs' -- any format has to be decompressed to bitmaps first, which are stored uncompressed in video memory.

You can speed things up a bit by using uncompressed images instead of jpeg on disk, but the downside of that is that they'll take up significantly more diskspace.