Sepia tunes?

A place for your artistic side. Discuss techniques and tools for pixel art on the NES, GBC, or similar platforms.

Moderator: Moderators

User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Sepia tunes?

Post by Zepper »

Not working, I get shades of blue. Since I use integer values, I'm adding cast to float. Not sure if correct though.

Code: Select all

p->red = (int)pow((float)p->red, 1.0 / 2.2); // R ^ (1 / 2.2)
p->green = (int)pow((float)p->green, 1.0 / 1.1); // G ^ (1 / 1.1)
p->blue = (int)pow((float)p->blue, 1.0 / 0.55); // B ^ (1 / .55)
Is something obviously wrong here??
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Sepia tunes?

Post by rainwarrior »

Yes. You need to convert the ranges, not just cast to float and back to integer. The naive version of this looks like:

Code: Select all

float fr = float(r) / 255.0; // convert 0-255 unsigned char to 0-1 float
unsigned char ir = int(fr * 255.0); // convert 0-1 float to 0-255 unsigned char
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Sepia tunes?

Post by Zepper »

Using the RGB triplet doesn't give the expected result - must be monochrome! So, I decided to convert it to grayscale, then to sepia using the brightness level for each new RGB triplet. The result is below.
Attachments
Rockman 5 - Blues no Wana! (J) 009.bmp
Post Reply