Qt 4.8
Public Functions | Properties | List of all members
QVolatileImage Class Reference

#include <qvolatileimage_p.h>

Public Functions

void beginDataAccess () const
 
ucharbits ()
 Access to pixel data via bits() or constBits() should be guarded by begin/endDataAccess(). More...
 
int byteCount () const
 
int bytesPerLine () const
 
const ucharconstBits () const
 
const QImageconstImageRef () const
 Non-detaching version, for read-only access only. More...
 
void copyFrom (QVolatileImage *source, const QRect &rect)
 
int depth () const
 
void * duplicateNativeImage () const
 
void endDataAccess (bool readOnly=false) const
 
bool ensureFormat (QImage::Format format)
 
void fill (uint pixelValue)
 
QImage::Format format () const
 
bool hasAlphaChannel () const
 
int height () const
 
QImageimageRef ()
 Returns a reference to the image that is potentially using some native buffer internally. More...
 
bool isNull () const
 
QVolatileImageoperator= (const QVolatileImage &rhs)
 
QPaintEnginepaintEngine ()
 To be called from the PixmapData's paintEngine(). More...
 
bool paintingActive () const
 
 QVolatileImage ()
 
 QVolatileImage (int w, int h, QImage::Format format)
 
 QVolatileImage (const QImage &sourceImage)
 
 QVolatileImage (void *nativeImage, void *nativeMask=0)
 
 QVolatileImage (const QVolatileImage &other)
 
void setAlphaChannel (const QPixmap &alphaChannel)
 
QImage toImage () const
 This will always perform a copy of the pixel data. More...
 
int width () const
 
 ~QVolatileImage ()
 

Properties

QSharedDataPointer< QVolatileImageDatad
 

Detailed Description

Definition at line 63 of file qvolatileimage_p.h.

Constructors and Destructors

◆ QVolatileImage() [1/5]

QVolatileImage::QVolatileImage ( )

Definition at line 68 of file qvolatileimage.cpp.

69  : d(new QVolatileImageData)
70 {
71 }
QSharedDataPointer< QVolatileImageData > d

◆ QVolatileImage() [2/5]

QVolatileImage::QVolatileImage ( int  w,
int  h,
QImage::Format  format 
)

Definition at line 73 of file qvolatileimage.cpp.

74  : d(new QVolatileImageData(w, h, format))
75 {
76 }
QSharedDataPointer< QVolatileImageData > d

◆ QVolatileImage() [3/5]

QVolatileImage::QVolatileImage ( const QImage sourceImage)
explicit

Definition at line 78 of file qvolatileimage.cpp.

79  : d(new QVolatileImageData(sourceImage))
80 {
81 }
QSharedDataPointer< QVolatileImageData > d

◆ QVolatileImage() [4/5]

QVolatileImage::QVolatileImage ( void *  nativeImage,
void *  nativeMask = 0 
)
explicit

Definition at line 83 of file qvolatileimage.cpp.

84  : d(new QVolatileImageData(nativeImage, nativeMask))
85 {
86 }
QSharedDataPointer< QVolatileImageData > d

◆ QVolatileImage() [5/5]

QVolatileImage::QVolatileImage ( const QVolatileImage other)

Definition at line 91 of file qvolatileimage.cpp.

92  : d(other.d)
93 {
94 }
QSharedDataPointer< QVolatileImageData > d

◆ ~QVolatileImage()

QVolatileImage::~QVolatileImage ( )

Definition at line 96 of file qvolatileimage.cpp.

97 {
98 }

Functions

◆ beginDataAccess()

void QVolatileImage::beginDataAccess ( ) const

◆ bits()

uchar * QVolatileImage::bits ( )

Access to pixel data via bits() or constBits() should be guarded by begin/endDataAccess().

Definition at line 165 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::ensureReadback().

166 {
167  return d->image.bits();
168 }
QSharedDataPointer< QVolatileImageData > d
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946

◆ byteCount()

int QVolatileImage::byteCount ( ) const

Definition at line 136 of file qvolatileimage.cpp.

137 {
138  return d->image.byteCount();
139 }
int byteCount() const
Returns the number of bytes occupied by the image data.
Definition: qimage.cpp:1800
QSharedDataPointer< QVolatileImageData > d

◆ bytesPerLine()

int QVolatileImage::bytesPerLine ( ) const

Definition at line 131 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::ensureReadback(), and QVGPixmapData::toVGImage().

132 {
133  return d->image.bytesPerLine();
134 }
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
QSharedDataPointer< QVolatileImageData > d

◆ constBits()

const uchar * QVolatileImage::constBits ( ) const

Definition at line 170 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::toVGImage().

171 {
172  return d->image.constBits();
173 }
QSharedDataPointer< QVolatileImageData > d
const uchar * constBits() const
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1985

◆ constImageRef()

const QImage & QVolatileImage::constImageRef ( ) const

Non-detaching version, for read-only access only.

Must be guarded by begin/endDataAccess().

Definition at line 207 of file qvolatileimage.cpp.

Referenced by QVolatileImagePaintEngine::drawPixmap().

208 {
209  const_cast<QVolatileImageData *>(d.data())->ensureImage();
210  return d->image;
211 }
T * data()
Returns a pointer to the shared data object.
Definition: qshareddata.h:82
QSharedDataPointer< QVolatileImageData > d

◆ copyFrom()

void QVolatileImage::copyFrom ( QVolatileImage source,
const QRect rect 
)

Definition at line 235 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::copy().

236 {
237  if (source->isNull()) {
238  return;
239  }
240  QRect r = rect;
241  if (rect.isNull()) {
242  r = QRect(0, 0, source->width(), source->height());
243  }
244  source->beginDataAccess();
245  QImage &srcImgRef(source->imageRef());
246  int srcbpl = srcImgRef.bytesPerLine();
247  int srcbpp = srcImgRef.depth() / 8;
248  const uchar *sptr = srcImgRef.constBits() + r.y() * srcbpl;
249  beginDataAccess();
250  QImage &dstImgRef(imageRef());
251  if (!dstImgRef.isNull()) {
252  int dstbpl = dstImgRef.bytesPerLine();
253  uchar *dptr = dstImgRef.bits();
254  for (int y = 0; y < r.height(); ++y) {
255  qMemCopy(dptr, sptr + r.x() * srcbpp, r.width() * srcbpp);
256  sptr += srcbpl;
257  dptr += dstbpl;
258  }
259  }
260  endDataAccess();
261  source->endDataAccess(true);
262 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
void beginDataAccess() const
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void endDataAccess(bool readOnly=false) const
bool isNull() const
unsigned char uchar
Definition: qglobal.h:994
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void * qMemCopy(void *dest, const void *src, size_t n)
Definition: qglobal.cpp:2508
int width() const
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
int height() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QImage & imageRef()
Returns a reference to the image that is potentially using some native buffer internally.

◆ depth()

int QVolatileImage::depth ( ) const

Definition at line 141 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::fill().

142 {
143  return d->image.depth();
144 }
QSharedDataPointer< QVolatileImageData > d
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620

◆ duplicateNativeImage()

void * QVolatileImage::duplicateNativeImage ( ) const

Definition at line 213 of file qvolatileimage.cpp.

214 {
215  return d->duplicateNativeImage();
216 }
QSharedDataPointer< QVolatileImageData > d
void * duplicateNativeImage() const

◆ endDataAccess()

void QVolatileImage::endDataAccess ( bool  readOnly = false) const

Definition at line 156 of file qvolatileimage.cpp.

Referenced by copyFrom(), QVolatileImagePaintEngine::drawPixmap(), QVGPaintEngine::drawPixmap(), QVGPixmapData::ensureReadback(), fill(), setAlphaChannel(), and QVGPixmapData::toVGImage().

157 {
158  d->endDataAccess(readOnly);
159 }
void endDataAccess(bool readOnly=false) const
QSharedDataPointer< QVolatileImageData > d

◆ ensureFormat()

bool QVolatileImage::ensureFormat ( QImage::Format  format)

Definition at line 175 of file qvolatileimage.cpp.

Referenced by setAlphaChannel().

176 {
177  return d->ensureFormat(format);
178 }
bool ensureFormat(QImage::Format format)
QSharedDataPointer< QVolatileImageData > d

◆ fill()

void QVolatileImage::fill ( uint  pixelValue)

Definition at line 227 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::fill().

228 {
229  beginDataAccess();
230  imageRef().fill(pixelValue);
231  endDataAccess();
232  d->ensureImage();
233 }
void beginDataAccess() const
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
void endDataAccess(bool readOnly=false) const
QSharedDataPointer< QVolatileImageData > d
QImage & imageRef()
Returns a reference to the image that is potentially using some native buffer internally.

◆ format()

QImage::Format QVolatileImage::format ( ) const

Definition at line 116 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::copy(), QVGPixmapData::ensureReadback(), and QVGPixmapData::toVGImage().

117 {
118  return d->image.format();
119 }
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
QSharedDataPointer< QVolatileImageData > d

◆ hasAlphaChannel()

bool QVolatileImage::hasAlphaChannel ( ) const

Definition at line 146 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::hasAlphaChannel().

147 {
148  return d->image.hasAlphaChannel();
149 }
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
Definition: qimage.cpp:6495
QSharedDataPointer< QVolatileImageData > d

◆ height()

int QVolatileImage::height ( ) const

Definition at line 126 of file qvolatileimage.cpp.

Referenced by copyFrom().

127 {
128  return d->image.height();
129 }
QSharedDataPointer< QVolatileImageData > d
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572

◆ imageRef()

QImage & QVolatileImage::imageRef ( )

Returns a reference to the image that is potentially using some native buffer internally.

Access to the image's pixel data should be guarded by begin/endDataAccess(). Use it when there is a need for QImage APIs not provided by this class. The returned QImage must never be shared or assigned to.

Definition at line 197 of file qvolatileimage.cpp.

Referenced by copyFrom(), QVGPaintEngine::drawPixmap(), fill(), QVGPixmapData::fill(), paintEngine(), and setAlphaChannel().

198 {
199  d->ensureImage();
200  return d->image;
201 }
QSharedDataPointer< QVolatileImageData > d

◆ isNull()

bool QVolatileImage::isNull ( ) const

Definition at line 111 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::copy(), copyFrom(), QVolatileImagePaintEngine::drawPixmap(), QVGPixmapData::ensureReadback(), QVGPixmapData::forceToImage(), QVGPixmapData::hasAlphaChannel(), QVGPixmapData::hibernate(), QVGPixmapData::toImage(), and QVGPixmapData::toVGImage().

112 {
113  return d->image.isNull();
114 }
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
QSharedDataPointer< QVolatileImageData > d

◆ operator=()

QVolatileImage & QVolatileImage::operator= ( const QVolatileImage rhs)

Definition at line 100 of file qvolatileimage.cpp.

101 {
102  d = rhs.d;
103  return *this;
104 }
QSharedDataPointer< QVolatileImageData > d

◆ paintEngine()

QPaintEngine * QVolatileImage::paintEngine ( )

To be called from the PixmapData's paintEngine().

Definition at line 267 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::paintEngine().

268 {
269  if (!d->pengine) {
270  d->pengine = new QVolatileImagePaintEngine(&imageRef(), this);
271  }
272  return d->pengine;
273 }
QSharedDataPointer< QVolatileImageData > d
QImage & imageRef()
Returns a reference to the image that is potentially using some native buffer internally.

◆ paintingActive()

bool QVolatileImage::paintingActive ( ) const

Definition at line 106 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::toVGImage().

107 {
108  return d->pengine && d->pengine->isActive();
109 }
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
QSharedDataPointer< QVolatileImageData > d

◆ setAlphaChannel()

void QVolatileImage::setAlphaChannel ( const QPixmap alphaChannel)

Definition at line 218 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::setAlphaChannel().

219 {
221  beginDataAccess();
222  imageRef().setAlphaChannel(alphaChannel.toImage());
223  endDataAccess();
224  d->ensureImage();
225 }
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
void beginDataAccess() const
bool ensureFormat(QImage::Format format)
void endDataAccess(bool readOnly=false) const
QSharedDataPointer< QVolatileImageData > d
void setAlphaChannel(const QImage &alphaChannel)
Sets the alpha channel of this image to the given alphaChannel.
Definition: qimage.cpp:6329
QImage & imageRef()
Returns a reference to the image that is potentially using some native buffer internally.

◆ toImage()

QImage QVolatileImage::toImage ( ) const

This will always perform a copy of the pixel data.

Definition at line 183 of file qvolatileimage.cpp.

Referenced by QVGPixmapData::toImage().

184 {
185  d->beginDataAccess();
186  QImage newImage = d->image.copy(); // no sharing allowed
187  d->endDataAccess(true);
188  return newImage;
189 }
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
void beginDataAccess() const
void endDataAccess(bool readOnly=false) const
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QSharedDataPointer< QVolatileImageData > d

◆ width()

int QVolatileImage::width ( ) const

Definition at line 121 of file qvolatileimage.cpp.

Referenced by copyFrom().

122 {
123  return d->image.width();
124 }
QSharedDataPointer< QVolatileImageData > d
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557

Properties

◆ d

QSharedDataPointer<QVolatileImageData> QVolatileImage::d
private

The documentation for this class was generated from the following files: