Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Premultiply posterization results
Browse files Browse the repository at this point in the history
Instead of leaving it unpremultiplied and generating invalid pixels.
  • Loading branch information
askmeaboutlo0m committed Mar 21, 2023
1 parent a21af73 commit fd13fa1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libengine/dpengine/pixels.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ static DP_Pixel15 from_bgra(BGRA15 bgra)
};
}

static DP_Pixel15 from_ubgra(BGRA15 bgra)
{
return DP_pixel15_premultiply((DP_UPixel15){
.b = from_fix(bgra.b),
.g = from_fix(bgra.g),
.r = from_fix(bgra.r),
.a = from_fix(bgra.a),
});
}


uint16_t DP_fix15_mul(uint16_t a, uint16_t b)
{
Expand Down Expand Up @@ -2089,6 +2099,6 @@ void DP_posterize_mask(DP_Pixel15 *dst, int posterize_num, const uint16_t *mask,
Fix15 ofix = to_fix(opacity);
float p = DP_int_to_float(posterize_num);
FOR_MASK_PIXEL(dst, mask, ofix, w, h, mask_skip, base_skip, x, y, o, {
*dst = from_bgra(posterize(p, o, DP_pixel15_unpremultiply(*dst)));
*dst = from_ubgra(posterize(p, o, DP_pixel15_unpremultiply(*dst)));
});
}

0 comments on commit fd13fa1

Please sign in to comment.