Revert "See what happens if we switch to Indexed8..."

This reverts commit a602b8b872c5b4c4c0772b82bb43e2384d92fd63.

What happens is we end up with an alpha channel in our PNGs, which
screws with our first entry in the palette: black, which is no longer at
full opacity :/.
This commit is contained in:
NiLuJe 2019-05-24 03:33:20 +02:00
parent 38ad6a5b2d
commit b5554bd0da
2 changed files with 3 additions and 17 deletions

View File

@ -25,8 +25,6 @@ typedef unsigned __int32 uint32_t;
#include <cstdint>
#endif
#include <QVector>
// NOTE: *May* not behave any better than a simple / 0xFF on modern x86_64 CPUs...
// This was, however, tested on ARM, where it is noticeably faster.
static uint32_t DIV255(uint32_t v) {
@ -81,19 +79,7 @@ QImage ordered_dither(const QImage &image) { // {{{
QImage img = image;
int y = 0, x = 0, width = img.width(), height = img.height();
uint8_t gray = 0, dithered = 0;
QImage dst(width, height, QImage::Format_Indexed8);
// Set up the eInk palette
// FIXME: Make it const and switch to C++11 list init if MSVC is amenable...
QVector<uint8_t> palette(16);
QVector<QRgb> color_table(16);
int i = 0;
for (i = 0; i < 16; i++) {
uint8_t color = i * 17;
palette << color;
color_table << qRgb(color, color, color);
}
dst.setColorTable(color_table);
QImage dst(width, height, QImage::Format_Grayscale8);
// We're running behind blend_image, so, we should only ever be fed RGB32 as input...
if (img.format() != QImage::Format_RGB32) {
@ -109,7 +95,7 @@ QImage ordered_dither(const QImage &image) { // {{{
// We're running behind grayscale_image, so R = G = B
gray = qRed(pixel);
dithered = dither_o8x8(x, y, gray);
*(dst_row + x) = palette.indexOf(dithered);
*(dst_row + x) = dithered;
}
}
return dst;

View File

@ -468,7 +468,7 @@ def eink_dither_image(img):
Running blend_image if the image has an alpha channel,
or grayscale_image if it's not already grayscaled is the caller's responsibility.
Returns a QImage in Indexed8 pixel format.
Returns a QImage in Grayscale8 pixel format.
'''
img = image_from_data(img)
return imageops.ordered_dither(img)