mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 11:22:58 +00:00
replace QRasterPixmapData::createPixmapForImage() with its body
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
3ebd923227
commit
40558f0630
2 changed files with 45 additions and 51 deletions
|
@ -93,14 +93,56 @@ bool QRasterPixmapData::fromData(const uchar *buffer, uint len, const char *form
|
||||||
if (image.isNull())
|
if (image.isNull())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
createPixmapForImage(image, flags);
|
fromImage(image, flags);
|
||||||
return !isNull();
|
return !isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRasterPixmapData::fromImage(const QImage &sourceImage,
|
void QRasterPixmapData::fromImage(const QImage &sourceImage,
|
||||||
Qt::ImageConversionFlags flags)
|
Qt::ImageConversionFlags flags)
|
||||||
{
|
{
|
||||||
createPixmapForImage(sourceImage, flags);
|
QImage::Format format;
|
||||||
|
if (flags & Qt::NoFormatConversion) {
|
||||||
|
format = sourceImage.format();
|
||||||
|
} else if (pixelType() == BitmapType) {
|
||||||
|
format = QImage::Format_MonoLSB;
|
||||||
|
} else {
|
||||||
|
if (sourceImage.depth() == 1) {
|
||||||
|
format = sourceImage.hasAlphaChannel()
|
||||||
|
? QImage::Format_ARGB32_Premultiplied
|
||||||
|
: QImage::Format_RGB32;
|
||||||
|
} else {
|
||||||
|
QImage::Format opaqueFormat = QImage::systemFormat();
|
||||||
|
QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
|
||||||
|
|
||||||
|
// We don't care about the others...
|
||||||
|
if (opaqueFormat == QImage::Format_RGB16) {
|
||||||
|
alphaFormat = QImage::Format_ARGB8565_Premultiplied;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sourceImage.hasAlphaChannel()) {
|
||||||
|
format = opaqueFormat;
|
||||||
|
} else if ((flags & Qt::NoOpaqueDetection) == 0
|
||||||
|
&& !sourceImage.data_ptr()->checkForAlphaPixels())
|
||||||
|
{
|
||||||
|
format = opaqueFormat;
|
||||||
|
} else {
|
||||||
|
format = alphaFormat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image = sourceImage.convertToFormat(format);
|
||||||
|
|
||||||
|
if (image.d) {
|
||||||
|
w = image.d->width;
|
||||||
|
h = image.d->height;
|
||||||
|
d = image.d->depth;
|
||||||
|
} else {
|
||||||
|
w = h = d = 0;
|
||||||
|
}
|
||||||
|
is_null = (w <= 0 || h <= 0);
|
||||||
|
|
||||||
|
setSerialNumber(image.cacheKey() >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRasterPixmapData::fromImageReader(QImageReader *imageReader,
|
void QRasterPixmapData::fromImageReader(QImageReader *imageReader,
|
||||||
|
@ -110,7 +152,7 @@ void QRasterPixmapData::fromImageReader(QImageReader *imageReader,
|
||||||
if (image.isNull())
|
if (image.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
createPixmapForImage(image, flags);
|
fromImage(image, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// from qwindowsurface.cpp
|
// from qwindowsurface.cpp
|
||||||
|
@ -261,53 +303,6 @@ int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRasterPixmapData::createPixmapForImage(const QImage &sourceImage, Qt::ImageConversionFlags flags)
|
|
||||||
{
|
|
||||||
QImage::Format format;
|
|
||||||
if (flags & Qt::NoFormatConversion) {
|
|
||||||
format = sourceImage.format();
|
|
||||||
} else if (pixelType() == BitmapType) {
|
|
||||||
format = QImage::Format_MonoLSB;
|
|
||||||
} else {
|
|
||||||
if (sourceImage.depth() == 1) {
|
|
||||||
format = sourceImage.hasAlphaChannel()
|
|
||||||
? QImage::Format_ARGB32_Premultiplied
|
|
||||||
: QImage::Format_RGB32;
|
|
||||||
} else {
|
|
||||||
QImage::Format opaqueFormat = QImage::systemFormat();
|
|
||||||
QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
|
|
||||||
|
|
||||||
// We don't care about the others...
|
|
||||||
if (opaqueFormat == QImage::Format_RGB16) {
|
|
||||||
alphaFormat = QImage::Format_ARGB8565_Premultiplied;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sourceImage.hasAlphaChannel()) {
|
|
||||||
format = opaqueFormat;
|
|
||||||
} else if ((flags & Qt::NoOpaqueDetection) == 0
|
|
||||||
&& !sourceImage.data_ptr()->checkForAlphaPixels())
|
|
||||||
{
|
|
||||||
format = opaqueFormat;
|
|
||||||
} else {
|
|
||||||
format = alphaFormat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
image = sourceImage.convertToFormat(format);
|
|
||||||
|
|
||||||
if (image.d) {
|
|
||||||
w = image.d->width;
|
|
||||||
h = image.d->height;
|
|
||||||
d = image.d->depth;
|
|
||||||
} else {
|
|
||||||
w = h = d = 0;
|
|
||||||
}
|
|
||||||
is_null = (w <= 0 || h <= 0);
|
|
||||||
|
|
||||||
setSerialNumber(image.cacheKey() >> 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
QImage* QRasterPixmapData::buffer()
|
QImage* QRasterPixmapData::buffer()
|
||||||
{
|
{
|
||||||
return ℑ
|
return ℑ
|
||||||
|
|
|
@ -75,7 +75,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
||||||
void createPixmapForImage(const QImage &sourceImage, Qt::ImageConversionFlags flags);
|
|
||||||
void setImage(const QImage &image);
|
void setImage(const QImage &image);
|
||||||
QImage image;
|
QImage image;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue