forked from enlightenment/efl
evas: handle premultiplying of AGRY88.
This commit is contained in:
parent
516ee8c99e
commit
eb7071078a
|
@ -1,6 +1,26 @@
|
||||||
#include "evas_common_private.h"
|
#include "evas_common_private.h"
|
||||||
#include "evas_convert_color.h"
|
#include "evas_convert_color.h"
|
||||||
|
|
||||||
|
EAPI DATA32
|
||||||
|
evas_common_convert_ag_premul(DATA16 *data, unsigned int len)
|
||||||
|
{
|
||||||
|
DATA16 *de = data + len;
|
||||||
|
DATA32 nas = 0;
|
||||||
|
|
||||||
|
while (data < de)
|
||||||
|
{
|
||||||
|
DATA16 a = 1 + ((*data >> 8) & 0xff);
|
||||||
|
|
||||||
|
*data = (*data & 0xff00) |
|
||||||
|
((((*data & 0xff) * a) >> 8) & 0xff);
|
||||||
|
data++;
|
||||||
|
|
||||||
|
if ((a == 1) || (a == 256))
|
||||||
|
nas++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nas;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI DATA32
|
EAPI DATA32
|
||||||
evas_common_convert_argb_premul(DATA32 *data, unsigned int len)
|
evas_common_convert_argb_premul(DATA32 *data, unsigned int len)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _EVAS_CONVERT_COLOR_H
|
#define _EVAS_CONVERT_COLOR_H
|
||||||
|
|
||||||
|
|
||||||
|
EAPI DATA32 evas_common_convert_ag_premul (DATA16 *data, unsigned int len);
|
||||||
EAPI DATA32 evas_common_convert_argb_premul (DATA32 *src, unsigned int len);
|
EAPI DATA32 evas_common_convert_argb_premul (DATA32 *src, unsigned int len);
|
||||||
EAPI void evas_common_convert_argb_unpremul (DATA32 *src, unsigned int len);
|
EAPI void evas_common_convert_argb_unpremul (DATA32 *src, unsigned int len);
|
||||||
EAPI void evas_common_convert_color_argb_premul (int a, int *r, int *g, int *b);
|
EAPI void evas_common_convert_color_argb_premul (int a, int *r, int *g, int *b);
|
||||||
|
|
|
@ -998,7 +998,15 @@ evas_common_image_premul(Image_Entry *ie)
|
||||||
if (!evas_cache_image_pixels(ie)) return;
|
if (!evas_cache_image_pixels(ie)) return;
|
||||||
if (!ie->flags.alpha) return;
|
if (!ie->flags.alpha) return;
|
||||||
|
|
||||||
nas = evas_common_convert_argb_premul(evas_cache_image_pixels(ie), ie->w * ie->h);
|
switch (ie->space)
|
||||||
|
{
|
||||||
|
case EVAS_COLORSPACE_ARGB8888:
|
||||||
|
nas = evas_common_convert_argb_premul(evas_cache_image_pixels(ie), ie->w * ie->h);
|
||||||
|
break;
|
||||||
|
case EVAS_COLORSPACE_AGRY88:
|
||||||
|
nas = evas_common_convert_ag_premul((void*) evas_cache_image_pixels(ie), ie->w * ie->h);
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h))
|
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h))
|
||||||
ie->flags.alpha_sparse = 1;
|
ie->flags.alpha_sparse = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue