IMG_pnm.c
changeset 320 aa5d55b11751
parent 280 ec4ae96c100c
child 343 5bf0f0d6a74e
equal deleted inserted replaced
319:e7feb0dbe64f 320:aa5d55b11751
   147 	/* binary PNM allows just a single character of whitespace after
   147 	/* binary PNM allows just a single character of whitespace after
   148 	   the last parameter, and we've already consumed it */
   148 	   the last parameter, and we've already consumed it */
   149 
   149 
   150 	if(kind == PPM) {
   150 	if(kind == PPM) {
   151 		/* 24-bit surface in R,G,B byte order */
   151 		/* 24-bit surface in R,G,B byte order */
   152 		surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, 24,
   152 		surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24,
   153 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
   153 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
   154 					   0x000000ff, 0x0000ff00, 0x00ff0000,
   154 					   0x000000ff, 0x0000ff00, 0x00ff0000,
   155 #else
   155 #else
   156 					   0x00ff0000, 0x0000ff00, 0x000000ff,
   156 					   0x00ff0000, 0x0000ff00, 0x000000ff,
   157 #endif
   157 #endif
   158 					   0);
   158 					   0);
   159 	} else {
   159 	} else {
   160 		/* load PBM/PGM as 8-bit indexed images */
   160 		/* load PBM/PGM as 8-bit indexed images */
   161 		surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, 8,
   161 		surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 8,
   162 					   0, 0, 0, 0);
   162 					   0, 0, 0, 0);
   163 	}
   163 	}
   164 	if ( surface == NULL )
   164 	if ( surface == NULL )
   165 		ERROR("Out of memory");
   165 		ERROR("Out of memory");
   166 	bpl = width * surface->format->BytesPerPixel;
   166 	bpl = width * surface->format->BytesPerPixel;