0 Members and 3 Guests are viewing this topic.
"welcome to the world of computers, where everything seems to be based on random number generators"
SDL_Color rgb16to24(Uint16 x){ SDL_Color newcolor; newcolor.b= (x & 0x1F) * 8; newcolor.g = ((x >> 5) & 0x2F)* 4; newcolor.r = ((x >> 11) & 0x1F)* 8; return newcolor;}SDL_Surface* LoadSCImage(Uint16* pallete, int paletteSize, unsigned char* image, int x, int y){ int i, j; SDL_Color newColors[paletteSize]; for (i = 0; i < paletteSize; i++) { newColors[i] = rgb16to24(pallete[i]); } SDL_Surface *tempsurf = SDL_CreateRGBSurface( SDL_SWSURFACE, x, y, 8, 0,0,0,0); for (i = 0; i < y; i++) { for (j=0; j < x; j++) { *(Uint8 *)(tempsurf->pixels + i*tempsurf->pitch + j) = image[i*x + j]; } } SDL_SetColors(tempsurf, newColors, 0, paletteSize); return tempsurf;}
SDL_Surface* LoadSCImage(Uint16* image, int x, int y){ SDL_Surface *rimage, *tempsurf = SDL_CreateRGBSurfaceFrom(image, x, y, 16, 2*x, PZM_RMASK16,PZM_GMASK16,PZM_BMASK16,0); rimage = SDL_DisplayFormat(tempsurf); SDL_FreeSurface(tempsurf); return rimage;}