Changed a way how RGB images are saving from RGBA

Before alpha channel was simply ignored causing bad looking
straight colors which is pretty much useless.

Now saving RGB would alpha-over image on top of black color,
which makes final image look really nice. It's also very
such the same what other graphics software does this.

In the future we could easily support configurable backdrop
color, which would be really the same as other SW does it.

Also, it'll probably worth adding the same mode to RGB
display of image editor.
This commit is contained in:
2013-02-28 14:25:26 +00:00
parent bad03bcfb1
commit 47d6d18771
2 changed files with 40 additions and 7 deletions

View File

@@ -367,9 +367,9 @@ void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol
else {
int mul = 255 - cp[3];
cp[0] += mul * backcol[0] / 255;
cp[1] += mul * backcol[1] / 255;
cp[2] += mul * backcol[2] / 255;
cp[0] = (cp[0] * cp[3] >> 8) + mul * backcol[0] / 255;
cp[1] = (cp[1] * cp[3] >> 8) + mul * backcol[1] / 255;
cp[2] = (cp[2] * cp[3] >> 8) + mul * backcol[2] / 255;
}
cp[3] = 255;