fix [#28430] Image with Stampinfo does not get saved correctly with alpha
This commit is contained in:
@@ -213,7 +213,7 @@ void blf_font_buffer(FontBLF *font, const char *str)
|
|||||||
{
|
{
|
||||||
unsigned char *cbuf;
|
unsigned char *cbuf;
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
unsigned char b_col_char[3];
|
unsigned char b_col_char[4];
|
||||||
GlyphBLF *g, *g_prev;
|
GlyphBLF *g, *g_prev;
|
||||||
FT_Vector delta;
|
FT_Vector delta;
|
||||||
FT_UInt glyph_index;
|
FT_UInt glyph_index;
|
||||||
@@ -232,6 +232,7 @@ void blf_font_buffer(FontBLF *font, const char *str)
|
|||||||
b_col_char[0]= font->b_col[0] * 255;
|
b_col_char[0]= font->b_col[0] * 255;
|
||||||
b_col_char[1]= font->b_col[1] * 255;
|
b_col_char[1]= font->b_col[1] * 255;
|
||||||
b_col_char[2]= font->b_col[2] * 255;
|
b_col_char[2]= font->b_col[2] * 255;
|
||||||
|
b_col_char[3]= font->b_col[3] * 255;
|
||||||
|
|
||||||
while (str[i]) {
|
while (str[i]) {
|
||||||
int pen_y;
|
int pen_y;
|
||||||
@@ -296,16 +297,19 @@ void blf_font_buffer(FontBLF *font, const char *str)
|
|||||||
a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f;
|
a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f;
|
||||||
|
|
||||||
if(a > 0.0f) {
|
if(a > 0.0f) {
|
||||||
|
float alphatest;
|
||||||
fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
|
fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
|
||||||
if (a >= 1.0f) {
|
if (a >= 1.0f) {
|
||||||
fbuf[0]= font->b_col[0];
|
fbuf[0]= font->b_col[0];
|
||||||
fbuf[1]= font->b_col[1];
|
fbuf[1]= font->b_col[1];
|
||||||
fbuf[2]= font->b_col[2];
|
fbuf[2]= font->b_col[2];
|
||||||
|
fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]))) < 1.0f ? alphatest : 1.0f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a));
|
fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a));
|
||||||
fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a));
|
fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a));
|
||||||
fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a));
|
fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a));
|
||||||
|
fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]*a))) < 1.0f ? alphatest : 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,16 +328,19 @@ void blf_font_buffer(FontBLF *font, const char *str)
|
|||||||
a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f;
|
a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f;
|
||||||
|
|
||||||
if(a > 0.0f) {
|
if(a > 0.0f) {
|
||||||
|
int alphatest;
|
||||||
cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
|
cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
|
||||||
if (a >= 1.0f) {
|
if (a >= 1.0f) {
|
||||||
cbuf[0]= b_col_char[0];
|
cbuf[0]= b_col_char[0];
|
||||||
cbuf[1]= b_col_char[1];
|
cbuf[1]= b_col_char[1];
|
||||||
cbuf[2]= b_col_char[2];
|
cbuf[2]= b_col_char[2];
|
||||||
|
cbuf[3]= (alphatest= ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cbuf[0]= (b_col_char[0]*a) + (cbuf[0] * (1-a));
|
cbuf[0]= (b_col_char[0]*a) + (cbuf[0] * (1-a));
|
||||||
cbuf[1]= (b_col_char[1]*a) + (cbuf[1] * (1-a));
|
cbuf[1]= (b_col_char[1]*a) + (cbuf[1] * (1-a));
|
||||||
cbuf[2]= (b_col_char[2]*a) + (cbuf[2] * (1-a));
|
cbuf[2]= (b_col_char[2]*a) + (cbuf[2] * (1-a));
|
||||||
|
cbuf[3]= (alphatest= ((int)cbuf[3] + (int)((font->b_col[3]*a)*255.0f))) < 255 ? alphatest : 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf,
|
|||||||
|
|
||||||
LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]);
|
LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]);
|
||||||
LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
|
LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
|
||||||
LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2);
|
LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2);
|
||||||
LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value);
|
LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value);
|
||||||
|
|
||||||
#endif /* IFF_H */
|
#endif /* IFF_H */
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i
|
|||||||
void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
|
void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
|
||||||
|
|
||||||
/* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
|
/* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
|
||||||
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2);
|
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2);
|
||||||
|
|
||||||
/* defined in metadata.c */
|
/* defined in metadata.c */
|
||||||
int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field);
|
int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field);
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2)
|
void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
float a; /* alpha */
|
float a; /* alpha */
|
||||||
@@ -509,6 +509,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
|
|||||||
unsigned char *pixel;
|
unsigned char *pixel;
|
||||||
unsigned char chr=0, chg=0, chb=0;
|
unsigned char chr=0, chg=0, chb=0;
|
||||||
float fr=0, fg=0, fb=0;
|
float fr=0, fg=0, fb=0;
|
||||||
|
|
||||||
|
const int alphaint= FTOCHAR(a);
|
||||||
|
|
||||||
if (a == 1.0f) {
|
if (a == 1.0f) {
|
||||||
chr = FTOCHAR(col[0]);
|
chr = FTOCHAR(col[0]);
|
||||||
@@ -527,10 +529,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
|
|||||||
pixel[0] = chr;
|
pixel[0] = chr;
|
||||||
pixel[1] = chg;
|
pixel[1] = chg;
|
||||||
pixel[2] = chb;
|
pixel[2] = chb;
|
||||||
|
pixel[3] = 255;
|
||||||
} else {
|
} else {
|
||||||
|
int alphatest;
|
||||||
pixel[0] = (char)((fr + ((float)pixel[0]*aich))*255.0f);
|
pixel[0] = (char)((fr + ((float)pixel[0]*aich))*255.0f);
|
||||||
pixel[1] = (char)((fg + ((float)pixel[1]*aich))*255.0f);
|
pixel[1] = (char)((fg + ((float)pixel[1]*aich))*255.0f);
|
||||||
pixel[2] = (char)((fb + ((float)pixel[2]*aich))*255.0f);
|
pixel[2] = (char)((fb + ((float)pixel[2]*aich))*255.0f);
|
||||||
|
pixel[3] = (char)((alphatest= ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,10 +551,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
|
|||||||
pixel[0] = col[0];
|
pixel[0] = col[0];
|
||||||
pixel[1] = col[1];
|
pixel[1] = col[1];
|
||||||
pixel[2] = col[2];
|
pixel[2] = col[2];
|
||||||
|
pixel[3] = 1.0f;
|
||||||
} else {
|
} else {
|
||||||
|
float alphatest;
|
||||||
pixel[0] = (col[0]*a) + (pixel[0]*ai);
|
pixel[0] = (col[0]*a) + (pixel[0]*ai);
|
||||||
pixel[1] = (col[1]*a) + (pixel[1]*ai);
|
pixel[1] = (col[1]*a) + (pixel[1]*ai);
|
||||||
pixel[2] = (col[2]*a) + (pixel[2]*ai);
|
pixel[2] = (col[2]*a) + (pixel[2]*ai);
|
||||||
|
pixel[3] = (alphatest= (pixel[3] + a)) < 1.0f ? alphatest : 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user