40 SDL_RWread (file, sign, 1, 2);
41 if ((sign[0] !=
'P') || (sign[1] !=
'6'))
43 printf (
"Invalid format.\n");
46 pnm_gotonextline (file);
48 while (pnm_checkforcomment (file));
51 SDL_RWread (file, &sign[i], 1, 1);
54 while (sign[i - 1] !=
' ');
60 SDL_RWread (file, &sign[i], 1, 1);
63 while (sign[i - 1] !=
'\n');
67 pnm_gotonextline (file);
69 image = calloc (l * h, 3);
70 SDL_RWread (file, image, 1, l * h * 3);
82 sprintf (s,
"P6\n%d %d\n255\n", length, height);
83 SDL_RWwrite (file, s,
sizeof (
char), strlen (s));
85 SDL_RWwrite (file, image, 1, length * height * 3);
95 void pnm::pnm_gotonextline (SDL_RWops * file)
101 SDL_RWread (file, &buff, 1, 1);
103 while (buff !=
'\n');
106 int pnm::pnm_checkforcomment (SDL_RWops * file)
110 SDL_RWread (file, &buff, 1, 1);
113 pnm_gotonextline (file);
118 SDL_RWseek (file, -1, SEEK_CUR);
#define u_int16
16 bits long unsigned integer
static void put(SDL_RWops *file, void *image, u_int16 length, u_int16 height)
Saves a PNM image into an opened file.
Image manipulation class.
#define u_int32
32 bits long unsigned integer
Declares the pnm static class.
static void * get(SDL_RWops *file, u_int16 *length, u_int16 *height)
Reads a PNM image from an opened file.