It is currently Tue Nov 21, 2017 2:35 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 5:45 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
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
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 5:53 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5824
Location: Canada
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
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 6:22 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3075
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
Rockman 5 - Blues no Wana! (J) 009.bmp [ 900.05 KiB | Viewed 429 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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 3 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group