The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Submission: ImageIO backend for SDL_Image on Mac OS X
E. Wing
Guest

Hi all,

I have a submission for SDL_image. I have implemented an ImageIO
backend for Mac OS X.

I've uploaded the code here:
http://www.assembla.com/spaces/SDL_Image_ImageIO

A Mercurial repository and a raw tar-ball can be found there.


The existing SDL_image implementation relies on 3rd-party libjpeg,
libpng, libgif, and libtiff which is a pain to build and maintain. In
the Mac release, we currently statically link all these libraries into
the framework. But Mac OS X already comes with these libraries, but
they are hidden away underneath their ImageIO framework. This
submission uses ImageIO to load these image formats.

To further minimize duplicated code, I also moved the bmp and tga
loader to ImageIO. Incidentally, Apple seems to have an implementation
that can detect if a file is a TGA.


ImageIO was introduced in Tiger 10.4. So this submission is intended
to go with the SDL_image that will accompany the SDL 1.3 release.

This code works so far for everything I've thrown at it (both PowerPC
and Intel). But I don't have a comprehensive library of test images.
So this could would benefit greatly from more scrutiny and testing.



Finally, would something like this would also be desirable for iPhone?

Thanks,
Eric
Submission: ImageIO backend for SDL_Image on Mac OS X
Donny Viszneki
Guest

Very nice Eric! Thanks!

On Fri, Jan 2, 2009 at 5:01 AM, E. Wing <ewmailing at gmail.com> wrote:
Quote:
Hi all,

I have a submission for SDL_image. I have implemented an ImageIO
backend for Mac OS X.

I've uploaded the code here:
http://www.assembla.com/spaces/SDL_Image_ImageIO

A Mercurial repository and a raw tar-ball can be found there.


The existing SDL_image implementation relies on 3rd-party libjpeg,
libpng, libgif, and libtiff which is a pain to build and maintain. In
the Mac release, we currently statically link all these libraries into
the framework. But Mac OS X already comes with these libraries, but
they are hidden away underneath their ImageIO framework. This
submission uses ImageIO to load these image formats.

To further minimize duplicated code, I also moved the bmp and tga
loader to ImageIO. Incidentally, Apple seems to have an implementation
that can detect if a file is a TGA.


ImageIO was introduced in Tiger 10.4. So this submission is intended
to go with the SDL_image that will accompany the SDL 1.3 release.

This code works so far for everything I've thrown at it (both PowerPC
and Intel). But I don't have a comprehensive library of test images.
So this could would benefit greatly from more scrutiny and testing.



Finally, would something like this would also be desirable for iPhone?

Thanks,
Eric
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
http://codebad.com/
Submission: ImageIO backend for SDL_Image on Mac OS X
E. Wing
Guest

Quote:
Quote:
I have a submission for SDL_image. I have implemented an ImageIO
backend for Mac OS X.

I've uploaded the code here:
http://www.assembla.com/spaces/SDL_Image_ImageIO

Quick update:

I decided to decouple the load file and load rwops in the ImageIO
backend, like I did with the UIImage backend.

I also merged the two branches, so both repositories now contain the same stuff.

Also, quick piece of trivia. I glanced at the file sizes for the old
SDL_image framework and the new ImageIO backend. The old one weighed
in at about 1000k, and I think that only included libjpeg and libpng.
The ImageIO version is down to 100k. Pretty nice savings.

-Eric
Submission: ImageIO backend for SDL_Image on Mac OS X
Donny Viszneki
Guest

On Sat, Jan 3, 2009 at 6:39 PM, E. Wing <ewmailing at gmail.com> wrote:
Quote:
I decided to decouple the load file and load rwops in the ImageIO
backend, like I did with the UIImage backend.

Was this to reap the theoretical benefits you said the Apple docs
mention? Any evidence of how it actually plays out?

Quote:
Also, quick piece of trivia. I glanced at the file sizes for the old
SDL_image framework and the new ImageIO backend. The old one weighed
in at about 1000k, and I think that only included libjpeg and libpng.
The ImageIO version is down to 100k. Pretty nice savings.

Nice!

--
http://codebad.com/
Submission: ImageIO backend for SDL_Image on Mac OS X
Sam Lantinga
Guest

Quote:
Hi all,

Quote:
I have a submission for SDL_image. I have implemented an ImageIO
backend for Mac OS X.

Thank you very much!

Do you give me permission to release your contributions to SDL_image
under both the LGPL and a closed-source commercial license?

Thanks!
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC
Submission: ImageIO backend for SDL_Image on Mac OS X
E. Wing
Guest

Ooops. I just caught a bug in the decoupled file loaders. I made the
mistake in the UIImage backend and then propagated it to ImageIO.

For the load file routines, the code failed to fallback to the
built-in SDL_image loaders if ImageIO failed to handle the image type.
This meant images like PCX would fail to load.

I just fixed this in both repositories.

Thanks,
Eric
Submission: ImageIO backend for SDL_Image on Mac OS X
E. Wing
Guest

On 1/3/09, Donny Viszneki <donny.viszneki at gmail.com> wrote:
Quote:
On Sat, Jan 3, 2009 at 6:39 PM, E. Wing <ewmailing at gmail.com> wrote:
Quote:
I decided to decouple the load file and load rwops in the ImageIO
backend, like I did with the UIImage backend.

Was this to reap the theoretical benefits you said the Apple docs
mention? Any evidence of how it actually plays out?

Yes, that was part of it, though there were two other aspects I
considered. First, since the UIImage code required me to change IMG.c
with a test for TARGET_OS_IPHONE, I thought I might as well generalize
it to __APPLE__ and make both implementations a little more
consistent. Second, I figured if nobody likes it, it is easier to
remove the code than to figure out how to write it.

Performance-wise, I have no evidence on how it plays out. I suspect
there won't be much of a performance difference since I added a 'hint'
dictionary to help clue-in ImageIO. But benchmarking is the real way
to know for sure.

But there is a potential operational difference. The way my file
loading implementation works, it will now try ImageIO first before
falling back to the standard SDL_image code. This means ImageIO may
capture more file types and extensions than SDL_image officially knows
about. (For example, ImageIO supports Jpeg2000.)

Thanks,
Eric
Submission: ImageIO backend for SDL_Image on Mac OS X
E. Wing
Guest

On 1/3/09, Sam Lantinga <slouken at devolution.com> wrote:
Quote:
Quote:
Hi all,

Quote:
I have a submission for SDL_image. I have implemented an ImageIO
backend for Mac OS X.

Thank you very much!

Do you give me permission to release your contributions to SDL_image
under both the LGPL and a closed-source commercial license?

Thanks!
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC
_______________________________________________

Yes, I grant you permission.

Thanks,
Eric
Submission: ImageIO backend for SDL_Image on Mac OS X
Sam Lantinga
Guest

Quote:
Ooops. I just caught a bug in the decoupled file loaders. I made the
mistake in the UIImage backend and then propagated it to ImageIO.

Can you submit a patch? I've already committed your merged code to svn.

Thanks!
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC
Submission: ImageIO backend for SDL_Image on Mac OS X
E. Wing
Guest

On 1/3/09, Sam Lantinga <slouken at devolution.com> wrote:
Quote:
Quote:
Ooops. I just caught a bug in the decoupled file loaders. I made the
mistake in the UIImage backend and then propagated it to ImageIO.

Can you submit a patch? I've already committed your merged code to svn.

Here you go.

(My feature request is you move to Mercurial like Ryan has Wink )

Thanks,
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OSX_fallback_fix.patch
Type: application/octet-stream
Size: 3441 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090103/83e97e95/attachment-0001.obj>
Submission: ImageIO backend for SDL_Image on Mac OS X
Sam Lantinga
Guest

Quote:
Yes, I grant you permission.

Thanks! :)

Your code and patch are checked in.

See ya!
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC