nesdev.com
http://forums.nesdev.com/

Sepia tunes?
http://forums.nesdev.com/viewtopic.php?f=21&t=13332
Page 2 of 2

Author:  Zepper [ Mon Oct 05, 2015 5:45 pm ]
Post subject:  Re: Sepia tunes?

Not working, I get shades of blue. Since I use integer values, I'm adding cast to float. Not sure if correct though.
Code:
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??

Author:  rainwarrior [ Mon Oct 05, 2015 5:53 pm ]
Post subject:  Re: Sepia tunes?

Yes. You need to convert the ranges, not just cast to float and back to integer. The naive version of this looks like:
Code:
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

Author:  Zepper [ Mon Oct 05, 2015 6:22 pm ]
Post subject:  Re: Sepia tunes?

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
Rockman 5 - Blues no Wana! (J) 009.bmp [ 900.05 KiB | Viewed 414 times ]

Page 2 of 2 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/