summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-02-14 10:39:30 +0100
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-09-17 14:48:48 +0200
commitd84a6eab5129ba29951a7ba6d82820b21cc9872e (patch)
tree1d794ecd3f37363a286f3eeda8e571c36ec4006c /src/gui/text/qfontengine.cpp
parentbce19cb9063003af5924c643f6fc1416146b4242 (diff)
Add Grayscale8 and Alpha8 formats to QImage and drawing
Extend the QImage format with two 8-bit grayscale and alpha formats. These formats have the advantage over Indexed8 that they have simpler conversion and can be rendered to by the raster engine. [ChangeLog][QtGui][QImage] Added support grayscale and alpha 8-bit formats which can also be rendered to. Change-Id: I4343c80a92a3dda196aa38d0c3ea251b094fc274 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/gui/text/qfontengine.cpp')
-rw-r--r--src/gui/text/qfontengine.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 5f801c3bf4..ad905030d4 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -771,7 +771,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
{
QImage i = alphaMapForGlyph(glyph);
if (t.type() > QTransform::TxTranslate)
- i = i.transformed(t).convertToFormat(QImage::Format_Indexed8);
+ i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
return i;
@@ -784,7 +784,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, con
QImage i = alphaMapForGlyph(glyph, subPixelPosition);
if (t.type() > QTransform::TxTranslate)
- i = i.transformed(t).convertToFormat(QImage::Format_Indexed8);
+ i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
return i;
@@ -881,20 +881,16 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph)
p.drawPath(path);
p.end();
- QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
+ QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
for (int y=0; y<im.height(); ++y) {
- uchar *dst = (uchar *) indexed.scanLine(y);
+ uchar *dst = (uchar *) alphaMap.scanLine(y);
uint *src = (uint *) im.scanLine(y);
for (int x=0; x<im.width(); ++x)
dst[x] = qAlpha(src[x]);
}
- return indexed;
+ return alphaMap;
}
void QFontEngine::removeGlyphFromCache(glyph_t)
@@ -1545,14 +1541,10 @@ bool QFontEngineBox::canRender(const QChar *, int) const
QImage QFontEngineBox::alphaMapForGlyph(glyph_t)
{
- QImage image(_size, _size, QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- image.setColorTable(colors);
+ QImage image(_size, _size, QImage::Format_Alpha8);
image.fill(0);
- // can't use qpainter for index8; so use setPixel to draw our rectangle.
+ // FIXME: use qpainter
for (int i=2; i <= _size-3; ++i) {
image.setPixel(i, 2, 255);
image.setPixel(i, _size-3, 255);