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>
This commit is contained in:
Allan Sandfeld Jensen 2014-02-14 10:39:30 +01:00
parent bce19cb906
commit d84a6eab51
28 changed files with 1060 additions and 272 deletions

View File

@ -812,6 +812,10 @@ bool QBmpHandler::write(const QImage &img)
case QImage::Format_RGB30:
image = img.convertToFormat(QImage::Format_RGB32);
break;
case QImage::Format_Alpha8:
case QImage::Format_Grayscale8:
image = img.convertToFormat(QImage::Format_Indexed8);
break;
default:
image = img;
}

View File

@ -661,7 +661,8 @@ bool QImageData::checkForAlphaPixels() const
The following image formats are available in Qt. Values from Format_ARGB8565_Premultiplied
to Format_ARGB4444_Premultiplied were added in Qt 4.4. Values Format_RGBX8888, Format_RGBA8888
and Format_RGBA8888_Premultiplied were added in Qt 5.2. Values Format_BGR30, Format_A2BGR30_Premultiplied,
Format_RGB30, Format_A2RGB30_Premultiplied were added in Qt 5.4.
Format_RGB30, Format_A2RGB30_Premultiplied were added in Qt 5.4. Format_Alpha8 and Format_Grayscale8
were added in Qt 5.5.
See the notes after the table.
\value Format_Invalid The image is invalid.
@ -717,6 +718,8 @@ bool QImageData::checkForAlphaPixels() const
\value Format_A2BGR30_Premultiplied The image is stored using a 32-bit premultiplied ABGR format (2-10-10-10).
\value Format_RGB30 The image is stored using a 32-bit RGB format (x-10-10-10).
\value Format_A2RGB30_Premultiplied The image is stored using a 32-bit premultiplied ARGB format (2-10-10-10).
\value Format_Alpha8 The image is stored using an 8-bit alpha only format.
\value Format_Grayscale8 The image is stored using an 8-bit grayscale format.
\note Drawing into a QImage with QImage::Format_Indexed8 is not
supported.
@ -2361,6 +2364,10 @@ bool QImage::allGray() const
return false;
}
return true;
case Format_Alpha8:
return false;
case Format_Grayscale8:
return true;
case Format_RGB32:
case Format_ARGB32:
case Format_ARGB32_Premultiplied:
@ -2414,9 +2421,9 @@ bool QImage::allGray() const
/*!
For 32-bit images, this function is equivalent to allGray().
For 8-bpp images, this function returns \c true if color(i) is
QRgb(i, i, i) for all indexes of the color table; otherwise
returns \c false.
For color indexed images, this function returns \c true if
color(i) is QRgb(i, i, i) for all indexes of the color table;
otherwise returns \c false.
\sa allGray(), {QImage#Image Formats}{Image Formats}
*/
@ -2425,12 +2432,19 @@ bool QImage::isGrayscale() const
if (!d)
return false;
if (d->format == QImage::Format_Alpha8)
return false;
if (d->format == QImage::Format_Grayscale8)
return true;
switch (depth()) {
case 32:
case 24:
case 16:
return allGray();
case 8: {
Q_ASSERT(d->format == QImage::Format_Indexed8);
for (int i = 0; i < colorCount(); i++)
if (d->colortable.at(i) != qRgb(i,i,i))
return false;
@ -3005,6 +3019,9 @@ QImage QImage::rgbSwapped_helper() const
case NImageFormats:
Q_ASSERT(false);
break;
case Format_Alpha8:
case Format_Grayscale8:
return *this;
case Format_Mono:
case Format_MonoLSB:
case Format_Indexed8:
@ -3091,6 +3108,9 @@ void QImage::rgbSwapped_inplace()
case NImageFormats:
Q_ASSERT(false);
break;
case Format_Alpha8:
case Format_Grayscale8:
return;
case Format_Mono:
case Format_MonoLSB:
case Format_Indexed8:
@ -4024,7 +4044,7 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
return;
// Slight optimization since alphachannels are returned as 8-bit grays.
if (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale()) {
if (alphaChannel.format() == QImage::Format_Alpha8 ||( alphaChannel.d->depth == 8 && alphaChannel.isGrayscale())) {
const uchar *src_data = alphaChannel.d->data;
const uchar *dest_data = d->data;
for (int y=0; y<h; ++y) {
@ -4082,9 +4102,13 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
Most usecases for this function can be replaced with QPainter and
using composition modes.
Note this returns a color-indexed image if you want the alpha channel in
the alpha8 format instead use convertToFormat(Format_Alpha8) on the source
image.
\warning This is an expensive function.
\sa setAlphaChannel(), hasAlphaChannel(),
\sa setAlphaChannel(), hasAlphaChannel(), convertToFormat(),
{QPixmap#Pixmap Information}{Pixmap},
{QImage#Image Transformations}{Image Transformations}
*/
@ -4094,6 +4118,9 @@ QImage QImage::alphaChannel() const
if (!d)
return QImage();
if (d->format == QImage::Format_Alpha8)
return *this;
int w = d->width;
int h = d->height;
@ -4168,6 +4195,7 @@ bool QImage::hasAlphaChannel() const
|| d->format == Format_RGBA8888_Premultiplied
|| d->format == Format_A2BGR30_Premultiplied
|| d->format == Format_A2RGB30_Premultiplied
|| d->format == Format_Alpha8
|| (d->has_alpha_clut && (d->format == Format_Indexed8
|| d->format == Format_Mono
|| d->format == Format_MonoLSB)));
@ -4277,6 +4305,8 @@ static QImage rotated90(const QImage &image) {
reinterpret_cast<quint16*>(out.bits()),
out.bytesPerLine());
break;
case QImage::Format_Alpha8:
case QImage::Format_Grayscale8:
case QImage::Format_Indexed8:
qt_memrotate270(reinterpret_cast<const quint8*>(image.bits()),
w, h, image.bytesPerLine(),
@ -4343,6 +4373,8 @@ static QImage rotated270(const QImage &image) {
reinterpret_cast<quint16*>(out.bits()),
out.bytesPerLine());
break;
case QImage::Format_Alpha8:
case QImage::Format_Grayscale8:
case QImage::Format_Indexed8:
qt_memrotate90(reinterpret_cast<const quint8*>(image.bits()),
w, h, image.bytesPerLine(),
@ -4495,24 +4527,17 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
dImage.d->dpmy = dotsPerMeterY();
dImage.d->devicePixelRatio = devicePixelRatio();
switch (bpp) {
// initizialize the data
case 8:
if (dImage.d->colortable.size() < 256) {
// colors are left in the color table, so pick that one as transparent
dImage.d->colortable.append(0x0);
memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount());
} else {
memset(dImage.bits(), 0, dImage.byteCount());
}
break;
case 1:
case 16:
case 24:
case 32:
memset(dImage.bits(), 0x00, dImage.byteCount());
break;
}
// initizialize the data
if (d->format == QImage::Format_Indexed8) {
if (dImage.d->colortable.size() < 256) {
// colors are left in the color table, so pick that one as transparent
dImage.d->colortable.append(0x0);
memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount());
} else {
memset(dImage.bits(), 0, dImage.byteCount());
}
} else
memset(dImage.bits(), 0x00, dImage.byteCount());
if (target_format >= QImage::Format_RGB32) {
QPainter p(&dImage);
@ -4948,6 +4973,32 @@ static Q_CONSTEXPR QPixelFormat pixelformats[] = {
/*PREMULTIPLIED*/ QPixelFormat::Premultiplied,
/*INTERPRETATION*/ QPixelFormat::UnsignedInteger,
/*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),
//QImage::Format_Alpha8:
QPixelFormat(QPixelFormat::Alpha,
/*First*/ 0,
/*SECOND*/ 0,
/*THIRD*/ 0,
/*FOURTH*/ 0,
/*FIFTH*/ 0,
/*ALPHA*/ 8,
/*ALPHA USAGE*/ QPixelFormat::UsesAlpha,
/*ALPHA POSITION*/ QPixelFormat::AtBeginning,
/*PREMULTIPLIED*/ QPixelFormat::Premultiplied,
/*INTERPRETATION*/ QPixelFormat::UnsignedByte,
/*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),
//QImage::Format_Grayscale8:
QPixelFormat(QPixelFormat::Grayscale,
/*GRAY*/ 8,
/*SECOND*/ 0,
/*THIRD*/ 0,
/*FOURTH*/ 0,
/*FIFTH*/ 0,
/*ALPHA*/ 0,
/*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,
/*ALPHA POSITION*/ QPixelFormat::AtBeginning,
/*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,
/*INTERPRETATION*/ QPixelFormat::UnsignedByte,
/*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),
};
Q_STATIC_ASSERT(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFormats);

View File

@ -114,20 +114,16 @@ public:
Format_RGBX8888,
Format_RGBA8888,
Format_RGBA8888_Premultiplied,
#if 0
// reserved for future use
Format_RGB15,
Format_Grayscale16,
Format_Grayscale8,
Format_Grayscale4,
Format_Grayscale4LSB,
Format_Grayscale2,
Format_Grayscale2LSB
#endif
Format_BGR30,
Format_A2BGR30_Premultiplied,
Format_RGB30,
Format_A2RGB30_Premultiplied,
Format_Alpha8,
Format_Grayscale8,
#if 0
// reserved for future use
Format_Grayscale16,
#endif
#ifndef Q_QDOC
NImageFormats
#endif

View File

@ -1868,11 +1868,154 @@ static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt
}
}
static void convert_Indexed8_to_Alpha8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
Q_ASSERT(src->format == QImage::Format_Indexed8);
Q_ASSERT(dest->format == QImage::Format_Alpha8);
uchar translate[256];
const QVector<QRgb> &colors = src->colortable;
bool simpleCase = (colors.size() == 256);
for (int i = 0; i < colors.size(); ++i) {
uchar alpha = qAlpha(colors[i]);
translate[i] = alpha;
simpleCase = simpleCase && (alpha == i);
}
if (simpleCase)
memcpy(dest->data, src->data, src->bytes_per_line * src->height);
else {
int size = src->bytes_per_line * src->height;
for (int i = 0; i < size; ++i) {
dest->data[i] = translate[src->data[i]];
}
}
}
static void convert_Indexed8_to_Grayscale8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
Q_ASSERT(src->format == QImage::Format_Indexed8);
Q_ASSERT(dest->format == QImage::Format_Grayscale8);
uchar translate[256];
const QVector<QRgb> &colors = src->colortable;
bool simpleCase = (colors.size() == 256);
for (int i = 0; i < colors.size(); ++i) {
uchar gray = qGray(colors[i]);
translate[i] = gray;
simpleCase = simpleCase && (gray == i);
}
if (simpleCase)
memcpy(dest->data, src->data, src->bytes_per_line * src->height);
else {
int size = src->bytes_per_line * src->height;
for (int i = 0; i < size; ++i) {
dest->data[i] = translate[src->data[i]];
}
}
}
static bool convert_Indexed8_to_Alpha8_inplace(QImageData *data, Qt::ImageConversionFlags)
{
Q_ASSERT(data->format == QImage::Format_Indexed8);
// Just check if this is an Alpha8 in Indexed8 disguise.
const QVector<QRgb> &colors = data->colortable;
if (colors.size() != 256)
return false;
for (int i = 0; i < colors.size(); ++i) {
if (i != qAlpha(colors[i]))
return false;
}
data->colortable.clear();
data->format = QImage::Format_Alpha8;
return true;
}
static bool convert_Indexed8_to_Grayscale8_inplace(QImageData *data, Qt::ImageConversionFlags)
{
Q_ASSERT(data->format == QImage::Format_Indexed8);
// Just check if this is a Grayscale8 in Indexed8 disguise.
const QVector<QRgb> &colors = data->colortable;
if (colors.size() != 256)
return false;
for (int i = 0; i < colors.size(); ++i) {
if (i != qGray(colors[i]))
return false;
}
data->colortable.clear();
data->format = QImage::Format_Grayscale8;
return true;
}
static void convert_Alpha8_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
Q_ASSERT(src->format == QImage::Format_Alpha8);
Q_ASSERT(dest->format == QImage::Format_Indexed8);
memcpy(dest->data, src->data, src->bytes_per_line * src->height);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
colors[i] = qRgba(0, 0, 0, i);
dest->colortable = colors;
}
static void convert_Grayscale8_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
Q_ASSERT(src->format == QImage::Format_Grayscale8);
Q_ASSERT(dest->format == QImage::Format_Indexed8);
memcpy(dest->data, src->data, src->bytes_per_line * src->height);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
colors[i] = qRgb(i, i, i);
dest->colortable = colors;
}
static bool convert_Alpha8_to_Indexed8_inplace(QImageData *data, Qt::ImageConversionFlags)
{
Q_ASSERT(data->format == QImage::Format_Alpha8);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
colors[i] = qRgba(0, 0, 0, i);
data->colortable = colors;
data->format = QImage::Format_Indexed8;
return true;
}
static bool convert_Grayscale8_to_Indexed8_inplace(QImageData *data, Qt::ImageConversionFlags)
{
Q_ASSERT(data->format == QImage::Format_Grayscale8);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
colors[i] = qRgb(i, i, i);
data->colortable = colors;
data->format = QImage::Format_Indexed8;
return true;
}
// first index source, second dest
Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormats] =
{
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
{
0,
@ -1893,7 +2036,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_Mono
{
@ -1915,7 +2058,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_MonoLSB
{
@ -1937,7 +2080,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0,
convert_Indexed8_to_Alpha8,
convert_Indexed8_to_Grayscale8,
}, // Format_Indexed8
{
@ -1964,6 +2109,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_RGB_to_RGB30<PixelOrderBGR>,
convert_RGB_to_RGB30<PixelOrderRGB>,
convert_RGB_to_RGB30<PixelOrderRGB>,
0, 0
}, // Format_RGB32
{
@ -1990,6 +2136,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
convert_RGB_to_RGB30<PixelOrderRGB>,
0,
0, 0
}, // Format_ARGB32
{
@ -2016,6 +2163,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_ARGB_to_A2RGB30<PixelOrderBGR>,
convert_ARGB_PM_to_RGB30<PixelOrderRGB>,
convert_ARGB_to_A2RGB30<PixelOrderRGB>,
0, 0
}, // Format_ARGB32_Premultiplied
{
@ -2037,7 +2185,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_RGB16
{
@ -2059,7 +2207,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB8565_Premultiplied
{
@ -2081,7 +2229,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_RGB666
{
@ -2103,7 +2251,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB6666_Premultiplied
{
@ -2125,7 +2273,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_RGB555
{
@ -2147,7 +2295,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB8555_Premultiplied
{
@ -2169,7 +2317,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_RGB888
{
@ -2191,7 +2339,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_RGB444
{
@ -2212,7 +2360,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB4444_Premultiplied
{
0,
@ -2234,7 +2382,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
mask_alpha_converter_RGBx,
mask_alpha_converter_RGBx,
0, 0, 0, 0
0, 0, 0, 0, 0, 0
}, // Format_RGBX8888
{
0,
@ -2259,9 +2407,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_ARGB_to_ARGB_PM,
#else
0,
0
0,
#endif
0, 0, 0, 0
0, 0, 0, 0, 0, 0
}, // Format_RGBA8888
{
@ -2288,9 +2436,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
#else
0,
0,
0
0,
#endif
0, 0, 0, 0
0, 0, 0, 0, 0, 0
}, // Format_RGBA8888_Premultiplied
{
@ -2316,7 +2464,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
convert_passthrough,
convert_BGR30_to_RGB30,
convert_BGR30_to_RGB30
convert_BGR30_to_RGB30,
0, 0
}, // Format_BGR30
{
0,
@ -2341,7 +2490,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_A2RGB30_PM_to_RGB30,
0,
0,
convert_BGR30_to_RGB30
convert_BGR30_to_RGB30,
0, 0
}, // Format_BGR30A2_Premultiplied
{
0,
@ -2367,6 +2517,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
convert_passthrough,
0, 0
}, // Format_RGB30
{
0,
@ -2392,19 +2543,61 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_BGR30_to_RGB30,
convert_A2RGB30_PM_to_RGB30,
0,
0,
0,
}, // Format_RGB30A2_Premultiplied
{
0,
0,
0,
convert_Alpha8_to_Indexed8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 0, 0, 0, 0, 0
}, // Format_Alpha8
{
0,
0,
0,
convert_Grayscale8_to_Indexed8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0, 0, 0, 0, 0, 0
} // Format_Grayscale8
};
InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats] =
{
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_Mono
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_MonoLSB
{
0,
@ -2425,7 +2618,9 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0,
convert_Indexed8_to_Alpha8_inplace,
convert_Indexed8_to_Grayscale8_inplace,
}, // Format_Indexed8
{
0,
@ -2446,7 +2641,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_RGB32
{
0,
@ -2471,7 +2666,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
convert_ARGB_to_RGBA_inplace,
0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB32
{
0,
@ -2493,34 +2688,34 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
convert_ARGB_to_RGBA_inplace,
0, 0, 0, 0
0, 0, 0, 0, 0, 0
}, // Format_ARGB32_Premultiplied
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB16
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB8565_Premultiplied
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB666
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB6666_Premultiplied
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB555
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB8555_Premultiplied
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB888
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB444
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB4444_Premultiplied
{
0,
@ -2542,7 +2737,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
convert_passthrough_inplace<QImage::Format_RGBA8888>,
convert_passthrough_inplace<QImage::Format_RGBA8888_Premultiplied>,
0, 0, 0, 0
0, 0, 0, 0, 0, 0
}, // Format_RGBX8888
{
0,
@ -2564,7 +2759,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0, 0, 0, 0
0, 0, 0, 0, 0, 0
}, // Format_RGBA8888
{
0,
@ -2586,7 +2781,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
0, 0, 0, 0
0, 0, 0, 0, 0, 0
}, // Format_RGBA8888_Premultiplied
{
0,
@ -2611,7 +2806,8 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
convert_passthrough_inplace<QImage::Format_A2BGR30_Premultiplied>,
convert_BGR30_to_RGB30_inplace,
convert_BGR30_to_RGB30_inplace
convert_BGR30_to_RGB30_inplace,
0, 0
}, // Format_BGR30
{
0,
@ -2636,7 +2832,8 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
convert_A2RGB30_PM_to_RGB30_inplace,
0,
0,
convert_BGR30_to_RGB30_inplace
convert_BGR30_to_RGB30_inplace,
0, 0
}, // Format_BGR30A2_Premultiplied
{
0,
@ -2661,7 +2858,8 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
convert_BGR30_to_RGB30_inplace,
convert_BGR30_to_RGB30_inplace,
0,
convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>
convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>,
0, 0
}, // Format_RGB30
{
0,
@ -2686,8 +2884,61 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
0,
convert_BGR30_to_RGB30_inplace,
convert_A2RGB30_PM_to_RGB30_inplace,
0
0,
0, 0
}, // Format_RGB30A2_Premultiplied
{
0,
0,
0,
convert_Alpha8_to_Indexed8_inplace,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0
}, // Format_Alpha8
{
0,
0,
0,
convert_Grayscale8_to_Indexed8_inplace,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, 0
} // Format_Grayscale8
};
void qInitImageConversions()

View File

@ -136,6 +136,8 @@ inline int qt_depthForFormat(QImage::Format format)
depth = 1;
break;
case QImage::Format_Indexed8:
case QImage::Format_Alpha8:
case QImage::Format_Grayscale8:
depth = 8;
break;
case QImage::Format_RGB32:

View File

@ -228,7 +228,7 @@ inline static bool read_jpeg_format(QImage::Format &format, j_decompress_ptr cin
bool result = true;
switch (cinfo->output_components) {
case 1:
format = QImage::Format_Indexed8;
format = QImage::Format_Grayscale8;
break;
case 3:
case 4:
@ -248,7 +248,7 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
QImage::Format format;
switch (info->output_components) {
case 1:
format = QImage::Format_Indexed8;
format = QImage::Format_Grayscale8;
break;
case 3:
case 4:
@ -258,16 +258,9 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
return false; // unsupported format
}
if (dest->size() != size || dest->format() != format) {
if (dest->size() != size || dest->format() != format)
*dest = QImage(size, format);
if (format == QImage::Format_Indexed8) {
dest->setColorCount(256);
for (int i = 0; i < 256; i++)
dest->setColor(i, qRgb(i,i,i));
}
}
return !dest->isNull();
}
@ -558,6 +551,9 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, volatile in
bool success = false;
const QVector<QRgb> cmap = image.colorTable();
if (image.format() == QImage::Format_Invalid || image.format() == QImage::Format_Alpha8)
return false;
struct jpeg_compress_struct cinfo;
JSAMPROW row_pointer[1];
row_pointer[0] = 0;
@ -581,19 +577,23 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, volatile in
cinfo.image_width = image.width();
cinfo.image_height = image.height();
bool gray=false;
bool gray = false;
switch (image.format()) {
case QImage::Format_Mono:
case QImage::Format_MonoLSB:
case QImage::Format_Indexed8:
gray = true;
for (int i = image.colorCount(); gray && i--;) {
gray = gray & (qRed(cmap[i]) == qGreen(cmap[i]) &&
qRed(cmap[i]) == qBlue(cmap[i]));
for (int i = image.colorCount(); gray && i; i--) {
gray = gray & qIsGray(cmap[i-1]);
}
cinfo.input_components = gray ? 1 : 3;
cinfo.in_color_space = gray ? JCS_GRAYSCALE : JCS_RGB;
break;
case QImage::Format_Grayscale8:
gray = true;
cinfo.input_components = 1;
cinfo.in_color_space = JCS_GRAYSCALE;
break;
default:
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
@ -678,6 +678,9 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, volatile in
}
}
break;
case QImage::Format_Grayscale8:
memcpy(row, image.constScanLine(cinfo.next_scanline), w);
break;
case QImage::Format_RGB888:
memcpy(row, image.constScanLine(cinfo.next_scanline), w * 3);
break;

View File

@ -211,9 +211,14 @@ void QRasterPlatformPixmap::fill(const QColor &color)
pixel = qPremultiply(color.rgba());
const QPixelLayout *layout = &qPixelLayouts[image.format()];
layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0);
} else {
} else if (image.format() == QImage::Format_Alpha8) {
pixel = qAlpha(color.rgba());
} else if (image.format() == QImage::Format_Grayscale8) {
pixel = qGray(color.rgba());
} else
{
pixel = 0;
// ### what about 8 bits
// ### what about 8 bit indexed?
}
image.fill(pixel);

View File

@ -302,6 +302,15 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal
if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
png_set_swap_alpha(png_ptr);
png_read_update_info(png_ptr, info_ptr);
} else if (bit_depth == 8 && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
png_set_expand(png_ptr);
if (image.size() != QSize(width, height) || image.format() != QImage::Format_Grayscale8) {
image = QImage(width, height, QImage::Format_Grayscale8);
if (image.isNull())
return;
}
png_read_update_info(png_ptr, info_ptr);
} else {
if (bit_depth == 16)
@ -674,6 +683,8 @@ QImage::Format QPngHandlerPrivate::readImageFormat()
format = QImage::Format_Mono;
} else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
format = QImage::Format_ARGB32;
} else if (bit_depth == 8 && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
format = QImage::Format_Grayscale8;
} else {
format = QImage::Format_Indexed8;
}
@ -865,6 +876,8 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, vo
else
color_type = PNG_COLOR_TYPE_PALETTE;
}
else if (image.format() == QImage::Format_Grayscale8)
color_type = PNG_COLOR_TYPE_GRAY;
else if (image.hasAlphaChannel())
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
else
@ -963,6 +976,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, vo
case QImage::Format_Mono:
case QImage::Format_MonoLSB:
case QImage::Format_Indexed8:
case QImage::Format_Grayscale8:
case QImage::Format_RGB32:
case QImage::Format_ARGB32:
case QImage::Format_RGB888:

View File

@ -130,7 +130,7 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
case '2': // ascii PGM
case '5': // raw PGM
nbits = 8;
format = QImage::Format_Indexed8;
format = QImage::Format_Grayscale8;
break;
case '3': // ascii PPM
case '6': // raw PPM
@ -208,13 +208,13 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
*p++ = b;
}
} else if (nbits == 8) {
if (mcc == maxc) {
if (mcc == 255) {
while (n--) {
*p++ = read_pbm_int(device);
}
} else {
while (n--) {
*p++ = read_pbm_int(device) * maxc / mcc;
*p++ = read_pbm_int(device) * 255 / mcc;
}
}
} else { // 32 bits
@ -241,14 +241,10 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
}
}
if (nbits == 1) { // bitmap
if (format == QImage::Format_Mono) {
outImage->setColorCount(2);
outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black
} else if (nbits == 8) { // graymap
outImage->setColorCount(maxc+1);
for (int i=0; i<=maxc; i++)
outImage->setColor(i, qRgb(i*255/maxc,i*255/maxc,i*255/maxc));
outImage->setColor(0, qRgb(255,255,255)); // white
outImage->setColor(1, qRgb(0,0,0)); // black
}
return true;
@ -267,6 +263,8 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
image = image.convertToFormat(QImage::Format_Mono);
} else if (image.depth() == 1) {
image = image.convertToFormat(QImage::Format_Indexed8);
} else if (gray) {
image = image.convertToFormat(QImage::Format_Grayscale8);
} else {
switch (image.format()) {
case QImage::Format_RGB16:
@ -335,63 +333,77 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
str.append("255\n");
if (out->write(str, str.length()) != str.length())
return false;
QVector<QRgb> color = image.colorTable();
uint bpl = w*(gray ? 1 : 3);
uchar *buf = new uchar[bpl];
for (uint y=0; y<h; y++) {
uchar *b = image.scanLine(y);
uchar *p = buf;
uchar *end = buf+bpl;
if (gray) {
while (p < end) {
uchar g = (uchar)qGray(color[*b++]);
*p++ = g;
}
} else {
while (p < end) {
QRgb rgb = color[*b++];
*p++ = qRed(rgb);
*p++ = qGreen(rgb);
*p++ = qBlue(rgb);
uint bpl = w * (gray ? 1 : 3);
uchar *buf = new uchar[bpl];
if (image.format() == QImage::Format_Indexed8) {
QVector<QRgb> color = image.colorTable();
for (uint y=0; y<h; y++) {
uchar *b = image.scanLine(y);
uchar *p = buf;
uchar *end = buf+bpl;
if (gray) {
while (p < end) {
uchar g = (uchar)qGray(color[*b++]);
*p++ = g;
}
} else {
while (p < end) {
QRgb rgb = color[*b++];
*p++ = qRed(rgb);
*p++ = qGreen(rgb);
*p++ = qBlue(rgb);
}
}
if (bpl != (uint)out->write((char*)buf, bpl))
return false;
}
} else {
for (uint y=0; y<h; y++) {
uchar *b = image.scanLine(y);
uchar *p = buf;
uchar *end = buf + bpl;
if (gray) {
while (p < end)
*p++ = *b++;
} else {
while (p < end) {
uchar color = *b++;
*p++ = color;
*p++ = color;
*p++ = color;
}
}
if (bpl != (uint)out->write((char*)buf, bpl))
return false;
}
if (bpl != (uint)out->write((char*)buf, bpl))
return false;
}
delete [] buf;
}
break;
}
case 32: {
str.insert(1, gray ? '5' : '6');
str.insert(1, '6');
str.append("255\n");
if (out->write(str, str.length()) != str.length())
return false;
uint bpl = w*(gray ? 1 : 3);
uint bpl = w * 3;
uchar *buf = new uchar[bpl];
for (uint y=0; y<h; y++) {
QRgb *b = (QRgb*)image.scanLine(y);
uchar *p = buf;
uchar *end = buf+bpl;
if (gray) {
while (p < end) {
uchar g = (uchar)qGray(*b++);
*p++ = g;
}
} else {
while (p < end) {
QRgb rgb = *b++;
*p++ = qRed(rgb);
*p++ = qGreen(rgb);
*p++ = qBlue(rgb);
}
while (p < end) {
QRgb rgb = *b++;
*p++ = qRed(rgb);
*p++ = qGreen(rgb);
*p++ = qBlue(rgb);
}
if (bpl != (uint)out->write((char*)buf, bpl))
return false;
}
delete [] buf;
}
break;
}
default:
return false;
@ -506,11 +518,11 @@ QVariant QPpmHandler::option(ImageOption option) const
switch (type) {
case '1': // ascii PBM
case '4': // raw PBM
format = QImage::Format_Mono;
break;
format = QImage::Format_Mono;
break;
case '2': // ascii PGM
case '5': // raw PGM
format = QImage::Format_Indexed8;
format = QImage::Format_Grayscale8;
break;
case '3': // ascii PPM
case '6': // raw PPM

View File

@ -77,6 +77,7 @@ QT_BEGIN_NAMESPACE
\enum QPixelFormat::ColorModel
This enum type is used to describe the color model of the pixelformat.
Alpha was added in 5.5.
\value RGB The color model is RGB.
@ -94,6 +95,8 @@ QT_BEGIN_NAMESPACE
\value HSV The color model is HSV.
\value YUV The color model is YUV.
\value Alpha There is no color model, only alpha is used.
*/
/*!
@ -289,6 +292,21 @@ QT_BEGIN_NAMESPACE
\sa QPixelFormat::TypeInterpretation
*/
/*!
\fn QPixelFormat qPixelFormatAlpha(uchar channelSize,
QPixelFormat::TypeInterpretation typeInterpretation = QPixelFormat::UnsignedInteger)
\relates QPixelFormat
\since 5.5
Constructor function for creating an Alpha format. A mask format can be
described by passing 1 to \a channelSize. Its also possible to define very
accurate alpha formats using doubles to describe each pixel by passing 8
as \a channelSize and FloatingPoint as \a typeInterpretation.
\sa QPixelFormat::TypeInterpretation
*/
/*!
\fn QPixelFormat qPixelFormatCmyk(uchar channelSize,
uchar alphaSize = 0,

View File

@ -111,7 +111,8 @@ public:
CMYK,
HSL,
HSV,
YUV
YUV,
Alpha
};
enum AlphaUsage {
@ -312,6 +313,22 @@ Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatGrayscale(uchar channelSize,
typeInt);
}
Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatAlpha(uchar channelSize,
QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW
{
return QPixelFormat(QPixelFormat::Alpha,
0,
0,
0,
0,
0,
channelSize,
QPixelFormat::UsesAlpha,
QPixelFormat::AtBeginning,
QPixelFormat::NotPremultiplied,
typeInt);
}
Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatCmyk(uchar channelSize,
uchar alfa=0,
QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha,

View File

@ -281,6 +281,22 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, con
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
break;
case QImage::Format_Alpha8:
if (context->isOpenGLES() || context->format().profile() != QSurfaceFormat::CoreProfile) {
externalFormat = internalFormat = GL_ALPHA;
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
}
// ### add support for core profiles.
break;
case QImage::Format_Grayscale8:
if (context->isOpenGLES() || context->format().profile() != QSurfaceFormat::CoreProfile) {
externalFormat = internalFormat = GL_LUMINANCE;
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
}
// ### add support for core profiles.
break;
default:
break;
}

View File

@ -772,7 +772,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGRs30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Mono
0, // Format_Invalid,
@ -797,7 +799,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_MonoLSB
0, // Format_Invalid,
@ -822,7 +826,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Indexed8
0, // Format_Invalid,
@ -847,7 +853,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB32
0, // Format_Invalid,
@ -872,7 +880,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB32
0, // Format_Invalid,
@ -897,7 +907,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB32_Premultiplied
0, // Format_Invalid,
@ -922,7 +934,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB16
0, // Format_Invalid,
@ -947,7 +961,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB8565_Premultiplied
0, // Format_Invalid,
@ -972,7 +988,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB666
0, // Format_Invalid,
@ -997,7 +1015,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB6666_Premultiplied
0, // Format_Invalid,
@ -1022,7 +1042,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB555
0, // Format_Invalid,
@ -1047,7 +1069,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB8555_Premultiplied
0, // Format_Invalid,
@ -1072,7 +1096,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB888
0, // Format_Invalid,
@ -1097,7 +1123,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB444
0, // Format_Invalid,
@ -1122,7 +1150,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB4444_Premultiplied
0, // Format_Invalid,
@ -1147,7 +1177,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBX8888
0, // Format_Invalid,
@ -1178,7 +1210,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBA8888
0, // Format_Invalid,
@ -1203,7 +1237,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBA8888_Premultiplied
0, // Format_Invalid,
@ -1234,7 +1270,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_BGR30
0, // Format_Invalid,
@ -1259,7 +1297,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_A2BGR30_Premultiplied
0, // Format_Invalid,
@ -1284,7 +1324,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB30
0, // Format_Invalid,
@ -1309,7 +1351,9 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_A2RGB30_Premultiplied
0, // Format_Invalid,
@ -1334,8 +1378,64 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Alpha8
0, // Format_Invalid,
0, // Format_Mono,
0, // Format_MonoLSB,
0, // Format_Indexed8,
0, // Format_RGB32,
0, // Format_ARGB32,
0, // Format_ARGB32_Premultiplied,
0, // Format_RGB16,
0, // Format_ARGB8565_Premultiplied,
0, // Format_RGB666,
0, // Format_ARGB6666_Premultiplied,
0, // Format_RGB555,
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
0, // Format_ARGB4444_Premultiplied,
0, // Format_RGBX8888,
0, // Format_RGBA8888,
0, // Format_RGBA8888_Premultiplied,
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Grayscale8
0, // Format_Invalid,
0, // Format_Mono,
0, // Format_MonoLSB,
0, // Format_Indexed8,
0, // Format_RGB32,
0, // Format_ARGB32,
0, // Format_ARGB32_Premultiplied,
0, // Format_RGB16,
0, // Format_ARGB8565_Premultiplied,
0, // Format_RGB666,
0, // Format_ARGB6666_Premultiplied,
0, // Format_RGB555,
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
0, // Format_ARGB4444_Premultiplied,
0, // Format_RGBX8888,
0, // Format_RGBA8888,
0, // Format_RGBA8888_Premultiplied,
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
}
};
@ -1363,7 +1463,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Mono
0, // Format_Invalid,
@ -1388,7 +1490,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_MonoLSB
0, // Format_Invalid,
@ -1413,7 +1517,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Indexed8
0, // Format_Invalid,
@ -1438,7 +1544,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB32
0, // Format_Invalid,
@ -1463,7 +1571,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB32
0, // Format_Invalid,
@ -1488,7 +1598,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB32_Premultiplied
0, // Format_Invalid,
@ -1513,7 +1625,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB16
0, // Format_Invalid,
@ -1538,7 +1652,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB8565_Premultiplied
0, // Format_Invalid,
@ -1563,7 +1679,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB666
0, // Format_Invalid,
@ -1588,7 +1706,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB6666_Premultiplied
0, // Format_Invalid,
@ -1613,7 +1733,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB555
0, // Format_Invalid,
@ -1638,7 +1760,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB8555_Premultiplied
0, // Format_Invalid,
@ -1663,7 +1787,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB888
0, // Format_Invalid,
@ -1688,7 +1814,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB444
0, // Format_Invalid,
@ -1713,7 +1841,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB4444_Premultiplied
0, // Format_Invalid,
@ -1738,7 +1868,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBX8888
0, // Format_Invalid,
@ -1769,7 +1901,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBA8888
0, // Format_Invalid,
@ -1794,7 +1928,9 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBA8888_Premultiplied
0, // Format_Invalid,
@ -1826,6 +1962,8 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_BGR30
0, // Format_Invalid,
@ -1851,6 +1989,7 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
qt_blend_a2rgb30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied,
qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_RGB30,
qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied,
0, 0,
},
{ // Format_A2BGR30_Premultiplied
0, // Format_Invalid,
@ -1876,6 +2015,7 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
qt_blend_a2rgb30pm_on_a2rgb30pm, // Format_A2BGR30_Premultiplied,
qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_RGB30,
qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied,
0, 0,
},
{ // Format_RGB30
0, // Format_Invalid,
@ -1901,6 +2041,7 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2BGR30_Premultiplied,
qt_blend_rgb30_on_rgb30, // Format_RGB30,
qt_blend_a2rgb30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied,
0, 0,
},
{ // Format_A2RGB30_Premultiplied
0, // Format_Invalid,
@ -1925,8 +2066,63 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_BGR30,
qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2BGR30_Premultiplied,
qt_blend_rgb30_on_rgb30, // Format_RGB30,
qt_blend_a2rgb30pm_on_a2rgb30pm // Format_A2RGB30_Premultiplied,
qt_blend_a2rgb30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied,
0, 0,
},
{ // Format_Alpha8
0, // Format_Invalid,
0, // Format_Mono,
0, // Format_MonoLSB,
0, // Format_Indexed8,
0, // Format_RGB32,
0, // Format_ARGB32,
0, // Format_ARGB32_Premultiplied,
0, // Format_RGB16,
0, // Format_ARGB8565_Premultiplied,
0, // Format_RGB666,
0, // Format_ARGB6666_Premultiplied,
0, // Format_RGB555,
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
0, // Format_ARGB4444_Premultiplied,
0, // Format_RGBX8888,
0, // Format_RGBA8888,
0, // Format_RGBA8888_Premultiplied,
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Grayscale8
0, // Format_Invalid,
0, // Format_Mono,
0, // Format_MonoLSB,
0, // Format_Indexed8,
0, // Format_RGB32,
0, // Format_ARGB32,
0, // Format_ARGB32_Premultiplied,
0, // Format_RGB16,
0, // Format_ARGB8565_Premultiplied,
0, // Format_RGB666,
0, // Format_ARGB6666_Premultiplied,
0, // Format_RGB555,
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
0, // Format_ARGB4444_Premultiplied,
0, // Format_RGBX8888,
0, // Format_RGBA8888,
0, // Format_RGBA8888_Premultiplied,
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
}
};
SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats] = {
@ -1953,7 +2149,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Mono
0, // Format_Invalid,
@ -1978,7 +2176,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_MonoLSB
0, // Format_Invalid,
@ -2003,7 +2203,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Indexed8
0, // Format_Invalid,
@ -2028,7 +2230,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB32
0, // Format_Invalid,
@ -2053,7 +2257,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB32
0, // Format_Invalid,
@ -2078,7 +2284,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB32_Premultiplied
0, // Format_Invalid,
@ -2103,7 +2311,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB16
0, // Format_Invalid,
@ -2128,7 +2338,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB8565_Premultiplied
0, // Format_Invalid,
@ -2153,7 +2365,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB666
0, // Format_Invalid,
@ -2178,7 +2392,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB6666_Premultiplied
0, // Format_Invalid,
@ -2203,7 +2419,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB555
0, // Format_Invalid,
@ -2228,7 +2446,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB8555_Premultiplied
0, // Format_Invalid,
@ -2253,7 +2473,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB888
0, // Format_Invalid,
@ -2278,7 +2500,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB444
0, // Format_Invalid,
@ -2303,7 +2527,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_ARGB4444_Premultiplied
0, // Format_Invalid,
@ -2328,7 +2554,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBX8888
0, // Format_Invalid,
@ -2359,7 +2587,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBA8888
0, // Format_Invalid,
@ -2384,7 +2614,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGBA8888_Premultiplied
0, // Format_Invalid,
@ -2415,7 +2647,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_BGR30
0, // Format_Invalid,
@ -2440,7 +2674,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_A2BGR30_Premultiplied
0, // Format_Invalid,
@ -2465,7 +2701,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_RGB30
0, // Format_Invalid,
@ -2490,7 +2728,9 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_A2RGB30_Premultiplied
0, // Format_Invalid,
@ -2515,7 +2755,63 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0 // Format_A2RGB30_Premultiplied,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Alpha8
0, // Format_Invalid,
0, // Format_Mono,
0, // Format_MonoLSB,
0, // Format_Indexed8,
0, // Format_RGB32,
0, // Format_ARGB32,
0, // Format_ARGB32_Premultiplied,
0, // Format_RGB16,
0, // Format_ARGB8565_Premultiplied,
0, // Format_RGB666,
0, // Format_ARGB6666_Premultiplied,
0, // Format_RGB555,
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
0, // Format_ARGB4444_Premultiplied,
0, // Format_RGBX8888,
0, // Format_RGBA8888,
0, // Format_RGBA8888_Premultiplied,
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
{ // Format_Grayscale8
0, // Format_Invalid,
0, // Format_Mono,
0, // Format_MonoLSB,
0, // Format_Indexed8,
0, // Format_RGB32,
0, // Format_ARGB32,
0, // Format_ARGB32_Premultiplied,
0, // Format_RGB16,
0, // Format_ARGB8565_Premultiplied,
0, // Format_RGB666,
0, // Format_ARGB6666_Premultiplied,
0, // Format_RGB555,
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
0, // Format_ARGB4444_Premultiplied,
0, // Format_RGBX8888,
0, // Format_RGBA8888,
0, // Format_RGBA8888_Premultiplied,
0, // Format_BGR30,
0, // Format_A2BGR30_Premultiplied,
0, // Format_RGB30,
0, // Format_A2RGB30_Premultiplied,
0, // Format_Alpha8
0, // Format_Grayscale8
},
};

View File

@ -535,6 +535,22 @@ static const uint *QT_FASTCALL convertRGBA8888ToARGB32PM(uint *buffer, const uin
return buffer;
}
static const uint *QT_FASTCALL convertAlpha8ToRGB32(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qRgba(0, 0, 0, src[i]);
return buffer;
}
static const uint *QT_FASTCALL convertGrayscale8ToRGB32(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qRgb(src[i], src[i], src[i]);
return buffer;
}
static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
@ -611,6 +627,30 @@ static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint
return buffer;
}
static const uint *QT_FASTCALL convertAlpha8FromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qAlpha(src[i]);
return buffer;
}
static const uint *QT_FASTCALL convertGrayscale8FromRGB32(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qGray(src[i]);
return buffer;
}
static const uint *QT_FASTCALL convertGrayscale8FromARGB32PM(uint *buffer, const uint *src, int count,
const QPixelLayout *, const QRgb *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qGray(qUnpremultiply(src[i]));
return buffer;
}
template <QPixelLayout::BPP bpp> static
uint QT_FASTCALL fetchPixel(const uchar *src, int index);
@ -764,6 +804,8 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
{ 10, 20, 10, 10, 10, 0, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertA2RGB30PMFromARGB32PM<PixelOrderBGR>, 0 }, // Format_A2BGR30_Premultiplied
{ 10, 0, 10, 10, 10, 20, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertRGB30FromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB> }, // Format_RGB30
{ 10, 0, 10, 10, 10, 20, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertA2RGB30PMFromARGB32PM<PixelOrderRGB>, 0 }, // Format_A2RGB30_Premultiplied
{ 0, 0, 0, 0, 0, 0, 8, 0, false, QPixelLayout::BPP8, convertAlpha8ToRGB32, convertAlpha8FromARGB32PM, 0 }, // Format_Alpha8
{ 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertGrayscale8ToRGB32, convertGrayscale8FromARGB32PM, convertGrayscale8FromRGB32 } // Format_Grayscale8
};
FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
@ -875,6 +917,8 @@ static DestFetchProc destFetchProc[QImage::NImageFormats] =
destFetch, // Format_A2BGR30_Premultiplied
destFetch, // Format_RGB30
destFetch, // Format_A2RGB30_Premultiplied
destFetch, // Format_Alpha8
destFetch, // Format_Grayscale8
};
/*
@ -1019,6 +1063,8 @@ static DestStoreProc destStoreProc[QImage::NImageFormats] =
destStore, // Format_A2BGR30_Premultiplied
destStore, // Format_RGB30
destStore, // Format_A2RGB30_Premultiplied
destStore, // Format_Alpha8
destStore, // Format_Grayscale8
};
/*
@ -2274,6 +2320,8 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchUntransformed, // Format_A2BGR30_Premultiplied
fetchUntransformed, // Format_RGB30
fetchUntransformed, // Format_A2RGB30_Premultiplied
fetchUntransformed, // Alpha8
fetchUntransformed, // Grayscale8
},
// Tiled
{
@ -2299,7 +2347,9 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchUntransformed, // BGR30
fetchUntransformed, // A2BGR30_Premultiplied
fetchUntransformed, // RGB30
fetchUntransformed // A2RGB30_Premultiplied
fetchUntransformed, // A2RGB30_Premultiplied
fetchUntransformed, // Alpha8
fetchUntransformed, // Grayscale8
},
// Transformed
{
@ -2326,6 +2376,8 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformed<BlendTransformed>, // A2BGR30_Premultiplied
fetchTransformed<BlendTransformed>, // RGB30
fetchTransformed<BlendTransformed>, // A2RGB30_Premultiplied
fetchTransformed<BlendTransformed>, // Alpah8
fetchTransformed<BlendTransformed>, // Grayscale8
},
{
0, // TransformedTiled
@ -2351,6 +2403,8 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformed<BlendTransformedTiled>, // A2BGR30_Premultiplied
fetchTransformed<BlendTransformedTiled>, // RGB30
fetchTransformed<BlendTransformedTiled>, // A2RGB30_Premultiplied
fetchTransformed<BlendTransformedTiled>, // Alpha8
fetchTransformed<BlendTransformedTiled>, // Grayscale8
},
{
0, // Bilinear
@ -2376,6 +2430,8 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformedBilinear<BlendTransformedBilinear>, // A2BGR30_Premultiplied
fetchTransformedBilinear<BlendTransformedBilinear>, // RGB30
fetchTransformedBilinear<BlendTransformedBilinear>, // A2RGB30_Premultiplied
fetchTransformedBilinear<BlendTransformedBilinear>, // Alpha8
fetchTransformedBilinear<BlendTransformedBilinear>, // Grayscale8
},
{
0, // BilinearTiled
@ -2400,7 +2456,9 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // BGR30
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // A2BGR30_Premultiplied
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGB30
fetchTransformedBilinear<BlendTransformedBilinearTiled> // A2RGB30_Premultiplied
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // A2RGB30_Premultiplied
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // Alpha8
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // Grayscale8
},
};
@ -5825,6 +5883,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_untransformed_generic,
blend_untransformed_generic,
blend_untransformed_generic,
blend_untransformed_generic,
blend_untransformed_generic,
},
// Tiled
{
@ -5851,6 +5911,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_tiled_generic,
blend_tiled_generic,
blend_tiled_generic,
blend_tiled_generic,
blend_tiled_generic,
},
// Transformed
{
@ -5877,6 +5939,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
blend_src_generic,
blend_src_generic,
},
// TransformedTiled
{
@ -5902,6 +5966,7 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
blend_src_generic,
blend_src_generic
},
// Bilinear
@ -5929,6 +5994,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
blend_src_generic,
blend_src_generic,
},
// BilinearTiled
{
@ -5955,6 +6022,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic, // A2BGR30_Premultiplied
blend_src_generic, // RGB30
blend_src_generic, // A2RGB30_Premultiplied
blend_src_generic, // Alpha8
blend_src_generic, // Grayscale8
}
};
@ -6475,6 +6544,22 @@ static void qt_rectfill_nonpremul_rgba(QRasterBuffer *rasterBuffer,
ARGB2RGBA(qUnpremultiply(color)), x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_alpha(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
quint32 color)
{
qt_rectfill<quint8>(reinterpret_cast<quint8 *>(rasterBuffer->buffer()),
qAlpha(color), x, y, width, height, rasterBuffer->bytesPerLine());
}
static void qt_rectfill_gray(QRasterBuffer *rasterBuffer,
int x, int y, int width, int height,
quint32 color)
{
qt_rectfill<quint8>(reinterpret_cast<quint8 *>(rasterBuffer->buffer()),
qGray(color), x, y, width, height, rasterBuffer->bytesPerLine());
}
// Map table for destination image format. Contains function pointers
// for blends of various types unto the destination
@ -6659,6 +6744,20 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
0,
0
},
// Format_Alpha8
{
blend_color_generic,
blend_src_generic,
0, 0, 0,
qt_rectfill_alpha
},
// Format_Grayscale8
{
blend_color_generic,
blend_src_generic,
0, 0, 0,
qt_rectfill_gray
},
};
#if defined(Q_CC_MSVC) && !defined(_MIPS_)

View File

@ -481,6 +481,21 @@ QT_IMPL_MEMROTATE(quint16)
QT_IMPL_MEMROTATE(quint24)
QT_IMPL_MEMROTATE(quint8)
void qt_memrotate90_8(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
{
qt_memrotate90(srcPixels, w, h, sbpl, destPixels, dbpl);
}
void qt_memrotate180_8(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
{
qt_memrotate180(srcPixels, w, h, sbpl, destPixels, dbpl);
}
void qt_memrotate270_8(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
{
qt_memrotate270(srcPixels, w, h, sbpl, destPixels, dbpl);
}
void qt_memrotate90_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
{
qt_memrotate90((const ushort *)srcPixels, w, h, sbpl, (ushort *)destPixels, dbpl);
@ -537,6 +552,8 @@ MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3] =
{ qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_A2BGR30_Premultiplied,
{ qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGB30,
{ qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_A2RGB30_Premultiplied,
{ qt_memrotate90_8, qt_memrotate180_8, qt_memrotate270_8 }, // Format_Alpha8,
{ qt_memrotate90_8, qt_memrotate180_8, qt_memrotate270_8 }, // Format_Grayscale8,
};
QT_END_NAMESPACE

View File

@ -425,6 +425,7 @@ void QRasterPaintEngine::init()
case QImage::Format_RGBA8888:
case QImage::Format_A2BGR30_Premultiplied:
case QImage::Format_A2RGB30_Premultiplied:
case QImage::Format_Alpha8:
gccaps |= PorterDuff;
break;
case QImage::Format_RGB32:
@ -436,6 +437,7 @@ void QRasterPaintEngine::init()
case QImage::Format_RGBX8888:
case QImage::Format_BGR30:
case QImage::Format_RGB30:
case QImage::Format_Grayscale8:
break;
default:
break;

View File

@ -293,13 +293,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
m_image = QImage(width, height, QImage::Format_Mono);
break;
case QFontEngine::Format_A8: {
m_image = QImage(width, height, QImage::Format_Indexed8);
m_image.fill(0);
QVector<QRgb> colors(256);
QRgb *it = colors.data();
for (int i=0; i<256; ++i, ++it)
*it = 0xff000000 | i | (i<<8) | (i<<16);
m_image.setColorTable(colors);
m_image = QImage(width, height, QImage::Format_Alpha8);
break; }
case QFontEngine::Format_A32:
m_image = QImage(width, height, QImage::Format_RGB32);

View File

@ -42,6 +42,7 @@
#include "qdistancefield_p.h"
#include <qmath.h>
#include <private/qdatabuffer_p.h>
#include <private/qimage_p.h>
#include <private/qpathsimplifier_p.h>
QT_BEGIN_NAMESPACE
@ -995,12 +996,12 @@ QImage QDistanceField::toImage(QImage::Format format) const
if (isNull())
return QImage();
QImage image(d->width, d->height, format == QImage::Format_Indexed8 ?
QImage image(d->width, d->height, qt_depthForFormat(format) == 8 ?
format : QImage::Format_ARGB32_Premultiplied);
if (image.isNull())
return image;
if (format == QImage::Format_Indexed8) {
if (image.depth() == 8) {
for (int y = 0; y < d->height; ++y)
memcpy(image.scanLine(y), scanLine(y), d->width);
} else {

View File

@ -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);

View File

@ -1858,7 +1858,7 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
format = QImage::Format_Mono;
break;
case Format_A8:
format = QImage::Format_Indexed8;
format = QImage::Format_Alpha8;
break;
case Format_A32:
format = QImage::Format_ARGB32;
@ -1968,13 +1968,8 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition)
const int pitch = antialias ? (glyph->width + 3) & ~3 : ((glyph->width + 31)/32) * 4;
QImage img(glyph->width, glyph->height, antialias ? QImage::Format_Indexed8 : QImage::Format_Mono);
if (antialias) {
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
colors[i] = qRgba(0, 0, 0, i);
img.setColorTable(colors);
} else {
QImage img(glyph->width, glyph->height, antialias ? QImage::Format_Alpha8 : QImage::Format_Mono);
if (!antialias) {
QVector<QRgb> colors(2);
colors[0] = qRgba(0, 0, 0, 0);
colors[1] = qRgba(0, 0, 0, 255);

View File

@ -404,7 +404,7 @@ QImage QFontEngineQPF2::alphaMapForGlyph(glyph_t g)
const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph);
QImage image(bits,glyph->width, glyph->height, glyph->bytesPerLine, QImage::Format_Indexed8);
QImage image(bits,glyph->width, glyph->height, glyph->bytesPerLine, QImage::Format_Alpha8);
return image;
}

View File

@ -642,15 +642,11 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosit
QImage im = imageForGlyph(glyph, subPixelPosition, false, x);
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 = qGray(*src);
++dst;
@ -658,7 +654,7 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosit
}
}
return indexed;
return alphaMap;
}
QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &x)

View File

@ -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

View File

@ -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

View File

@ -713,7 +713,8 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp
Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied
|| img.format() == QImage::Format_RGB32
|| img.format() == QImage::Format_Indexed8);
|| img.format() == QImage::Format_Indexed8
|| img.format() == QImage::Format_Grayscale8);
// choose the alpha such that pixels at radius distance from a fully
// saturated pixel will have an alpha component of no greater than
@ -788,7 +789,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source)
QImage srcImage = source;
if (source.format() == QImage::Format_Indexed8) {
if (source.format() == QImage::Format_Indexed8 || source.format() == QImage::Format_Grayscale8) {
// assumes grayscale
QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
@ -898,7 +899,7 @@ Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius,
Q_WIDGETS_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0)
{
if (blurImage.format() == QImage::Format_Indexed8)
if (blurImage.format() == QImage::Format_Indexed8 || blurImage.format() == QImage::Format_Grayscale8)
expblur<12, 10, true>(blurImage, radius, quality, transposed);
else
expblur<12, 10, false>(blurImage, radius, quality, transposed);

View File

@ -781,6 +781,13 @@ void tst_QImage::convertToFormat_data()
<< int(QImage::Format_ARGB32) << 0xff00ff00;
QTest::newRow("blue rgb30 -> argb32") << int(QImage::Format_RGB30) << 0xff0000ff
<< int(QImage::Format_ARGB32) << 0xff0000ff;
QTest::newRow("white gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xfffffeffu
<< int(QImage::Format_ARGB32_Premultiplied) << 0xfffefefeu;
QTest::newRow("gray gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xff565557u
<< int(QImage::Format_ARGB32_Premultiplied) << 0xff555555u;
QTest::newRow("black gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xff000100u
<< int(QImage::Format_ARGB32_Premultiplied) << 0xff000000u;
}
@ -1010,6 +1017,10 @@ void tst_QImage::rotate_data()
<< QImage::Format_RGBX8888 << d;
QTest::newRow(qPrintable(title.arg("Format_RGBA8888_Premultiplied")))
<< QImage::Format_RGBA8888_Premultiplied << d;
QTest::newRow(qPrintable(title.arg("Format_Alpha8")))
<< QImage::Format_Alpha8 << d;
QTest::newRow(qPrintable(title.arg("Format_Grayscale8")))
<< QImage::Format_Grayscale8 << d;
}
}
@ -2098,16 +2109,20 @@ void tst_QImage::fillPixel_data()
QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u;
QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u;
QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u;
QTest::newRow("Alpha8, transparent") << QImage::Format_Alpha8 << 0x0u << 0x00000000u;
QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u;
QTest::newRow("RGB32, red") << QImage::Format_RGB32 << 0xffff0000u << 0xffff0000u;
QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u;
QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u;
QTest::newRow("Grayscale8, grey") << QImage::Format_Grayscale8 << 0xff808080u << 0xff808080u;
QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u;
QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u;
QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u;
QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u;
QTest::newRow("Alpha8, semi-red") << QImage::Format_Alpha8 << 0x80000080u << 0x80000000u;
}
void tst_QImage::fillPixel()

View File

@ -495,13 +495,13 @@ void tst_QImageReader::imageFormat_data()
QTest::addColumn<QImage::Format>("imageFormat");
QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm") << QImage::Format_Mono;
QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm") << QImage::Format_Indexed8;
QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm") << QImage::Format_Grayscale8;
QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-3") << QString("runners.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("ppm-4") << QString("test.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Indexed8;
QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Grayscale8;
QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;

View File

@ -3448,7 +3448,8 @@ void tst_QPainter::drawImage_data()
for (int srcFormat = QImage::Format_Mono; srcFormat < QImage::NImageFormats; ++srcFormat) {
for (int dstFormat = QImage::Format_Mono; dstFormat < QImage::NImageFormats; ++dstFormat) {
if (dstFormat == QImage::Format_Indexed8)
// Indexed8 can't be painted to, and Alpha8 can't hold a color.
if (dstFormat == QImage::Format_Indexed8 || dstFormat == QImage::Format_Alpha8)
continue;
for (int odd_x = 0; odd_x <= 1; ++odd_x) {
for (int odd_width = 0; odd_width <= 1; ++odd_width) {