It is currently Sat Sep 22, 2018 9:29 am

 All times are UTC - 7 hours

 Page 2 of 2 [ 18 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Sepia tunes?Posted: Mon Oct 05, 2015 5:45 pm
 Formerly Fx3

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3154
Location: Brazil
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??

Top

 Post subject: Re: Sepia tunes?Posted: Mon Oct 05, 2015 5:53 pm

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6817
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

Top

 Post subject: Re: Sepia tunes?Posted: Mon Oct 05, 2015 6:22 pm
 Formerly Fx3

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3154
Location: Brazil
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 [ 900.05 KiB | Viewed 707 times ]
Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 18 posts ] Go to page Previous  1, 2

 All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki