use premultiplied colors on the EFL side

This commit is contained in:
Vincent Torri 2023-09-17 15:25:23 +02:00 committed by Gitea
parent 8576ac9128
commit 4b443e752f
2 changed files with 13 additions and 4 deletions

View File

@ -262,7 +262,16 @@ evas_image_load_file_data_qoi_internal(Evas_Loader_Internal *loader EINA_UNUSED,
index[QOI_COLOR_HASH(px) % 64] = px;
}
*iter = ((prop->alpha ? px.rgba.a : 255) << 24) | (px.rgba.r << 16) | (px.rgba.g << 8) | px.rgba.b;
if (prop->alpha)
*iter = (px.rgba.a << 24) |
(((px.rgba.r * px.rgba.a) / 255) << 16) |
(((px.rgba.g * px.rgba.a) / 255) << 8) |
(((px.rgba.b * px.rgba.a) / 255));
else
*iter = (255 << 24) |
(px.rgba.r << 16) |
(px.rgba.g << 8) |
(px.rgba.b);
}
*error = EVAS_LOAD_ERROR_NONE;

View File

@ -115,10 +115,10 @@ save_image_qoi(RGBA_Image *im, const char *file, int quality EINA_UNUSED)
iter = (unsigned char *)im->image.data;
for (px_pos = 0; px_pos < px_len; px_pos += channels, iter +=4)
{
px.rgba.b = *(iter + 0);
px.rgba.g = *(iter + 1);
px.rgba.r = *(iter + 2);
px.rgba.a = *(iter + 3);
px.rgba.b = *(iter + 0) * 255 / px.rgba.a;
px.rgba.g = *(iter + 1) * 255 / px.rgba.a;
px.rgba.r = *(iter + 2) * 255 / px.rgba.a;
if (px.v == px_prev.v)
{