You are not logged in.

#1 2009-09-04 17:38:58

elisherer
Member

GRRLIB_BMFX_Sepia

Code:

/**
 * Change a texture to sepia (old photo style).
 * @see GRRLIB_FlushTex
 * @param texsrc The texture source.
 * @param texdest The texture grayscaled destination.
 */
void  GRRLIB_BMFX_Sepia (const GRRLIB_texImg *texsrc,
                             GRRLIB_texImg *texdest) {
    unsigned int x, y;
    u16 sr,sg,sb;
    u32 color;

    for (y = 0; y < texsrc->h; y++) {
    for (x = 0; x < texsrc->w; x++) {
        color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
        sr = R(color)*0.393 + G(color)*0.769 + B(color)*0.189;
        sg = R(color)*0.349 + G(color)*0.686 + B(color)*0.168;
        sb = R(color)*0.272 + G(color)*0.534 + B(color)*0.131;
        if (sr>255) sr=255; if (sg>255) sg=255; if (sb>255) sb=255;
        GRRLIB_SetPixelTotexImg(x, y, texdest,GRRLIB_GetColor(sr,sg,sb,color&0xFF));
    }
    }
    GRRLIB_SetHandle( texdest, 0, 0 );
}

based on the Grayscale effect combined with the Sepia ColorMatrix! enjoy

Offline

 

#2 2009-09-04 17:58:58

Crayon
Bad Mother Fucker

Re: GRRLIB_BMFX_Sepia

That's nice, I'm going to test it and certainly add it to the project (GRRLIB_bmfx.c) and lesson 2 this weekend. Thanks.

Offline

 

#3 2009-09-04 18:07:11

BlueChip
Moderator

Re: GRRLIB_BMFX_Sepia

Cheers dude smile
svn update wink


I can be found on efnet, freenode, msn, gtalk, aim, ychat & icq ...PM me for details

Offline

 

#4 2009-09-04 18:08:01

BlueChip
Moderator

Re: GRRLIB_BMFX_Sepia

LOL we both hit send at the same time
I will let you update the demo smile


I can be found on efnet, freenode, msn, gtalk, aim, ychat & icq ...PM me for details

Offline

 

Board footer

Powered by FluxBB