mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
add alphaColorTable() function for alpha maps
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
07ebdb0f75
commit
2de9205c73
3 changed files with 10 additions and 6 deletions
|
@ -28,12 +28,19 @@ static const QRgb qt_transparentrgba = qRgba(0, 0, 0, 0);
|
||||||
// same as QColor(Qt::transparent).rgb()
|
// same as QColor(Qt::transparent).rgb()
|
||||||
static const QRgb qt_transparentrgb = qRgb(0, 0, 0);
|
static const QRgb qt_transparentrgb = qRgb(0, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
inline static const QVector<QRgb>& monoColorTable()
|
inline static const QVector<QRgb>& monoColorTable()
|
||||||
{
|
{
|
||||||
static const QVector<QRgb> colortable = { qt_whitergba, qt_blackrgba };
|
static const QVector<QRgb> colortable = { qt_whitergba, qt_blackrgba };
|
||||||
return colortable;
|
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)
|
inline static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
|
||||||
{
|
{
|
||||||
const int maxFactor = 100;
|
const int maxFactor = 100;
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
static const QVector<QRgb> qt_alphamapcolortable = { qt_transparentrgba, qt_blackrgba };
|
|
||||||
|
|
||||||
// Harfbuzz helper functions
|
// 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)
|
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();
|
return QImage();
|
||||||
QImage im(glyph_width, glyph_height, QImage::Format_Mono);
|
QImage im(glyph_width, glyph_height, QImage::Format_Mono);
|
||||||
im.fill(0);
|
im.fill(0);
|
||||||
im.setColorTable(qt_alphamapcolortable);
|
im.setColorTable(alphaColorTable());
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,7 +816,7 @@ QImage QFontEngineBox::alphaMapForGlyph(glyph_t)
|
||||||
{
|
{
|
||||||
QImage image(_size, _size, QImage::Format_Mono);
|
QImage image(_size, _size, QImage::Format_Mono);
|
||||||
image.fill(0);
|
image.fill(0);
|
||||||
image.setColorTable(qt_alphamapcolortable);
|
image.setColorTable(alphaColorTable());
|
||||||
|
|
||||||
for (int i=2; i <= _size-3; ++i) {
|
for (int i=2; i <= _size-3; ++i) {
|
||||||
image.setPixel(i, 2, qt_blackrgba);
|
image.setPixel(i, 2, qt_blackrgba);
|
||||||
|
|
|
@ -893,8 +893,7 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g)
|
||||||
const int pitch = (((glyph->width + 31) & ~31) >> 3);
|
const int pitch = (((glyph->width + 31) & ~31) >> 3);
|
||||||
|
|
||||||
QImage img(glyph->width, glyph->height, QImage::Format_Mono);
|
QImage img(glyph->width, glyph->height, QImage::Format_Mono);
|
||||||
static const QVector<QRgb> colors = { qt_transparentrgba, qt_blackrgba };
|
img.setColorTable(alphaColorTable());
|
||||||
img.setColorTable(colors);
|
|
||||||
Q_ASSERT(img.bytesPerLine() == pitch);
|
Q_ASSERT(img.bytesPerLine() == pitch);
|
||||||
if (glyph->width) {
|
if (glyph->width) {
|
||||||
for (int y = 0; y < glyph->height; ++y)
|
for (int y = 0; y < glyph->height; ++y)
|
||||||
|
|
Loading…
Add table
Reference in a new issue