summaryrefslogtreecommitdiffstats
path: root/src/plugins
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/plugins
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/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp10
2 files changed, 6 insertions, 16 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 35b7f13ea4..ff2cfe4745 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -1168,19 +1168,13 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
return QImage();
}
- QImage indexed(mask->width(), mask->height(), QImage::Format_Indexed8);
+ QImage alphaMap(mask->width(), mask->height(), QImage::Format_Alpha8);
- // ### This part is kinda pointless, but we'll crash later if we don't because some
- // code paths expects there to be colortables for index8-bit...
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
// Copy data... Cannot use QPainter here as GDI has messed up the
// Alpha channel of the ni.image pixels...
for (int y=0; y<mask->height(); ++y) {
- uchar *dest = indexed.scanLine(y);
+ uchar *dest = alphaMap.scanLine(y);
if (mask->image().format() == QImage::Format_RGB16) {
const qint16 *src = (qint16 *) ((const QImage &) mask->image()).scanLine(y);
for (int x=0; x<mask->width(); ++x)
@@ -1202,7 +1196,7 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
DeleteObject(font);
}
- return indexed;
+ return alphaMap;
}
#define SPI_GETFONTSMOOTHINGCONTRAST 0x200C
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index 15b14aff1a..9825653a62 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -493,15 +493,11 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub
{
QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform());
- 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) {
uint *src = (uint*) im.scanLine(y);
- uchar *dst = indexed.scanLine(y);
+ uchar *dst = alphaMap.scanLine(y);
for (int x=0; x<im.width(); ++x) {
*dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.);
++dst;
@@ -509,7 +505,7 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub
}
}
- return indexed;
+ return alphaMap;
}
bool QWindowsFontEngineDirectWrite::supportsSubPixelPositions() const