evas_common: rgba32 to Y8 (Enhance Conversion)

Summary:
Made small change to expand mapping range by using celling values.
Now : rgb(255,255,255)   ->  y(255)
Now : rgb(1  , 1 ,1  )   ->  y(1)

Old : rgb(255,255,255)   ->  y(254)
Old : rgb(1  ,  1,  1)   ->  y(0)

It is important for white point convert to not loss any value

Test Plan:
```
#include <stdio.h>

int main()
{
    unsigned char r =255, g =255,b =255;
    unsigned int gry8_old = ((r * 19595) + (g * 38469) + (b * 7471)) >> 16;
    unsigned int gry8_new = ((r * 19596) + (g * 38470) + (b * 7472)) >> 16;

    printf("gry_old=%i\n",gry8_old);
    printf("gry_new=%i\n",gry8_new);

    return 0;
}

```

Reviewers: cedric, raster, zmike, vtorri, Hermet, woohyun, bu5hm4n, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: segfaultxavi, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9490
This commit is contained in:
Ali Alzyod 2020-03-13 09:54:54 +01:00 committed by Xavi Artigas
parent e8100fa8b0
commit ba1a326a57
1 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ void evas_common_convert_rgba_to_8bpp_gry_256_dith (DATA32 *src, DATA8 *dst,
b = (B_VAL(src_ptr));
// Y = 0.299 * R + 0.587 * G + 0.114 * B;
gry8 = ((r * 19595) + (g * 38469) + (b * 7471)) >> 16;
gry8 = ((r * 19596) + (g * 38470) + (b * 7472)) >> 16;
*dst_ptr = gry8;
@ -54,7 +54,7 @@ void evas_common_convert_rgba_to_8bpp_gry_16_dith (DATA32 *src, DATA8 *dst,
b = (B_VAL(src_ptr));
// Y = 0.299 * R + 0.587 * G + 0.114 * B;
gry8 = ((r * 19595) + (g * 38469) + (b * 7471)) >> 16;
gry8 = ((r * 19596) + (g * 38470) + (b * 7472)) >> 16;
if (((gry8 - gry8 * 255 / 4) >= dith) && (gry8 < 0x07)) gry8++;