SDL_image update & png fix

Hi

I had some month ago pointed to a bug in the png image loader, which
messed up the transparency setting.

One of the dev team of sdl has fixed it, but the IMG_png from cvs is not
updated i think and there is no new release of the lib.

Also, there is perhaps another bug, i had find out that with old library
many png pictures with palette are stored as surface without palette,
the info says there is no one. We use pngs with optimized palette (means
not used color entrys are not safed in palette structure).

Well, i had wrote the sdl client of crossfire, a big open source mmorpg.
We have yet about >3500 pngs and i can’t release it using the broken lib.
I had to use really dirty hacks to fix this.

Don’t understand we false, but i need a defined answer: Will the sdl team
fix & update the image lib in the next days/ 2 weeks or not?

If not, it is no problem, then i skip the use of the image lib and wrote it
by myself - but i find it much cleaner to use the official libs.

thx
Michael

Well, i had wrote the sdl client of crossfire, a big open source mmorpg.
We have yet about >3500 pngs and i can’t release it using the broken lib.
I had to use really dirty hacks to fix this.

Don’t understand we false, but i need a defined answer: Will the sdl team
fix & update the image lib in the next days/ 2 weeks or not?

Yes, the libs will be released in the next week or two.
I’ve been having trouble rounding up all the platforms to build and test
the packages on, but it’s slowly coming together.

The fix should be in CVS, however the repository listed on the webpage
was wrong.
The correct CVS repository is: http://www.libsdl.org/cgi/cvsweb.cgi/

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

“Michael Toennies” <michael.toennies at nord-com.net> wrote:

One of the dev team of sdl has fixed it, but the IMG_png from cvs is not
updated i think and there is no new release of the lib.

the file in CVS is definitely updated — Sam, have you released a version
after that?

Also, there is perhaps another bug, i had find out that with old library
many png pictures with palette are stored as surface without palette,
the info says there is no one. We use pngs with optimized palette (means
not used color entrys are not safed in palette structure).

I’m not sure what you mean by this — can you give an example? By
"old library", do you mean a previous release of SDL_image or libpng?
If SDL_image does not correctly load an image that you think should be
handled, please send an example file to me and I’ll see what I can do.
(Send it in another format as well for reference.)

i had attached 2 example pngs.
After this piece of code

    bitmap = IMG_Load(fname);
    if(bitmap->format->palette)
        LOG(LOG_MSG,"*** find palette ***: %s \n", fname );
    else
        LOG(LOG_MSG,"*** NO palette ***: %s \n", fname );

they are handled as non palette pngs (bitmap->format->palette == NULL).

They looks like 2 pngs, saved with GIMP… When i save then with optimized
palette from paint shop 7, all is ok.

“Michael Toennies” <@Michael_Toennies> wrote:

One of the dev team of sdl has fixed it, but the IMG_png from cvs is not
updated i think and there is no new release of the lib.

the file in CVS is definitely updated — Sam, have you released a version
after that?

Also, there is perhaps another bug, i had find out that with old library
many png pictures with palette are stored as surface without palette,
the info says there is no one. We use pngs with optimized palette (means
not used color entrys are not safed in palette structure).

I’m not sure what you mean by this — can you give an example? By
"old library", do you mean a previous release of SDL_image or libpng?
If SDL_image does not correctly load an image that you think should be
handled, please send an example file to me and I’ll see what I can do.
(Send it in another format as well for reference.)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
-------------- next part --------------
A non-text attachment was scrubbed…
Name: no_pal_bug.zip
Type: application/x-zip-compressed
Size: 1297 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20011020/c73f5169/attachment.bin

If I blit a surface without alpha channel I’ve 47 fps, but with alpha channel
I’ve 23 fps.
Why alpha blit It is too slow? I could use opengl (with 3d acceleration) for
more faster blits?

If I blit a surface without alpha channel I’ve 47 fps, but with alpha channel
I’ve 23 fps.
Why alpha blit It is too slow? I could use opengl (with 3d acceleration) for
more faster blits?

It depends of the target driver you are running your program on. Is it
X, framebuffer, directX, DGA? Some drivers can take advantage of
hardware acceleration, while others can’t. I think DGA and framebuffer
can take advantage of your hardware if configured properly, while X
can’t. By the way, I’m also interested for a complete list of
accelerations supported by drivers, if someone has more informations
about it…

Thanks,
Alex.

“Michael Toennies” <michael.toennies at nord-com.net> wrote:

i had attached 2 example pngs.
[…]
they are handled as non palette pngs (bitmap->format->palette == NULL).

the current SDL_image seems to be able to load them as palettized pngs
without problem

Ah, i got now the right CVS of SDL_image - you are right,
all looks perfect!

Hope you release is soon. And the bad link to this old CVS
should be removed form your active links, is a bit confusing.> “Michael Toennies” <@Michael_Toennies> wrote:

i had attached 2 example pngs.
[…]
they are handled as non palette pngs (bitmap->format->palette == NULL).

the current SDL_image seems to be able to load them as palettized pngs
without problem


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

AFAIK, SDL supports h/w acceleration only for colorkey blitting - as do
most 2D targets SDL supports.

DirectGraphics (DX 8.0) and OpenGL could accelerate alpha blits (and lots
of other stuff), but SDL 1.2.x doesn’t support it.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Sunday 21 October 2001 14:12, Alexandre Courbot wrote:

If I blit a surface without alpha channel I’ve 47 fps, but with alpha
channel I’ve 23 fps.
Why alpha blit It is too slow? I could use opengl (with 3d
acceleration) for more faster blits?

It depends of the target driver you are running your program on. Is it
X, framebuffer, directX, DGA? Some drivers can take advantage of
hardware acceleration, while others can’t. I think DGA and
framebuffer can take advantage of your hardware if configured properly,
while X can’t. By the way, I’m also interested for a complete list of
accelerations supported by drivers, if someone has more informations
about it…

If I blit a surface without alpha channel I’ve 47 fps, but with alpha
channel I’ve 23 fps.
Why alpha blit It is too slow?

It’s always done in software - and I’d actually say it’s extremely fast
for a generic software implementation!

Are you using SDL_DisplayFormatAlpha() with the SDL_RLEACCEL flag?

Also note that there’s a faster special case for 50% (128) alpha.

I could use opengl (with 3d acceleration) for more faster blits?

Yes - and you’d get various other bonuses, as well as some problems.

I’ve experimented with an OpenGL implementation of the SDL 2D API, and it
seems like it would be possible to code a usable OpenGL rendering backend
for SDL. Practically all SDL applications would work with OpenGL, and
most would run much faster, BUT, there are issues with the way SDL 1.2.x
does certain things. (“Partial Locking” of the screen surface would be
very useful.) Also, it’s not possible to transparently take advantage
of interpolated scaling/stretching in any reliable way. (My
implementation runs with NEAREST filtering for everything, which makes it
look exactly like software/2D SDL.)

If you’re serious about using heavy alpha blending, and perhaps other
blending effects, in a high resolution game (640x480+), you should
consider using OpenGL directly.

However, make sure there’s a good motivation to use OpenGL! If there’s
any reasonable way a 2D game could run without OpenGL, it should.
Supporting both SDL 2D and OpenGL is workable if you do it right from the
start, but it’s very likely that the 2D code gets left behind as new cool
effects evolve…

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Sunday 21 October 2001 13:02, samsagaz wrote:

I’ve experimented with an OpenGL implementation of the SDL 2D API, and it
seems like it would be possible to code a usable OpenGL rendering backend
for SDL. Practically all SDL applications would work with OpenGL, and
most would run much faster, BUT, there are issues with the way SDL 1.2.x
does certain things. (“Partial Locking” of the screen surface would be
very useful.) Also, it’s not possible to transparently take advantage
of interpolated scaling/stretching in any reliable way. (My
implementation runs with NEAREST filtering for everything, which makes it
look exactly like software/2D SDL.)

Wow - you mean you have hacked an OpenGL backend for SDL? This is truly
interesting, how about making it public, or even part of SDL? SDL is a
very clean and powerfull library, but it’s often limited in it’s
performances by it’s backends. Having an OpenGL backend available would
virtually make hardware acceleration available to X, and would make SDL
even more portable. Needless to mention, that anti-aliasing on the
screen surface would rock too.I don’t know much about OpenGL itself, but
it seems to be that it’s not really good at 2D blitting, can you
confirm/infirm this?

Thanks,
Alex.

I’ve experimented with an OpenGL implementation of the SDL 2D API,
and it seems like it would be possible to code a usable OpenGL
rendering backend for SDL. Practically all SDL applications would
work with OpenGL, and most would run much faster, BUT, there are
issues with the way SDL 1.2.x does certain things. ("Partial Locking"
of the screen surface would be very useful.) Also, it’s not
possible to transparently take advantage of interpolated
scaling/stretching in any reliable way. (My
implementation runs with NEAREST filtering for everything, which
makes it look exactly like software/2D SDL.)

Wow - you mean you have hacked an OpenGL backend for SDL? This is truly
interesting, how about making it public, or even part of SDL?

It’s included as an optional “experimental” build time option in Kobo
Deluxe v0.3, to be released RSN. (No major issues remaining; I just need
test it some on Windows as well…)

Note however, that this is a quick proof-of-concept hack, that won’t work
on any 64 bit platforms, cannot safely be mixed with SDL "add-on"
libraries, and that doesn’t even work properly in all respects.

SDL is a
very clean and powerfull library, but it’s often limited in it’s
performances by it’s backends. Having an OpenGL backend available would
virtually make hardware acceleration available to X, and would make SDL
even more portable.

Needless to mention, that anti-aliasing on the
screen surface would rock too.

There’s a major problem: It’s not possible to do transparently. Kobo
Deluxe does AA in the scaled software modes, but that requires background
tiles, fonts and sprites to be treated differently - and still, the way
tiles are handled isn’t even correct. (The engine will eventually be able
to understand and manipulate tiled map data and generate new tiles in
order to deal with that.)

I don’t know much about OpenGL itself,
but it seems to be that it’s not really good at 2D blitting, can you
confirm/infirm this?

OpenGL is excellent for 2D rendering - it’s just that it doesn’t work
at all like traditional software 2D rendering. It’s definitely possible
to come up with a 2D rendering API that would enable optimal
implementations in software as well as over various 3D acceleration API.
However, SDL wasn’t designed with that in mind, and it shows.

SDL-on-OpenGL with the 1.2.x API will have have performance/compatibility
issues, but it might still turn out to be usable - if only because h/w
accelerated rendering is so much faster than software rendering.

More specifically;

		SDL-on-OpenGL:		SDL software:On Monday 22 October 2001 21:48, Alexandre Courbot wrote:

Blitting from display No issues; VERY fast. No major issues.
format surfaces to
screen:

Blitting from “dynamic” First blit after mod. First blit after mod.
surfaces to screen: results in conversion results in conversion
and downloading and/or encoding
overhead. overhead.

		Entire surface has to	Locking a surface
		be considered changed,	forces unpacking of
		as there is no		RLE encoded surfaces.
		"UpdateRects" for
		normal surfaces.

Blitting from screen Depends on OpenGL Depends on target.
to surface: implementation. Usually slow due to
Generally very slow. CPU reads from VRAM.

Direct manipulation of Has to be emulated by Low bandwidth, but
VRAM frame buffer: reading the entire only pixels actually
OpenGL frame buffer accessed count.
when the screen is
locked! Dog slow.

Blitting from surface Done in software by Can be accelerated on
to surface: SDL. (Cannot be h/w some targets.
accelerated.)

		Blitting to (or		(What happens when you
		FillRect of) areas in	blit to an RLE surface?)
		surfaces that are later
		blitted to screen can
		be optimized.

SDL_Flip(): Very fast, even if Slow when SDL has to
emulated with a back-> emulate it with a s/w
front blit in the back->front blit.
driver.

Alpha blending: Always h/w accelerated. Cannot be h/w accelerated.
Minor overhead. Massive overhead, despite
very efficient code.

Colorkey blitting: Emulated using the Can be accelerated on
alpha channel. some targets.
Minor overhead. Insignificant overhead
in software with RLE.

Memory: Temporary buffers for No “hidden” buffers.
texture conversion.

As you probably can tell by thinking some about these points, the biggest
issues are results of the possibility of SDL being used in ways that
leave our OpenGL backend with insufficient information to do it’s job
efficiently. (As when you lock the entire screen to change a few hundred
pixels directly with the CPU, forcing the OpenGL backend to grab and then
update the entire screen, as it can’t know what was actually changed.)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -’

Ah, i got now the right CVS of SDL_image - you are right,
all looks perfect!

Hope you release is soon. And the bad link to this old CVS
should be removed form your active links, is a bit confusing.

It should already be removed. If it’s not, please send e-mail to
@slouken with the location of the bad link.

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

It might be nice, because it’s how DX8 works for 2D.
In DX8 you need to reender textures to do 2D programming.

Just take a look at

Paulo Pinto> ----- Original Message -----

From: alexandrecourbot@linuxgames.com (Alexandre Courbot)
To:
Sent: Monday, October 22, 2001 8:48 PM
Subject: Re: [SDL] Alpha blit is too slow

I’ve experimented with an OpenGL implementation of the SDL 2D API, and
it

seems like it would be possible to code a usable OpenGL rendering
backend

for SDL. Practically all SDL applications would work with OpenGL, and
most would run much faster, BUT, there are issues with the way SDL 1.2.x
does certain things. (“Partial Locking” of the screen surface would be
very useful.) Also, it’s not possible to transparently take advantage
of interpolated scaling/stretching in any reliable way. (My
implementation runs with NEAREST filtering for everything, which makes
it

look exactly like software/2D SDL.)

Wow - you mean you have hacked an OpenGL backend for SDL? This is truly
interesting, how about making it public, or even part of SDL? SDL is a
very clean and powerfull library, but it’s often limited in it’s
performances by it’s backends. Having an OpenGL backend available would
virtually make hardware acceleration available to X, and would make SDL
even more portable. Needless to mention, that anti-aliasing on the
screen surface would rock too.I don’t know much about OpenGL itself, but
it seems to be that it’s not really good at 2D blitting, can you
confirm/infirm this?

Thanks,
Alex.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

It’s included as an optional “experimental” build time option in Kobo
Deluxe v0.3, to be released RSN. (No major issues remaining; I just need
test it some on Windows as well…)

Ah, cool. Guess I’ll have a look at the code once you release it then.

Note however, that this is a quick proof-of-concept hack, that won’t work
on any 64 bit platforms, cannot safely be mixed with SDL "add-on"
libraries, and that doesn’t even work properly in all respects.

SDL-on-OpenGL with the 1.2.x API will have have performance/compatibility
issues, but it might still turn out to be usable - if only because h/w
accelerated rendering is so much faster than software rendering.

From what you said, it sounds like the possibility to blit surfaces when
using OpenGL is “sort of” back-end and that it is accelerated, right? In
what is it different from the backend you’ve hacked for Kobo?

Alex.

SDL_OPENGLBLIT results in SDL setting up a software RGBA back buffer, to
which SDL blits are performed. When you all SDL_UpdateRects, the
specified areas are “pumped” through OpenGL via a single 256x256 texture.

The SDL_GLSDL hack associates OpenGL textures with SDL surfaces in a
similar fashion to how the DirectX backend associates DirectX surfaces to
SDL surfaces. (Although SDL_GLSDL keeps the original software surface as
well, which I don’t think is the case with the DX backend.)

That is, once you’re up running, surfaces “SDL_DisplayFormat()ed” and
all, SDL_OPENGLBLIT will keep doing software blits and abusing the
texture downloading API, while SDL_GLSDL just enqueues OpenGL rendering
operations from textures associated with the source surfaces, just like a
normal OpenGL application would do it.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 24 October 2001 18:41, Alexandre Courbot wrote:

It’s included as an optional “experimental” build time option in Kobo
Deluxe v0.3, to be released RSN. (No major issues remaining; I just
need test it some on Windows as well…)

Ah, cool. Guess I’ll have a look at the code once you release it then.

Note however, that this is a quick proof-of-concept hack, that won’t
work on any 64 bit platforms, cannot safely be mixed with SDL
"add-on" libraries, and that doesn’t even work properly in all
respects.

SDL-on-OpenGL with the 1.2.x API will have have
performance/compatibility issues, but it might still turn out to be
usable - if only because h/w accelerated rendering is so much faster
than software rendering.

From what you said, it sounds like the possibility to blit surfaces
when using OpenGL is “sort of” back-end and that it is accelerated,
right? In what is it different from the backend you’ve hacked for Kobo?

That is, once you’re up running, surfaces “SDL_DisplayFormat()ed” and
all, SDL_OPENGLBLIT will keep doing software blits and abusing the
texture downloading API, while SDL_GLSDL just enqueues OpenGL rendering
operations from textures associated with the source surfaces, just like a
normal OpenGL application would do it.

Uh yeah, that sounds really good. But - since the SDL_GLSDL mode is in
Kobo source, is it a patch for SDL that we have to recompile? Or can you
add a backend into the library just like a module? Sorry for my
ignorance - I don’t know SDL internals well, but I’m all willing to
learn.

Also, is there a way to get this version of Kobo now? I’ve browsed your
site, but can’t find a reference to a CVS or a way to get development
code.

Thanks,
Alex.

That is, once you’re up running, surfaces “SDL_DisplayFormat()ed” and
all, SDL_OPENGLBLIT will keep doing software blits and abusing the
texture downloading API, while SDL_GLSDL just enqueues OpenGL
rendering operations from textures associated with the source
surfaces, just like a normal OpenGL application would do it.

Uh yeah, that sounds really good. But - since the SDL_GLSDL mode is in
Kobo source, is it a patch for SDL that we have to recompile?

No, it’s a temporary hack involving #defines and use of an unused field
in the SDL_Surface struct. That is, it runs on a standard SDL install,
but you shouldn’t use that code in production code. (Send an SDL surface
to any glSDL_* call without first clearing the “unused1” field, and you
get a bad crash, for example… heh)

Or can
you add a backend into the library just like a module?

AFAIK, no.

Also, is there a way to get this version of Kobo now? I’ve browsed your
site, but can’t find a reference to a CVS or a way to get development
code.

The latest versions are at

http://olofson.net/download

but you won’t find the OpenGL hacked version there yet. I was planning to
releas the official v0.3 (including that hack, as an experimental
configure option), but I got sidetracked… Sorry.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Saturday 27 October 2001 16:31, Alexandre Courbot wrote: