add alphaColorTable() function for alpha maps

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-12-25 22:55:29 +02:00
parent 07ebdb0f75
commit 2de9205c73
3 changed files with 10 additions and 6 deletions

View file

@ -28,12 +28,19 @@ static const QRgb qt_transparentrgba = qRgba(0, 0, 0, 0);
// same as QColor(Qt::transparent).rgb()
static const QRgb qt_transparentrgb = qRgb(0, 0, 0);
inline static const QVector<QRgb>& monoColorTable()
{
static const QVector<QRgb> colortable = { qt_whitergba, qt_blackrgba };
return colortable;
}
inline static const QVector<QRgb>& alphaColorTable()
{
static const QVector<QRgb> colortable = { qt_transparentrgba, qt_blackrgba };
return colortable;
}
inline static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
{
const int maxFactor = 100;

View file

@ -35,8 +35,6 @@
QT_BEGIN_NAMESPACE
static const QVector<QRgb> qt_alphamapcolortable = { qt_transparentrgba, qt_blackrgba };
// Harfbuzz helper functions
static HB_Bool hb_stringToGlyphs(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft)
@ -523,7 +521,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph)
return QImage();
QImage im(glyph_width, glyph_height, QImage::Format_Mono);
im.fill(0);
im.setColorTable(qt_alphamapcolortable);
im.setColorTable(alphaColorTable());
return im;
}
@ -818,7 +816,7 @@ QImage QFontEngineBox::alphaMapForGlyph(glyph_t)
{
QImage image(_size, _size, QImage::Format_Mono);
image.fill(0);
image.setColorTable(qt_alphamapcolortable);
image.setColorTable(alphaColorTable());
for (int i=2; i <= _size-3; ++i) {
image.setPixel(i, 2, qt_blackrgba);

View file

@ -893,8 +893,7 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g)
const int pitch = (((glyph->width + 31) & ~31) >> 3);
QImage img(glyph->width, glyph->height, QImage::Format_Mono);
static const QVector<QRgb> colors = { qt_transparentrgba, qt_blackrgba };
img.setColorTable(colors);
img.setColorTable(alphaColorTable());
Q_ASSERT(img.bytesPerLine() == pitch);
if (glyph->width) {
for (int y = 0; y < glyph->height; ++y)