Use bg1/bg2 directly as alpha=255 in the thumbnails generation

This commit is contained in:
David Capello 2016-09-26 13:00:01 -03:00
parent e287d0e066
commit dd54e0b6f9

View File

@ -54,23 +54,12 @@ she::Surface* get_cel_thumbnail(const doc::Cel* cel,
base::UniquePtr<doc::Image> thumb_img(doc::Image::create(
image->pixelFormat(), thumb_size.w, thumb_size.h));
double alpha = 255.0;
uint8_t bg_r[] = { rgba_getr(bg1), rgba_getr(bg2) };
uint8_t bg_g[] = { rgba_getg(bg1), rgba_getg(bg2) };
uint8_t bg_b[] = { rgba_getb(bg1), rgba_getb(bg2) };
uint8_t bg_a[] = { rgba_geta(bg1), rgba_geta(bg2) };
doc::color_t bg[] = {
rgba(bg_r[0], bg_g[0], bg_b[0], (int)(bg_a[0] * alpha)),
rgba(bg_r[1], bg_g[1], bg_b[1], (int)(bg_a[1] * alpha))
};
int block_size = MID(4, thumb_size.w/8, 16);
for (int dst_y = 0; dst_y < thumb_size.h; dst_y++) {
for (int dst_x = 0; dst_x < thumb_size.w; dst_x++) {
thumb_img->putPixel(dst_x, dst_y,
bg[((dst_x / block_size) % 2) ^
((dst_y / block_size) % 2)]);
(((dst_x / block_size) % 2) ^
((dst_y / block_size) % 2)) ? bg2: bg1);
}
}