I have here some GIMP C-source dump made from .png picture. It is a
structure and has some pixel
data size member (pixel_data[15 * 15 * 4 + 1]).
A whole bunch of files. Just put your files into somefiles.h/c. And size
matters, take the size the filesize of the original file on your disk. Not
the length of the string, the size of the variable, the size of the image
data at some color depth, only the size of the file as it would be stored
else. The PBM file had a size of 11, but for the C string representation i
needed to convert the newlines to \n, but this does not change the size.
There’s no way to determine the size from within C if you don’t use
something like uuencode, base64 or something like this.
linkedinfile.h:
#ifndef LINKEDINFILE_H_
#define LINKEDINFILE_H_
#include <SDL/SDL_rwops.h>
typedef struct LinkedInFile {
unsigned int size;
char *data;
} LinkedInFile;
SDL_RWops* GetRWops(LinkedInFile src);
#endif /* LINKEDINFILE_H_ */
linkedinfile.c
#include “linkedinfile.h”
SDL_RWops* GetRWops(LinkedInFile src) {
return SDL_RWFromConstMem(src.data, src.size);
}
somefiles.h
#ifndef SOMEFILES_H_
#define SOMEFILES_H_
#include “linkedinfile.h”
extern LinkedInFile myfirstfile;
#endif /* SOMEFILES_H_ */
somefiles.c
#include “linkedinfile.h”
/* Image in PBM(PNM) Format */
LinkedInFile myfirstfile = {11,“P1\n2 2\n1001”};
main.c
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include “somefiles.h”
#include “stdio.h”
int main(int argc, char **argv) {
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(100,100,0,0);
SDL_RWops *rwops = GetRWops(myfirstfile);
SDL_Surface *image = IMG_Load_RW(rwops, 1);
printf(“image size: %dx%d\n”, image->w, image->h);
return 0;
}On Thu, 04 Feb 2010 03:52:48 -0800, “dekyco” wrote:
–
Christoph Nelles
E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723
PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt