2013-06-20 03:53:29 -07:00
|
|
|
#include "evas_common_private.h"
|
2008-07-10 15:53:33 -07:00
|
|
|
#include "evas_convert_gry_8.h"
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2009-11-06 07:15:37 -08:00
|
|
|
#ifdef USE_DITHER_44
|
|
|
|
extern const DATA8 _evas_dither_44[4][4];
|
|
|
|
#endif
|
|
|
|
#ifdef USE_DITHER_128128
|
|
|
|
extern const DATA8 _evas_dither_128128[128][128];
|
|
|
|
#endif
|
|
|
|
|
2012-11-04 03:51:42 -08:00
|
|
|
void evas_common_convert_rgba_to_8bpp_gry_256_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
|
2009-11-06 07:15:37 -08:00
|
|
|
{
|
|
|
|
DATA32 *src_ptr;
|
|
|
|
DATA8 *dst_ptr;
|
|
|
|
int x, y;
|
|
|
|
DATA8 r, g, b;
|
|
|
|
DATA32 gry8;
|
|
|
|
|
|
|
|
dst_ptr = (DATA8 *)dst;
|
|
|
|
|
|
|
|
CONVERT_LOOP_START_ROT_0();
|
|
|
|
|
|
|
|
r = (R_VAL(src_ptr));
|
|
|
|
g = (G_VAL(src_ptr));
|
|
|
|
b = (B_VAL(src_ptr));
|
|
|
|
|
|
|
|
// Y = 0.299 * R + 0.587 * G + 0.114 * B;
|
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
2020-03-13 01:54:54 -07:00
|
|
|
gry8 = ((r * 19596) + (g * 38470) + (b * 7472)) >> 16;
|
2009-11-06 07:15:37 -08:00
|
|
|
|
|
|
|
*dst_ptr = gry8;
|
|
|
|
|
|
|
|
CONVERT_LOOP_END_ROT_0();
|
|
|
|
}
|
2008-07-10 15:53:33 -07:00
|
|
|
|
2012-11-04 03:51:42 -08:00
|
|
|
void evas_common_convert_rgba_to_8bpp_gry_64_dith (DATA32 *src EINA_UNUSED, DATA8 *dst EINA_UNUSED, int src_jump EINA_UNUSED, int dst_jump EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED){}
|
2008-07-10 15:53:33 -07:00
|
|
|
|
2012-11-04 03:51:42 -08:00
|
|
|
void evas_common_convert_rgba_to_8bpp_gry_16_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal EINA_UNUSED)
|
2009-11-06 07:15:37 -08:00
|
|
|
{
|
|
|
|
DATA32 *src_ptr;
|
|
|
|
DATA8 *dst_ptr;
|
|
|
|
int x, y;
|
|
|
|
DATA8 r, g, b;
|
|
|
|
DATA32 gry8;
|
2009-12-21 07:52:12 -08:00
|
|
|
DATA8 dith;
|
2009-11-06 07:15:37 -08:00
|
|
|
|
|
|
|
dst_ptr = (DATA8 *)dst;
|
|
|
|
|
|
|
|
CONVERT_LOOP_START_ROT_0();
|
|
|
|
|
|
|
|
dith = DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK] >> DM_SHF(4);
|
|
|
|
|
|
|
|
r = (R_VAL(src_ptr));
|
|
|
|
g = (G_VAL(src_ptr));
|
|
|
|
b = (B_VAL(src_ptr));
|
|
|
|
|
|
|
|
// Y = 0.299 * R + 0.587 * G + 0.114 * B;
|
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
2020-03-13 01:54:54 -07:00
|
|
|
gry8 = ((r * 19596) + (g * 38470) + (b * 7472)) >> 16;
|
2009-11-06 07:15:37 -08:00
|
|
|
|
|
|
|
if (((gry8 - gry8 * 255 / 4) >= dith) && (gry8 < 0x07)) gry8++;
|
|
|
|
|
|
|
|
*dst_ptr = gry8;
|
|
|
|
|
|
|
|
CONVERT_LOOP_END_ROT_0();
|
|
|
|
}
|
2008-07-10 15:53:33 -07:00
|
|
|
|
2012-11-04 03:51:42 -08:00
|
|
|
void evas_common_convert_rgba_to_8bpp_gry_4_dith (DATA32 *src EINA_UNUSED, DATA8 *dst EINA_UNUSED, int src_jump EINA_UNUSED, int dst_jump EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED){}
|
2008-07-10 15:53:33 -07:00
|
|
|
|
2012-11-04 03:51:42 -08:00
|
|
|
void evas_common_convert_rgba_to_8bpp_gry_1_dith (DATA32 *src EINA_UNUSED, DATA8 *dst EINA_UNUSED, int src_jump EINA_UNUSED, int dst_jump EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED){}
|