SDL and gif's

Is there anyway in SDL to store all my images in one file?
Kind of like they did with diablo.
Or are there other utilities for such?

This is a good question for the SDL development mailing list.
Send mail to sdl-subscribe at surfnetcity.com.au, if you are not already
subscribed.

SDL doesn’t provide anything itself, but you can write your own, and
use them with SDL. If you are feeling adventurous, take a look at
SDL_rwops.h in the latest CVS snapshot of SDL. :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Sam Lantinga wrote:

Is there anyway in SDL to store all my images in one file?
Kind of like they did with diablo.
Or are there other utilities for such?

This is a good question for the SDL development mailing list.
Send mail to sdl-subscribe at surfnetcity.com.au, if you are not already
subscribed.

SDL doesn’t provide anything itself, but you can write your own, and
use them with SDL. If you are feeling adventurous, take a look at
SDL_rwops.h in the latest CVS snapshot of SDL. :slight_smile:

    -Sam Lantinga                           (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software

“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

I have just downloaded the newest version of gimp, It alows you to save an
image as c-source code it gives bits per pixel, height, width, and of
course the pixels. I have included a sample file the image is 40x40 and is
a BMP in c-source code. Can you possibly give me a hint as how to use this
source code with SDL to display this image? Please see the attached source
file.
-------------- next part --------------
/* GIMP RGB C-Source image dump (/root/pengin_saviour/test.c) */

#include <stdio.h>
#include <stdlib.h>

static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA /
unsigned char pixel_data[40 * 40 * 3];
} gimp_image = {
40, 40, 3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H"\233H"\233H\0\0\0"
"\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H\0\0\0\0\0\0\0\0\0\0\0\0”\233H"\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0"\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233"
“H”\233H"\233H"\233H"\233H\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233"
“H”\233H"\233H"\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0"\233H"\233H"\233H"\233H"\233H"\233H\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0"\233H"\233H\0\0\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0"\233"
“H”\233H"\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H"\233"
“H”\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H\0\0\0\0"
"\0\0wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL"
"\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0"\233H"\233H"\233H"\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0"\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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26\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26"
“wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26"
“wL\26\0\0\0\0\0\0\0\0\0”\233H\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26"
”\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26"
“wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26"
“wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26wL\26"
“wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0"
”\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL”
”\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26\0\0\0\0\0"
”\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26\0\0\0\0\0"
”\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0"
“wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26\0\0"
”\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26\0\0"
”\0\0\0\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
”\0\0\0wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26"
”\0\0\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
”\0\0\0wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26"
"wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26w”
"L\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
"wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26w”
“L\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26"
“wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26wL\26wL\26"
“wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26w”
“L\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
”\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26wL\26wL”
”\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
”\0\0\0\0\0\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
”\0\0\0\0\0\0\0\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26w”
“L\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26w”
"L\26wL\26wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0L
\4L*\4L*\4L*\4"
"\0\0\0\0\0\0\0\0\0wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26"
“wL\26wL\26wL\26wL\26wL\26wL\26wL\26\0\0\0\0\0\0\0\0\0L*\4L*\4L*\4L*\4\0\0"
”\0\0\0\0\0\0\0wL\26wL\26\0\0\0\0\0\0\0\0\0\0\0\0wL\26wL\26wL\26wL\26wL\26"
“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\0\0\0\0wL\26wL\26wL\26\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H"\233"
“H”\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0"\233H"\233H"\233H"\233H"\233H"\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233H"\233H"\233H"
""\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H""
"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233H"\233"
“H”\233H"\233H",
};

Cool! I didn’t realize gimp could do that. Reminds me of an old DOS text screen
program I used to use (TheDraw or something …) anyway …

I doubt that the file you attached is really a .BMP (I assume that’s what you
meant, sorry if not :slight_smile: To use it you could just blit (or convert) the
gimp_image.pixel_data buffer to wherever you want it, as it’s just raw
RGB graphics data.

/devOn 20-Jul-99 Mark Huff II wrote:

Sam Lantinga wrote:
I have just downloaded the newest version of gimp, It alows you to save an
image as c-source code it gives bits per pixel, height, width, and of
course the pixels. I have included a sample file the image is 40x40 and is
a BMP in c-source code. Can you possibly give me a hint as how to use this
source code with SDL to display this image? Please see the attached source
file.


// David E. Vandewalle | The road to hell is paved with NAND gates.
// vandewal at skyblue.com | – J. Gooding
// david.e.vandewalle at lmco.com |

meant, sorry if not :slight_smile: To use it you could just blit (or convert) the
gimp_image.pixel_data buffer to wherever you want it, as it’s just raw
RGB graphics data.

He may not mean .BMP's file format - http://wotsit.org/cgi-bin/download.cgi?bmp :), but bitmaps. The definition of a bitmap is an array of pixels. The difference between that and a sprite is that a sprite has pixels that are non-opaque.

Anyways, I actually wrote a piece of GPL’d software a year ago that crops a
bitmap from a PCX file and outputs the raw data along with two ints: width
and height. http://creativeforces.dhs.org/sanctuary/gametools/index.html
Linux users may wish to check it out. It’s svgalib, but it only requires
320x200x256 colour support.

Anyways, yesterday was the third day of me using the graphics side of SDL,
and I decided to try and load up one of my raw images.

Here’s some of my code, chopped:

–Begin Code
/* Assume RawImage is the bitmap in the old form, and SDLImage is /
/
a pointer to SDL_Surface */

SDLImage = SDL_AllocSurface(SDL_SWSURFACE, RawImage->width,
RawImage->height, 8, /I have no real idea what these four params do other
than they are RGBA
/ 0xFF000000, 0x00FF0000, 0x0000FF00, 0);

/* This line is probably wrong, because I don’t know the format of
SDLImage->pixels very well: */

SDLImage->pixels = RawImage->imgdata;
SDL_MapSurface(SDLImage, Screen->format);

/* Some stuff about assigning a SDL_Rect called dest boring values chopped
*/

SDL_BlitSurface(SDLImage, NULL, Screen, &dest);
SDL_UpdateRects(Screen, 1, &dest);

–End Code

Okay, I probably just made a bit of a blithering idiot of myself by pasting
code that deals with a file format made by myself, and not really used by
anyone else to date. :slight_smile:

The end result of the code is that it turns up blank on the screen. No
segfault.

If anyone would be interested in looking at the full 110 lines of rawdraw.c,
e-mail me.______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

I have just downloaded the newest version of gimp, It alows you to save an
image as c-source code it gives bits per pixel, height, width, and of
course the pixels. I have included a sample file the image is 40x40 and is
a BMP in c-source code. Can you possibly give me a hint as how to use this
source code with SDL to display this image? Please see the attached source
file.

That is very cool. I didn’t know the GIMP could do that.

Here is code to view those images from within SDL. :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec
-------------- next part --------------

#include <stdio.h>
#include “SDL.h”

/* Include the GIMP created image */
#include “gimp_image.c”

main()
{
SDL_Surface *screen, *image;

if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
	fprintf(stderr, "Couldn't init SDL: %s\n", SDL_GetError());
	exit(1);
}
atexit(SDL_Quit);

screen = SDL_SetVideoMode(gimp_image.width, gimp_image.height, 0, 0);
if ( screen == NULL ) {
	fprintf(stderr, "Couldn't set video mode: %s\n",SDL_GetError());
	exit(1);
}

/* A sneaky way of getting our image in a format SDL can use */
switch (gimp_image.bytes_per_pixel) {
    case 3:
	/* 24-bit RGB */
	image = SDL_AllocSurface(SDL_SWSURFACE, 0, 0, 24, 0, 0, 0, 0);
	break;
    case 4:
	/* 32-bit RGBA */
	image = SDL_AllocSurface(SDL_SWSURFACE, 0, 0, 32,
			0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
	break;
    default:
	/* Um, guess. :) */
	image = SDL_AllocSurface(SDL_SWSURFACE, 0, 0,
			gimp_image.bytes_per_pixel*8, 0, 0, 0, 0);
	break;
}
if ( image == NULL ) {
	fprintf(stderr, "Couldn't create image: %s\n", SDL_GetError());
	exit(1);
}
image->w = gimp_image.width;
image->h = gimp_image.height;
image->pitch = gimp_image.width * gimp_image.bytes_per_pixel;
image->pixels = (void *)gimp_image.pixel_data;

/* Show the image */
SDL_BlitSurface(image, NULL, screen, NULL);
SDL_UpdateRect(screen, 0, 0, 0, 0);

/* Wait for a keystroke or quit request */
while ( ! SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT,
			SDL_KEYDOWNMASK|SDL_QUITMASK) ) {
	SDL_Delay(100);
	SDL_PumpEvents();
}

/* Free the gimp image
   - be sure to set pixels NULL so SDL doesn't free them!
 */
image->pixels = NULL;
SDL_FreeSurface(image);

/* We're outta here! */
exit(0);

}

source code with SDL to display this image? Please see the attached source
file.

That is very cool. I didn’t know the GIMP could do that.

Agreed - this solves a strange problem I had with Windows-Linux
displaying images differently.–
±---------------------------------------------------------+
Paul Furber, TML Trade Publishing
"I’ll tell you what’s wrong with the scientific power you’re
wielding - it didn’t require any discipline to attain it"
Dr. Malcom, Jurassic Park