- Joined
- Mar 11, 2004
- Messages
- 600
Is anybody else tired of people saying SUcks! it is a recolor! burn da witch! ?
Well I am tired of them.
recoloring actually takes skill, seriously.
This is what takes to take a texture and recolor it to green:
edit: note that those symbols were white on white background so they were invisible, after recolor they got visible, demonstrating that recolor is also very useful
Well I am tired of them.
recoloring actually takes skill, seriously.
This is what takes to take a texture and recolor it to green:
Code:
SDL_Surface* GreenIFy(SDL_Surface* src)
{
//SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Uint32 rmask,gmask,bmask,amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
Uint32 w=src->w,h=src->h;
SDL_Surface* r = SDL_CreateRGBSurface(SDL_SRCALPHA|SDL_HWSURFACE,w,h,32, rmask, gmask, bmask, amask);
Uint8 bp= (src->format->BytesPerPixel);
SDL_LockSurface(r);
SDL_LockSurface(src);
Uint32 tm=0,tm2=0;
Uint8* src_pix= (Uint8*)(src->pixels);
Uint8* r_pix= (Uint8*)(r->pixels);
Uint8 rd=0,g=0,b=0,a=0,aux=0;
Uint32 i,j;
for (i=0;i<w;i++)
for (j=0;j<h;j++)
{
tm= *((Uint32*)(src_pix));
SDL_GetRGBA(tm, src->format, &rd, &g, &b, &a);
aux= (Uint32)((rd+g+b)/3);
rd=b=0;
g=aux;
tm = SDL_MapRGBA( r->format, rd, g ,b, a );
(*(Uint32*)(r_pix) ) = tm;
src_pix+=bp;
r_pix+=4;
}
SDL_UnlockSurface(r);
SDL_UnlockSurface(src);
return(r);
}
edit: note that those symbols were white on white background so they were invisible, after recolor they got visible, demonstrating that recolor is also very useful