42 SDL_RWread (file, sign, 1, 2);
43 if ((sign[0] !=
'P') || (sign[1] !=
'6'))
45 printf (
"Invalid format.\n");
48 pnm_gotonextline (file);
50 while (pnm_checkforcomment (file));
53 SDL_RWread (file, &sign[i], 1, 1);
56 while (sign[i - 1] !=
' ');
62 SDL_RWread (file, &sign[i], 1, 1);
65 while (sign[i - 1] !=
'\n');
69 pnm_gotonextline (file);
71 image = calloc (l * h, 3);
72 SDL_RWread (file, image, 1, l * h * 3);
84 sprintf (s,
"P6\n%d %d\n255\n", length, height);
85 SDL_RWwrite (file, s,
sizeof (
char), strlen (s));
87 SDL_RWwrite (file, image, 1, length * height * 3);
97 void pnm::pnm_gotonextline (SDL_RWops * file)
103 SDL_RWread (file, &buff, 1, 1);
105 while (buff !=
'\n');
108 int pnm::pnm_checkforcomment (SDL_RWops * file)
112 SDL_RWread (file, &buff, 1, 1);
115 pnm_gotonextline (file);
120 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.