Qt 4.8
Functions | Variables
qpixmap_raster.cpp File Reference
#include "qpixmap.h"
#include <private/qfont_p.h>
#include "qpixmap_raster_p.h"
#include "qnativeimage_p.h"
#include "qimage_p.h"
#include "qpaintengine.h"
#include "qbitmap.h"
#include "qimage.h"
#include <QBuffer>
#include <QImageReader>
#include <private/qimage_p.h>
#include <private/qsimd_p.h>
#include <private/qwidget_p.h>
#include <private/qdrawhelper_p.h>

Go to the source code of this file.

Functions

void qt_scrollRectInImage (QImage &img, const QRect &rect, const QPoint &offset)
 
QPixmap qt_toRasterPixmap (const QImage &image)
 
QPixmap qt_toRasterPixmap (const QPixmap &pixmap)
 

Variables

const uchar qt_pixmap_bit_mask []
 

Function Documentation

◆ qt_scrollRectInImage()

void qt_scrollRectInImage ( QImage img,
const QRect rect,
const QPoint offset 
)

Definition at line 345 of file qwindowsurface.cpp.

Referenced by QRasterPixmapData::fromImageReader(), and QRasterPixmapData::scroll().

346 {
347  // make sure we don't detach
348  uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
349 
350  int lineskip = img.bytesPerLine();
351  int depth = img.depth() >> 3;
352 
353  const QRect imageRect(0, 0, img.width(), img.height());
354  const QRect r = rect & imageRect & imageRect.translated(-offset);
355  const QPoint p = rect.topLeft() + offset;
356 
357  if (r.isEmpty())
358  return;
359 
360  const uchar *src;
361  uchar *dest;
362 
363  if (r.top() < p.y()) {
364  src = mem + r.bottom() * lineskip + r.left() * depth;
365  dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
366  lineskip = -lineskip;
367  } else {
368  src = mem + r.top() * lineskip + r.left() * depth;
369  dest = mem + p.y() * lineskip + p.x() * depth;
370  }
371 
372  const int w = r.width();
373  int h = r.height();
374  const int bytes = w * depth;
375 
376  // overlapping segments?
377  if (offset.y() == 0 && qAbs(offset.x()) < w) {
378  do {
379  ::memmove(dest, src, bytes);
380  dest += lineskip;
381  src += lineskip;
382  } while (--h);
383  } else {
384  do {
385  ::memcpy(dest, src, bytes);
386  dest += lineskip;
387  src += lineskip;
388  } while (--h);
389  }
390 }
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
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
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ qt_toRasterPixmap() [1/2]

QPixmap qt_toRasterPixmap ( const QImage image)

Definition at line 65 of file qpixmap_raster.cpp.

Referenced by qt_toRasterPixmap().

66 {
67  QPixmapData *data =
68  new QRasterPixmapData(image.depth() == 1
71 
72  data->fromImage(image, Qt::AutoColor);
73 
74  return QPixmap(data);
75 }
virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags)=0
static const char * data(const QByteArray &arr)
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ qt_toRasterPixmap() [2/2]

QPixmap qt_toRasterPixmap ( const QPixmap pixmap)

Definition at line 77 of file qpixmap_raster.cpp.

78 {
79  if (pixmap.isNull())
80  return QPixmap();
81 
83  return pixmap;
84 
85  return qt_toRasterPixmap(pixmap.toImage());
86 }
QPixmap qt_toRasterPixmap(const QImage &image)
DataPtr & data_ptr()
Definition: qpixmap.h:297
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
ClassId classId() const
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615

Variable Documentation

◆ qt_pixmap_bit_mask

const uchar qt_pixmap_bit_mask[]
Initial value:
= { 0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80 }

Definition at line 62 of file qpixmap_raster.cpp.

Referenced by QRasterPixmapData::setMask().