GLBasic forum

Feature request => 2D => Topic started by: Cliff3D on 2010-Sep-02

Title: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: Cliff3D on 2010-Sep-02
To quote the online manual:

Quote
LOADSPRITE bmp$, num%


Loads the graphic file (bmp or png) into memory for using it with DRAWSPRITE commands later on. Every loaded sprite needs a unique ID number (num%) which allows you to access the sprite. If an ID is reused, the image in memory for that ID will be replaced by the new image.

Now I've read apparent comments that JPEG support had been added, but that it tended to cuase problems - I really want to be able to use JPEGs. Please?
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: Ian Price on 2010-Sep-02
Don't we all (well some of us). :(
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: doimus on 2010-Sep-02
There are some advantages to JPG. For example, in casual Hidden Object games that have lots of full screen backgrounds, huge "sprites" etc. it's sensible to use JPG. In fact almost all casual frameworks support it.
Sometimes is acceptable to have slightly lossy images but with the benefit of much smaller game download. JPG at 95% quality is still way smaller than PNG, without apparent degradation in quality.

Also, textures for 3d models mostly don't have to be losless, due to the way they're displayed on screen.
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: Cliff3D on 2010-Sep-02
Also, in my instance many 3D models in .OBJ format have .jpg textures. If I supply a program to someone I doubt they will want to convert all their textures to .png and fix the references to go to the .pngs before using whatever I could write to use them :(

I'm surpriseed no-one has written a user function to read JPEGS - is the file format not available, or really convoluted?
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: Cliff3D on 2010-Sep-03
Can "we", as a user group, find the jpeg spec and write a reader (as I'm currently attempting with .OBJ files)? I don't know how into "group helping and sharing" we are here, yet. I'll learn!
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: Kitty Hello on 2010-Sep-15
You can try to load jpeg on Win32. On most platforms it works - iPhone does for sure _not_.
I am aware of that bug, but so far I can't get it fixed as it's a different library I have to use.
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: Cliff3D on 2010-Sep-15
Cool - I'll try it on Win32 a bit later. Personally I don't need iPhone support yet but was nervous about jpeg as it doesn't seem to be documented and the forum posts I found seemed to suggest it was, ah, flakey?
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: Ian Price on 2010-Sep-15
JPEG doesn't work properly EVEN on Windows, I'm afraid.

It might load one or more images once, but try to use them more than once and/or other images and it all fecks up.

I brought this up ages ago, as I was working on a Top Trumps game and wanted the card images to use JPEG. It seems fine at first, but goes awry very quickly when JPEGs are loaded and displayed.
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: Cliff3D on 2010-Sep-15
:( thanks Ian, I had a horrible feeling that's what I'd found - so jpeg support is back on my list of things to consider trying to write. Ah well! :|
Title: Re: Good, fast, stable support for JPEG files in LOADSPRIATE etc.
Post by: MrTAToad on 2010-Sep-15
As it causes immense problems, I dont see it being in for quite a while.

At the moment you can only use it with one file - any further use (especially to the same id number) will crash your program...
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: Cliff3D on 2010-Sep-15
I must admit, I had hoped that someone would ahve taken a similar approach to my initial thoughts on the .obj file format - and started tackling the .jpeg file format in GLBasic from first principles. Possibly even converting from C source code freely avaiable at site slike:

http://www.ijg.org/ (http://www.ijg.org/)
or
http://www.faqs.org/faqs/jpeg-faq/part1/index.html (http://www.faqs.org/faqs/jpeg-faq/part1/index.html)

(links very quickly obtained via google).

I have slightly fond memories of using a version of FORTH which had been written and compiled in an earlier version of FORTH, and have wondered whether producing our own 2libraries" might be something the community was "up for" on a collective basis - there certainly seem to be some code snippets along those lines. Maybe those who post their code thend not to be those interested in 3D or different graphic formats?
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: Moru on 2010-Sep-15
The ability to load raw image data to a sprite has only been available for a few days, hold your horses :-)
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: MrTAToad on 2010-Sep-15
Apparently Gernot is using the jpeg code from http://www.ijg.org/ - but its being a problem...
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: Cliff3D on 2010-Sep-15
I can wait a bit. Even without days like today when my head's splitting too much to code, I've got a fair few bits and pieces to put together and test out. Plenty of refining before I NEED good .jpeg support - though I fear I have lost sight of the prudence I intended to have when approaching GLB to eval :(
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: phaelax on 2010-Sep-22
Quote
JPG at 95% quality is still way smaller than PNG, without apparent degradation in quality.

I must be the only one who prefers PNGs because they almost always seem to be smaller than JPGs with better quality. That's why I typically only use PNGs for web design.  After a certain size a JPG might be smaller, but for mostly what I've done PNG has been smaller.
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: Ian Price on 2010-Sep-22
Quote
After a certain size a JPG might be smaller, but for mostly what I've done PNG has been smaller.
Smaller is a relative term and means bugger all, really.

Given the same image in three formats a PNG when uncompressed might appear smaller than a .JPEG or .BMP, but when compressed in a .ZIP file, is likely to be larger. And whilst occupying memory, each image will be the same.
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: Cliff3D on 2010-Sep-22
There's no disagreement here, actually. I personally find them preferable to .jpg, given a choice, and while generalisations are dangerous (it's often possible to disprove a generalisation with a very specific, perhaps unlikely, example) I find .png files tend to be smaller "live" than a .jpg file which isn't visibly poorer.

Which is great, for "live" use asuch as on the web.

Ian (and I think others) however are saying that .jpg files compress further in .zip or .rar form, so that - in a compressed archive (such as a game bundled with graphics and sound) .jpgs of visibly similar (possibly "identical" to the eye) quality actually end up taking less space - which makes them lighter to download. which is a good thing, overall.

It's all horse for courses - there's no "one good way" to do everything, each method/type has its pros and cons :)
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: mentalthink on 2012-Nov-11
I kent, tes normally this occurs when the size exceeds I think 1000px
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: erico on 2012-Nov-11
Hi KentM, this is your first post and you registered today.
You are offering a "free tool" as a solution to a problem after investigation and experimentation.

It may be more polite to share some of this investigation and experimentation with jpegs and GLB and how far it goes, like multiplatform etc.
No harm intended and I apologize for my behavior, but the way it is, it sounds like spam on my book. :doubt:
Title: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: Ian Price on 2012-Nov-11
I have removed KentM's message as -

a) It was responding to a post over two years old
b) It wasn't really relevant
c) It was indeed a means to advertise a product.
d) If it was a genuine first post it was crap.

Thanks for reporting fellas :)

Title: Re: Re: Good, fast, stable support for JPEG files in LOADSPRITE etc.
Post by: fuzzy70 on 2012-Nov-11
Quote
d) If it was a genuine first post it was crap.

+1

Lee
Sent from my GT-I5700 using Tapatalk 2