mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
rgb_greyscale: linear approximation to gamma decomp
This commit is contained in:
parent
fe2dcc3387
commit
5d69545f22
@ -18,8 +18,8 @@ int box_demo(struct notcurses* nc){
|
||||
}
|
||||
struct timespec start, now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
int zbonus = 0;
|
||||
int zbonusdelta = 16;
|
||||
int zbonus = 40;
|
||||
int zbonusdelta = 20;
|
||||
int ylen, xlen;
|
||||
ncplane_dim_yx(n, &ylen, &xlen);
|
||||
// target grid is 7x7
|
||||
|
@ -1718,7 +1718,8 @@ rgb_greyscale(int r, int g, int b){
|
||||
if(b < 0 || b > 255){
|
||||
return -1;
|
||||
}
|
||||
float fg = (0.2126 * (r / 255.0) + 0.7152 * (g / 255.0) + 0.0722 * (b / 255.0));
|
||||
// Use Rec. 601 scaling plus linear approximation of gamma decompression
|
||||
float fg = (0.299 * (r / 255.0) + 0.587 * (g / 255.0) + 0.114 * (b / 255.0));
|
||||
return fg * 255;
|
||||
}
|
||||
|
||||
@ -1729,7 +1730,6 @@ void ncplane_greyscale(ncplane *n){
|
||||
cell* c = &n->fb[nfbcellidx(n, y, x)];
|
||||
unsigned r, g, b;
|
||||
cell_fg_rgb(c, &r, &g, &b);
|
||||
// Use Rec. 601 scaling
|
||||
int gy = rgb_greyscale(r, g, b);
|
||||
cell_set_fg_rgb(c, gy, gy, gy);
|
||||
cell_bg_rgb(c, &r, &g, &b);
|
||||
|
Loading…
Reference in New Issue
Block a user