Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qimage.cpp File Reference

(d591fab309dd6cf6036a49a06e77842add9f9e19)

#include "qimage.h"
#include "qbuffer.h"
#include "qdatastream.h"
#include "qcolortransform.h"
#include "qfloat16.h"
#include "qmap.h"
#include "qtransform.h"
#include "qimagereader.h"
#include "qimagewriter.h"
#include "qrgbafloat.h"
#include "qstringlist.h"
#include "qvariant.h"
#include "qimagepixmapcleanuphooks_p.h"
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
#include <qpa/qplatformpixmap.h>
#include <private/qcolorspace_p.h>
#include <private/qcolortransform_p.h>
#include <private/qmemrotate_p.h>
#include <private/qimagescale_p.h>
#include <private/qpixellayout_p.h>
#include <private/qsimd_p.h>
#include <qhash.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qimage_p.h>
#include <private/qfont_p.h>
#include <qtgui_tracepoints_p.h>
#include <memory>
#include "moc_qimage.cpp"
+ Include dependency graph for qimage.cpp:

Go to the source code of this file.

Macros

#define QIMAGE_SANITYCHECK_MEMORY(image)
 
#define PIX(x, y)   (*((const QRgb*)scanLine(y)+x) & 0x00ffffff)
 
#define IWX_MSB(b)
 
#define IWX_LSB(b)
 
#define IWX_PIX(b)
 

Functions

 Q_TRACE_PREFIX (qtgui, "#include <qimagereader.h>")
 
 Q_TRACE_METADATA (qtgui, "ENUM { } QImage::Format;" "FLAGS { } Qt::ImageConversionFlags;")
 
 Q_TRACE_PARAM_REPLACE (Qt::AspectRatioMode, int)
 
 Q_TRACE_PARAM_REPLACE (Qt::TransformationMode, int)
 
static QImage rotated90 (const QImage &src)
 
static QImage rotated180 (const QImage &src)
 
static QImage rotated270 (const QImage &src)
 
static int next_qimage_serial_number ()
 
bool qt_read_xpm_image_or_array (QIODevice *device, const char *const *source, QImage &image)
 
static void copyPhysicalMetadata (QImageData *dst, const QImageData *src)
 
static void copyMetadata (QImageData *dst, const QImageData *src)
 
static void copyMetadata (QImage *dst, const QImage &src)
 
static int pixel_distance (QRgb p1, QRgb p2)
 
static int closestMatch (QRgb pixel, const QList< QRgb > &clut)
 
static QImage convertWithPalette (const QImage &src, QImage::Format format, const QList< QRgb > &clut)
 
void do_flip (QImageData *dst, QImageData *src, int w, int h, int depth)
 
void do_mirror (QImageData *dst, QImageData *src, bool horizontal, bool vertical)
 
static void rgbSwapped_generic (int width, int height, const QImage *src, QImage *dst, const QPixelLayout *layout)
 
QDataStreamoperator<< (QDataStream &s, const QImage &image)
 [0]
 
QDataStreamoperator>> (QDataStream &s, QImage &image)
 
bool qt_xForm_helper (const QTransform &trueMat, int xoffset, int type, int depth, uchar *dptr, qsizetype dbpl, int p_inc, int dHeight, const uchar *sptr, qsizetype sbpl, int sWidth, int sHeight)
 
static bool isRgb32Data (QImage::Format f)
 
static bool isRgb64Data (QImage::Format f)
 
static bool isRgb32fpx4Data (QImage::Format f)
 
QDebug operator<< (QDebug dbg, const QImage &i)
 
Q_GUI_EXPORT void qt_imageTransform (QImage &src, QImageIOHandler::Transformations orient)
 
QMap< QString, QStringqt_getImageText (const QImage &image, const QString &description)
 
QMap< QString, QStringqt_getImageTextFromDescription (const QString &description)
 

Variables

QImage Q_TRACE_INSTRUMENT (qtgui) QImage
 
static constexpr QPixelFormat pixelformats []
 

Macro Definition Documentation

◆ IWX_LSB

#define IWX_LSB ( b)
Value:
if (trigx < maxws && trigy < maxhs) { \
if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \
(1 << ((trigx>>12)&7))) \
*dptr |= b; \
} \
trigx += m11; \
trigy += m12;
GLboolean GLboolean GLboolean b

Definition at line 4368 of file qimage.cpp.

Referenced by qt_xForm_helper().

◆ IWX_MSB

#define IWX_MSB ( b)
Value:
if (trigx < maxws && trigy < maxhs) { \
if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \
(1 << (7-((trigx>>12)&7)))) \
*dptr |= b; \
} \
trigx += m11; \
trigy += m12;

Definition at line 4359 of file qimage.cpp.

Referenced by qt_xForm_helper().

◆ IWX_PIX

#define IWX_PIX ( b)
Value:
if (trigx < maxws && trigy < maxhs) { \
if ((*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \
(1 << (7-((trigx>>12)&7)))) == 0) \
*dptr &= ~b; \
} \
trigx += m11; \
trigy += m12;

Definition at line 4377 of file qimage.cpp.

◆ PIX

#define PIX ( x,
y )   (*((const QRgb*)scanLine(y)+x) & 0x00ffffff)

◆ QIMAGE_SANITYCHECK_MEMORY

#define QIMAGE_SANITYCHECK_MEMORY ( image)
Value:
if ((image).isNull()) { \
qWarning("QImage: out of memory, returning null image"); \
return QImage(); \
}
\inmodule QtGui
Definition qimage.h:37
Definition image.cpp:4

Definition at line 63 of file qimage.cpp.

Referenced by QImage::convertToFormat_helper(), and QImage::mirrored_helper().

Function Documentation

◆ closestMatch()

static int closestMatch ( QRgb pixel,
const QList< QRgb > & clut )
inlinestatic

Definition at line 2260 of file qimage.cpp.

References dist(), i, and pixel_distance().

Referenced by convertWithPalette(), QIconLoaderEngine::entryForSize(), and QNetworkAuthenticationCache::insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convertWithPalette()

static QImage convertWithPalette ( const QImage & src,
QImage::Format format,
const QList< QRgb > & clut )
static

Definition at line 2273 of file qimage.cpp.

References cache, closestMatch(), copyMetadata(), QImage::Format_Indexed8, QImageData::get(), QRgb, QImage::scanLine(), QImage::setColorTable(), and QImage::setPixel().

Referenced by QImage::convertToFormat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyMetadata() [1/2]

static void copyMetadata ( QImage * dst,
const QImage & src )
static

Definition at line 1181 of file qimage.cpp.

◆ copyMetadata() [2/2]

static void copyMetadata ( QImageData * dst,
const QImageData * src )
static

Definition at line 1172 of file qimage.cpp.

References copyPhysicalMetadata().

Referenced by QImage::colorTransformed(), QImage::convertToFormat_helper(), convertWithPalette(), QImage::mirrored_helper(), rotated180(), rotated270(), rotated90(), and QImage::smoothScaled().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyPhysicalMetadata()

static void copyPhysicalMetadata ( QImageData * dst,
const QImageData * src )
static

Definition at line 1165 of file qimage.cpp.

Referenced by copyMetadata().

+ Here is the caller graph for this function:

◆ do_flip()

void do_flip ( QImageData * dst,
QImageData * src,
int w,
int h,
int depth )
inline

Definition at line 3354 of file qimage.cpp.

References d.

Referenced by do_mirror().

+ Here is the caller graph for this function:

◆ do_mirror()

void do_mirror ( QImageData * dst,
QImageData * src,
bool horizontal,
bool vertical )
inline

Definition at line 3385 of file qimage.cpp.

References begin(), bitflip, do_flip(), QImage::Format_Mono, QImage::Format_MonoLSB, i, Q_ASSERT, qt_get_bitflip_array(), and shift().

Referenced by QImage::mirrored_helper(), and QImage::mirrored_inplace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRgb32Data()

static bool isRgb32Data ( QImage::Format f)
static

Definition at line 5360 of file qimage.cpp.

References QImage::Format_ARGB32, QImage::Format_ARGB32_Premultiplied, and QImage::Format_RGB32.

Referenced by QImage::colorTransformed().

+ Here is the caller graph for this function:

◆ isRgb32fpx4Data()

static bool isRgb32fpx4Data ( QImage::Format f)
static

Definition at line 5386 of file qimage.cpp.

References QImage::Format_RGBA32FPx4, QImage::Format_RGBA32FPx4_Premultiplied, and QImage::Format_RGBX32FPx4.

Referenced by QImage::colorTransformed().

+ Here is the caller graph for this function:

◆ isRgb64Data()

static bool isRgb64Data ( QImage::Format f)
static

Definition at line 5373 of file qimage.cpp.

References QImage::Format_RGBA64, QImage::Format_RGBA64_Premultiplied, and QImage::Format_RGBX64.

Referenced by QImage::colorTransformed().

+ Here is the caller graph for this function:

◆ next_qimage_serial_number()

static int next_qimage_serial_number ( )
static

Definition at line 85 of file qimage.cpp.

References Q_BASIC_ATOMIC_INITIALIZER.

◆ operator<<() [1/2]

QDataStream & operator<< ( QDataStream & stream,
const QImage & image )
related

[0]

[1]

Definition at line 3947 of file qimage.cpp.

References QImageWriter::write().

+ Here is the call graph for this function:

◆ operator<<() [2/2]

QDebug operator<< ( QDebug dbg,
const QImage & i )

Definition at line 5880 of file qimage.cpp.

References i, QByteArray(), and qMin().

+ Here is the call graph for this function:

◆ operator>>()

QDataStream & operator>> ( QDataStream & s,
QImage & image )
related

Definition at line 3973 of file qimage.cpp.

References read().

+ Here is the call graph for this function:

◆ pixel_distance()

static int pixel_distance ( QRgb p1,
QRgb p2 )
inlinestatic

Definition at line 2246 of file qimage.cpp.

References a1, a2, p1, p2, qAlpha(), qBlue(), qGreen(), qRed(), r1, and r2.

Referenced by closestMatch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Q_TRACE_METADATA()

Q_TRACE_METADATA ( qtgui ,
"ENUM { } QImage::Format;" "FLAGS { } Qt::ImageConversionFlags;"  )

◆ Q_TRACE_PARAM_REPLACE() [1/2]

Q_TRACE_PARAM_REPLACE ( Qt::AspectRatioMode ,
int  )

◆ Q_TRACE_PARAM_REPLACE() [2/2]

Q_TRACE_PARAM_REPLACE ( Qt::TransformationMode ,
int  )

◆ Q_TRACE_PREFIX()

Q_TRACE_PREFIX ( qtgui ,
"#include <qimagereader.h>"  )

◆ qt_getImageText()

QMap< QString, QString > qt_getImageText ( const QImage & image,
const QString & description )

Definition at line 6424 of file qimage.cpp.

References QString::contains(), QString::insert(), qt_getImageTextFromDescription(), and text.

Referenced by set_text(), and set_text().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_getImageTextFromDescription()

QMap< QString, QString > qt_getImageTextFromDescription ( const QString & description)

Definition at line 6435 of file qimage.cpp.

References QString::indexOf(), QString::insert(), QString::left(), text, and QString::tokenize().

Referenced by QImageReaderPrivate::getText(), and qt_getImageText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_imageTransform()

Q_GUI_EXPORT void qt_imageTransform ( QImage & src,
QImageIOHandler::Transformations orient )

Definition at line 6410 of file qimage.cpp.

References rotated270(), rotated90(), QImageIOHandler::TransformationFlip, QImageIOHandler::TransformationMirror, QImageIOHandler::TransformationNone, QImageIOHandler::TransformationRotate270, and QImageIOHandler::TransformationRotate90.

Referenced by QImageReader::read(), QImageWriter::write(), and QJpegHandler::write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_read_xpm_image_or_array()

bool qt_read_xpm_image_or_array ( QIODevice * device,
const char *const * source,
QImage & image )
extern

Definition at line 997 of file qxpmhandler.cpp.

References cpp, device, matcher, qMakeStaticByteArrayMatcher(), read_xpm_body(), read_xpm_header(), and state.

Referenced by QImage::QImage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_xForm_helper()

bool qt_xForm_helper ( const QTransform & trueMat,
int xoffset,
int type,
int depth,
uchar * dptr,
qsizetype dbpl,
int p_inc,
int dHeight,
const uchar * sptr,
qsizetype sbpl,
int sWidth,
int sHeight )

Definition at line 4385 of file qimage.cpp.

References IWX_LSB, IWX_MSB, p2, qRound(), QT_XFORM_TYPE_LSBFIRST, and QT_XFORM_TYPE_MSBFIRST.

Referenced by QX11PlatformPixmap::transformed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rgbSwapped_generic()

static void rgbSwapped_generic ( int width,
int height,
const QImage * src,
QImage * dst,
const QPixelLayout * layout )
inlinestatic

Definition at line 3545 of file qimage.cpp.

References i, layout, and qWarning.

◆ rotated180()

static QImage rotated180 ( const QImage & src)
static

Definition at line 4734 of file qimage.cpp.

References QPixelLayout::bpp, copyMetadata(), out, qMemRotateFunctions, and qPixelLayouts.

+ Here is the call graph for this function:

◆ rotated270()

static QImage rotated270 ( const QImage & src)
static

Definition at line 4752 of file qimage.cpp.

References QPixelLayout::bpp, copyMetadata(), out, qMemRotateFunctions, and qPixelLayouts.

Referenced by qt_imageTransform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rotated90()

static QImage rotated90 ( const QImage & src)
static

Definition at line 4708 of file qimage.cpp.

References QPixelLayout::bpp, copyMetadata(), out, qMemRotateFunctions, and qPixelLayouts.

Referenced by qt_imageTransform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ pixelformats

constexpr QPixelFormat pixelformats[]
staticconstexpr

Definition at line 5907 of file qimage.cpp.

Referenced by QImage::toImageFormat(), and QImage::toPixelFormat().

◆ Q_TRACE_INSTRUMENT

void Q_TRACE_INSTRUMENT ( qtgui )

Definition at line 3565 of file qimage.cpp.