QPixmapData::QPixmapData(PixelType pixelType)
- : w(0),
- h(0),
- d(0),
- is_null(true),
- ref(0),
+ : ref(0),
detach_no(0),
type(pixelType),
ser_no(0)
int QPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
{
- if (!image.d)
+ if (isNull())
return 0;
// override the image dpi with the screen dpi when rendering to a pixmap
switch (metric) {
case QPaintDevice::PdmWidth:
- return w;
+ return width();
case QPaintDevice::PdmHeight:
- return h;
+ return height();
case QPaintDevice::PdmWidthMM:
- return qRound(image.d->width * 25.4 / QX11Info::appDpiX());
+ return qRound(width() * 25.4 / QX11Info::appDpiX());
case QPaintDevice::PdmHeightMM:
- return qRound(image.d->height * 25.4 / QX11Info::appDpiY());
+ return qRound(height() * 25.4 / QX11Info::appDpiY());
case QPaintDevice::PdmNumColors:
- if (image.d->depth == 1)
+ if (depth() == 1)
return 2;
return 0;
case QPaintDevice::PdmDepth:
}
image = QImage(width, height, format);
- w = width;
- h = height;
- d = image.depth();
- is_null = (w <= 0 || h <= 0);
if (pixelType() == BitmapType && !image.isNull()) {
image.setColorTable(monoColorTable());
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* buffer();
- inline int width() const { return w; }
- inline int height() const { return h; }
- inline int depth() const { return d; }
- inline bool isNull() const { return is_null; }
+ inline int width() const { return image.width(); }
+ inline int height() const { return image.height(); }
+ inline int depth() const { return image.depth(); }
+ inline bool isNull() const { return image.isNull(); }
inline qint64 cacheKey() const {
return ((static_cast<qint64>(ser_no) << 32)
| (static_cast<qint64>(detach_no)));
protected:
void setSerialNumber(int serNo);
- int w;
- int h;
- int d;
- bool is_null;
private:
friend class QPixmap;