Bitmap refreshing fails for `FT_PIXEL_MODE_GRAY[24]`
I tried to extend ftinspect
similar to commit 746d5be5, applying the following patch
diff --git a/src/ftinspect/engine/rendering.cpp b/src/ftinspect/engine/rendering.cpp
index 11ad283..3f62b33 100644
--- a/src/ftinspect/engine/rendering.cpp
+++ b/src/ftinspect/engine/rendering.cpp
@@ -144,6 +144,22 @@ RenderingEngine::convertBitmapTo8Bpp(FT_Bitmap* bitmap)
{
// XXX handling?
}
+
+ // Scale gray values, too.
+ int i, size = qAbs(out.pitch) * out.rows;
+ auto buf = reinterpret_cast<uint32_t*>(out.buffer);
+ uint32_t scale = 255U / (out.num_grays - 1);
+
+ // Four bytes at a time.
+ for (i = 0; i <= size - 4; i += 4, buf++)
+ *buf *= scale;
+
+ // The remaining bytes.
+ for (; i < size; i++ )
+ out.buffer[i] *= scale;
+
+ out.num_grays = 256;
+
return out;
}
Interestingly, it doesn't work as expected: The bitmap doesn't get repainted correctly if I move around the canvas:
The attached BDF fonts can be used for testing the two gray modes.
Edited by Werner Lemberg