src/gui/text/qfontengine.cpp
changeset 30 5dc02b23752f
parent 19 fcece45ef507
child 37 758a864f9613
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   594 
   594 
   595 QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
   595 QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
   596 {
   596 {
   597     QImage i = alphaMapForGlyph(glyph);
   597     QImage i = alphaMapForGlyph(glyph);
   598     if (t.type() > QTransform::TxTranslate)
   598     if (t.type() > QTransform::TxTranslate)
   599         i = i.transformed(t);
   599         i = i.transformed(t).convertToFormat(QImage::Format_Indexed8);
   600     Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
   600     Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
       
   601 
   601     return i;
   602     return i;
   602 }
   603 }
   603 
   604 
   604 QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int /* margin */, const QTransform &t)
   605 QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int /* margin */, const QTransform &t)
   605 {
   606 {
   606     QImage alphaMask = alphaMapForGlyph(glyph, t);
   607     QImage alphaMask = alphaMapForGlyph(glyph, t);
   607     QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);
   608     QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);
   608 
   609 
       
   610     QVector<QRgb> colorTable = alphaMask.colorTable();
   609     for (int y=0; y<alphaMask.height(); ++y) {
   611     for (int y=0; y<alphaMask.height(); ++y) {
   610         uint *dst = (uint *) rgbMask.scanLine(y);
   612         uint *dst = (uint *) rgbMask.scanLine(y);
   611         uchar *src = (uchar *) alphaMask.scanLine(y);
   613         uchar *src = (uchar *) alphaMask.scanLine(y);
   612         for (int x=0; x<alphaMask.width(); ++x)
   614         for (int x=0; x<alphaMask.width(); ++x) {
   613             dst[x] = qRgb(src[x], src[x], src[x]);
   615             int val = qAlpha(colorTable.at(src[x]));
       
   616             dst[x] = qRgb(val, val, val);
       
   617         }
   614     }
   618     }
   615 
   619 
   616     return rgbMask;
   620     return rgbMask;
   617 }
   621 }
   618 
   622