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

#include <qpaintengine_raster_p.h>

Public Functions

ucharbuffer () const
 
QImage bufferImage () const
 
int bytesPerLine () const
 
int bytesPerPixel () const
 
QImage colorizeBitmap (const QImage &image, const QColor &color)
 
void flushToARGBImage (QImage *image) const
 
int height () const
 
void init ()
 
QImage::Format prepare (QImage *image)
 
QImage::Format prepare (QPixmap *pix)
 
void prepare (QCustomRasterPaintDevice *device)
 
void prepare (int w, int h)
 
void prepareBuffer (int w, int h)
 
 QRasterBuffer ()
 
void resetBuffer (int val=0)
 
ucharscanLine (int y)
 
int width () const
 
 ~QRasterBuffer ()
 

Public Variables

QPainter::CompositionMode compositionMode
 
QRgb destColor0
 
QRgb destColor1
 
DrawHelperdrawHelper
 
QImage::Format format
 
bool monoDestinationWithClut
 

Properties

int bytes_per_line
 
int bytes_per_pixel
 
ucharm_buffer
 
int m_height
 
int m_width
 

Detailed Description

Definition at line 497 of file qpaintengine_raster_p.h.

Constructors and Destructors

◆ QRasterBuffer()

QRasterBuffer::QRasterBuffer ( )
inline

◆ ~QRasterBuffer()

QRasterBuffer::~QRasterBuffer ( )

Definition at line 3915 of file qpaintengine_raster.cpp.

3916 {
3917 }

Functions

◆ buffer()

uchar* QRasterBuffer::buffer ( ) const
inline

◆ bufferImage()

QImage QRasterBuffer::bufferImage ( ) const

Definition at line 4506 of file qpaintengine_raster.cpp.

4507 {
4509 
4510  for (int y = 0; y < m_height; ++y) {
4511  uint *span = (uint *)const_cast<QRasterBuffer *>(this)->scanLine(y);
4512 
4513  for (int x=0; x<m_width; ++x) {
4514  uint argb = span[x];
4515  image.setPixel(x, y, argb);
4516  }
4517  }
4518  return image;
4519 }
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996

◆ bytesPerLine()

int QRasterBuffer::bytesPerLine ( ) const
inline

◆ bytesPerPixel()

int QRasterBuffer::bytesPerPixel ( ) const
inline

Definition at line 531 of file qpaintengine_raster_p.h.

531 { return bytes_per_pixel; }

◆ colorizeBitmap()

QImage QRasterBuffer::colorizeBitmap ( const QImage image,
const QColor color 
)

Definition at line 3892 of file qpaintengine_raster.cpp.

Referenced by QRasterPaintEngine::drawPixmap(), and QRasterPaintEngine::drawTiledPixmap().

3893 {
3894  Q_ASSERT(image.depth() == 1);
3895 
3896  QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB);
3897  QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied);
3898 
3899  QRgb fg = PREMUL(color.rgba());
3900  QRgb bg = 0;
3901 
3902  int height = sourceImage.height();
3903  int width = sourceImage.width();
3904  for (int y=0; y<height; ++y) {
3905  uchar *source = sourceImage.scanLine(y);
3906  QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y));
3907  if (!source || !target)
3908  QT_THROW(std::bad_alloc()); // we must have run out of memory
3909  for (int x=0; x < width; ++x)
3910  target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg;
3911  }
3912  return dest;
3913 }
unsigned int QRgb
Definition: qrgb.h:53
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned char uchar
Definition: qglobal.h:994
#define QT_THROW(A)
Definition: qglobal.h:1538
Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x)
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
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886

◆ flushToARGBImage()

void QRasterBuffer::flushToARGBImage ( QImage image) const

Definition at line 4523 of file qpaintengine_raster.cpp.

4524 {
4525  int w = qMin(m_width, target->width());
4526  int h = qMin(m_height, target->height());
4527 
4528  for (int y=0; y<h; ++y) {
4529  uint *sourceLine = (uint *)const_cast<QRasterBuffer *>(this)->scanLine(y);
4530  QRgb *dest = (QRgb *) target->scanLine(y);
4531  for (int x=0; x<w; ++x) {
4532  QRgb pixel = sourceLine[x];
4533  int alpha = qAlpha(pixel);
4534  if (!alpha) {
4535  dest[x] = 0;
4536  } else {
4537  dest[x] = (alpha << 24)
4538  | ((255*qRed(pixel)/alpha) << 16)
4539  | ((255*qGreen(pixel)/alpha) << 8)
4540  | ((255*qBlue(pixel)/alpha) << 0);
4541  }
4542  }
4543  }
4544 }
unsigned int QRgb
Definition: qrgb.h:53
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
Definition: qrgb.h:66
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
unsigned int uint
Definition: qglobal.h:996
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60

◆ height()

int QRasterBuffer::height ( ) const
inline

◆ init()

void QRasterBuffer::init ( )

Definition at line 3919 of file qpaintengine_raster.cpp.

◆ prepare() [1/4]

QImage::Format QRasterBuffer::prepare ( QImage image)

Definition at line 3927 of file qpaintengine_raster.cpp.

Referenced by blendCursor(), QScreen::compose(), and QScreen::paintBackground().

3928 {
3929  m_buffer = (uchar *)image->bits();
3930  m_width = qMin(QT_RASTER_COORD_LIMIT, image->width());
3932  bytes_per_pixel = image->depth()/8;
3933  bytes_per_line = image->bytesPerLine();
3934 
3935  format = image->format();
3937  if (image->depth() == 1 && image->colorTable().size() == 2) {
3938  monoDestinationWithClut = true;
3939  destColor0 = PREMUL(image->colorTable()[0]);
3940  destColor1 = PREMUL(image->colorTable()[1]);
3941  }
3942 
3943  return format;
3944 }
QImage::Format format
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
unsigned char uchar
Definition: qglobal.h:994
const int QT_RASTER_COORD_LIMIT
Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x)
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
DrawHelper qDrawHelper[QImage::NImageFormats]
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
DrawHelper * drawHelper
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< QRgb > colorTable() const
Returns a list of the colors contained in the image&#39;s color table, or an empty list if the image does...
Definition: qimage.cpp:1770

◆ prepare() [2/4]

QImage::Format QRasterBuffer::prepare ( QPixmap pix)

◆ prepare() [3/4]

void QRasterBuffer::prepare ( QCustomRasterPaintDevice device)

Definition at line 3953 of file qpaintengine_raster.cpp.

3954 {
3955  m_buffer = reinterpret_cast<uchar*>(device->memory());
3956  m_width = qMin(QT_RASTER_COORD_LIMIT, device->width());
3957  m_height = qMin(QT_RASTER_COORD_LIMIT, device->height());
3958  bytes_per_pixel = device->depth() / 8;
3959  bytes_per_line = device->bytesPerLine();
3960  format = device->format();
3961 #ifndef QT_NO_RASTERCALLBACKS
3962  if (!m_buffer)
3964  else
3965 #endif
3967 }
QImage::Format format
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int height() const
Definition: qpaintdevice.h:92
virtual QImage::Format format() const
Returns the format of the device&#39;s memory buffet.
virtual int bytesPerLine() const
Returns the number of bytes per line in the framebuffer.
unsigned char uchar
Definition: qglobal.h:994
int width() const
Definition: qpaintdevice.h:91
const int QT_RASTER_COORD_LIMIT
DrawHelper qDrawHelper[QImage::NImageFormats]
DrawHelper qDrawHelperCallback[QImage::NImageFormats]
DrawHelper * drawHelper
virtual void * memory() const
Returns a pointer to the paint device&#39;s memory buffer, or 0 if no such buffer exists.
int depth() const
Definition: qpaintdevice.h:103

◆ prepare() [4/4]

void QRasterBuffer::prepare ( int  w,
int  h 
)

◆ prepareBuffer()

void QRasterBuffer::prepareBuffer ( int  w,
int  h 
)

◆ resetBuffer()

void QRasterBuffer::resetBuffer ( int  val = 0)

Definition at line 3946 of file qpaintengine_raster.cpp.

3947 {
3948  memset(m_buffer, val, m_height*bytes_per_line);
3949 }

◆ scanLine()

uchar* QRasterBuffer::scanLine ( int  y)
inline

◆ width()

int QRasterBuffer::width ( ) const
inline

Properties

◆ bytes_per_line

int QRasterBuffer::bytes_per_line
private

Definition at line 547 of file qpaintengine_raster_p.h.

◆ bytes_per_pixel

int QRasterBuffer::bytes_per_pixel
private

Definition at line 548 of file qpaintengine_raster_p.h.

◆ compositionMode

QPainter::CompositionMode QRasterBuffer::compositionMode

◆ destColor0

QRgb QRasterBuffer::destColor0

◆ destColor1

QRgb QRasterBuffer::destColor1

◆ drawHelper

DrawHelper* QRasterBuffer::drawHelper

Definition at line 541 of file qpaintengine_raster_p.h.

◆ format

QImage::Format QRasterBuffer::format

◆ m_buffer

uchar* QRasterBuffer::m_buffer
private

Definition at line 549 of file qpaintengine_raster_p.h.

◆ m_height

int QRasterBuffer::m_height
private

Definition at line 546 of file qpaintengine_raster_p.h.

◆ m_width

int QRasterBuffer::m_width
private

Definition at line 545 of file qpaintengine_raster_p.h.

◆ monoDestinationWithClut

bool QRasterBuffer::monoDestinationWithClut

Definition at line 535 of file qpaintengine_raster_p.h.

Referenced by destStoreMono(), and destStoreMonoLsb().


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