Qt 4.8
Functions | Variables
qpixmapdata.cpp File Reference
#include "qpixmapdata_p.h"
#include <QtCore/qbuffer.h>
#include <QtGui/qbitmap.h>
#include <QtGui/qimagereader.h>
#include <private/qgraphicssystem_p.h>
#include <private/qapplication_p.h>
#include <private/qimagepixmapcleanuphooks_p.h>

Go to the source code of this file.

Functions

static QImage makeBitmapCompliantIfNeeded (QPixmapData *d, const QImage &image, Qt::ImageConversionFlags flags)
 

Variables

const uchar qt_pixmap_bit_mask []
 

Function Documentation

◆ makeBitmapCompliantIfNeeded()

static QImage makeBitmapCompliantIfNeeded ( QPixmapData d,
const QImage image,
Qt::ImageConversionFlags  flags 
)
static

Definition at line 107 of file qpixmapdata.cpp.

Referenced by QPixmapData::fromData(), and QPixmapData::fromFile().

108 {
109  if (d->pixelType() == QPixmapData::BitmapType) {
110  QImage img = image.convertToFormat(QImage::Format_MonoLSB, flags);
111 
112  // make sure image.color(0) == Qt::color0 (white)
113  // and image.color(1) == Qt::color1 (black)
114  const QRgb c0 = QColor(Qt::black).rgb();
115  const QRgb c1 = QColor(Qt::white).rgb();
116  if (img.color(0) == c0 && img.color(1) == c1) {
117  img.invertPixels();
118  img.setColor(0, c1);
119  img.setColor(1, c0);
120  }
121  return img;
122  }
123 
124  return image;
125 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
unsigned int QRgb
Definition: qrgb.h:53
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
Definition: qimage.cpp:1850
PixelType pixelType() const
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
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
void invertPixels(InvertMode=InvertRgb)
Inverts all pixel values in the image.
Definition: qimage.cpp:2179
QRgb color(int i) const
Returns the color in the color table at index i.
Definition: qimage.cpp:1829
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051

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 52 of file qpixmapdata.cpp.

Referenced by QPixmapData::mask(), and QPixmapData::setMask().