Patch for animated gif in SDL_image 1.1.0

I made a patch fo viewing animated gif with SDL_image
it ads:
SDL_Surface *IMG_LoadGIF_RW_FRAME(SDL_RWops *src,int frameNumber);
where should I send my files?
I haven’t debugged it yet, but it seems to work.
the function returnes a surface pointing to the frameNumber of the
animated gif or NULL in case of error.

michele

I made a patch fo viewing animated gif with SDL_image
it ads:
SDL_Surface *IMG_LoadGIF_RW_FRAME(SDL_RWops *src,int frameNumber);

not only gif supports multi-frame files (tiff, mng, perhaps also photoshop
and gimp, possibly xpm) so if we want this capability then the API should
be designed with this in mind. SDL_image as it stands right now aims for
correctness and simplicity and this is worth keeping up to a point

multi-frame files opens another can of worms (layers, transparency, timing,
layer effects etc) which have to be considered. Many file formats have
special abilities that SDL_image does not attempt to address and it would
be nice to keep the api clean and the library small

Since you probably wrote the patch to solve a problem, please keep it
separate until we can integrate it in a good way

About the animated GIF loading patch

Since you probably wrote the patch to solve a problem, please keep it
separate until we can integrate it in a good way

Might I suggest creating a new library specifically for handling
multi-framed images (maybe “SDL_mimage” or something? :slight_smile: )

At least that way, people can actively participate in development (adding
GIMP layer support, MNG, etc.) now, and if it gets decided that it
the library should really be merged with SDL_image, it can be done
more cleanly and in a more feature-complete way.

-bill!
(wondering if he’s making much sense right now :slight_smile: )

why not passing an array of SDL_Surface * to Load Image ?

void SDL_LoadMultiImage(SDL_Surface **dest, int nbImages); ???

I actually have a code who handle thoses sort of things in OpenGL, and I
load into an array of SurfaceContent (in C++), which is an hidden image
container, which allow me to have only one OpenGL texture for multiple logic
images.

Interested in the code ?

Stephane

Might I suggest creating a new library specifically for handling
multi-framed images (maybe “SDL_mimage” or something? :slight_smile: )

people interested should feel free to do that if it solves their
problems. I’d still recommend standard single-image file formats (with
several sprites/tiles in the same image if desired) in general since
they can be manipulated by a much wider range of tools but I’ll give
the design of a multi-image interface some thought

William Kendrick wrote:

Might I suggest creating a new library specifically for handling
multi-framed images (maybe “SDL_mimage” or something? :slight_smile: )

At least that way, people can actively participate in development (adding
GIMP layer support, MNG, etc.) now, and if it gets decided that it
the library should really be merged with SDL_image, it can be done
more cleanly and in a more feature-complete way.

-bill!
(wondering if he’s making much sense right now :slight_smile: )

OK, I think you’re right, SOMEONE should strt a new lib. I can’t manage
to do it, but if you can I’ll be glad to help you.

michele

Stephane Magnenat wrote:

why not passing an array of SDL_Surface * to Load Image ?

void SDL_LoadMultiImage(SDL_Surface **dest, int nbImages); ???

I actually have a code who handle thoses sort of things in OpenGL, and I
load into an array of SurfaceContent (in C++), which is an hidden image
container, which allow me to have only one OpenGL texture for multiple logic
images.

Interested in the code ?

Stephane

to be more correct we should make a struct:

typedef struct{
SDL_Surface * a;
SDL_Rect r;
int delay_time_ms;
}SDL_Frame

and

typedef struct{
SDL_Frame **a;
SDL_Rect r;
SDL_Color background;
int numberofframes;
}SDL_MultiImage

hello the project still alive? were/how can i test the patch? tks

image
could you maybe not? …

Check out SDL_image/IMG_LoadGIFAnimation_RW - SDL Wiki

Thanks, already found it last night. Having one loop issue, gif looks like lag. It stops, try read more info and didn’t find.

The wiki doesn’t contain much information about IMG_Animation but when looking at the struct definition in SDL_image.h I think it becomes pretty self-explanatory.

typedef struct
{
	int w, h;
	int count;
	SDL_Surface **frames;
	int *delays;
} IMG_Animation;