Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qjpeghandler.cpp File Reference
#include "qjpeghandler_p.h"
#include <qbuffer.h>
#include <qcolorspace.h>
#include <qcolortransform.h>
#include <qdebug.h>
#include <qimage.h>
#include <qlist.h>
#include <qloggingcategory.h>
#include <qmath.h>
#include <qvariant.h>
#include <private/qicc_p.h>
#include <private/qsimd_p.h>
#include <private/qimage_p.h>
#include <stdio.h>
#include <setjmp.h>
#include <jpeglib.h>
+ Include dependency graph for qjpeghandler.cpp:

Go to the source code of this file.

Classes

struct  my_error_mgr
 
struct  my_jpeg_source_mgr
 
struct  my_jpeg_destination_mgr
 
class  QJpegHandlerPrivate
 

Macros

#define XMD_H
 
#define HIGH_QUALITY_THRESHOLD   50
 

Typedefs

typedef void(QT_FASTCALLRgb888ToRgb32Converter) (quint32 *dst, const uchar *src, int len)
 

Functions

QT_BEGIN_NAMESPACE Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32 (quint32 *dst, const uchar *src, int len)
 
static void my_error_exit (j_common_ptr cinfo)
 
static void my_output_message (j_common_ptr cinfo)
 
static void qt_init_source (j_decompress_ptr)
 
static boolean qt_fill_input_buffer (j_decompress_ptr cinfo)
 
static void qt_skip_input_data (j_decompress_ptr cinfo, long num_bytes)
 
static void qt_term_source (j_decompress_ptr cinfo)
 
static bool read_jpeg_size (int &w, int &h, j_decompress_ptr cinfo)
 
static bool read_jpeg_format (QImage::Format &format, j_decompress_ptr cinfo)
 
static bool ensureValidImage (QImage *dest, struct jpeg_decompress_struct *info, const QSize &size)
 
static bool read_jpeg_image (QImage *outImage, QSize scaledSize, QRect scaledClipRect, QRect clipRect, int quality, Rgb888ToRgb32Converter converter, j_decompress_ptr info, struct my_error_mgr *err)
 
static void qt_init_destination (j_compress_ptr)
 
static boolean qt_empty_output_buffer (j_compress_ptr cinfo)
 
static void qt_term_destination (j_compress_ptr cinfo)
 
static void set_text (const QImage &image, j_compress_ptr cinfo, const QString &description)
 
static void write_icc_profile (const QImage &image, j_compress_ptr cinfo)
 
static bool do_write_jpeg_image (struct jpeg_compress_struct &cinfo, JSAMPROW *row_pointer, const QImage &image, QIODevice *device, int sourceQuality, const QString &description, bool optimize, bool progressive)
 
static bool write_jpeg_image (const QImage &image, QIODevice *device, int sourceQuality, const QString &description, bool optimize, bool progressive)
 
static bool readExifHeader (QDataStream &stream)
 
static int getExifOrientation (QByteArray &exifData)
 
static QImageIOHandler::Transformations exif2Qt (int exifOrientation)
 
Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon (quint32 *dst, const uchar *src, int len)
 
Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3 (quint32 *dst, const uchar *src, int len)
 
void qt_convert_rgb888_to_rgb32_mips_dspr2_asm (quint32 *dst, const uchar *src, int len)
 
void qt_imageTransform (QImage &src, QImageIOHandler::Transformations orient)
 

Variables

static const int max_buf = 4096
 
static constexpr int maxMarkerSize = 65533
 

Macro Definition Documentation

◆ HIGH_QUALITY_THRESHOLD

#define HIGH_QUALITY_THRESHOLD   50

Definition at line 164 of file qjpeghandler.cpp.

◆ XMD_H

#define XMD_H

Definition at line 28 of file qjpeghandler.cpp.

Typedef Documentation

◆ Rgb888ToRgb32Converter

typedef void(QT_FASTCALL * Rgb888ToRgb32Converter) (quint32 *dst, const uchar *src, int len)

Definition at line 42 of file qjpeghandler.cpp.

Function Documentation

◆ do_write_jpeg_image()

static bool do_write_jpeg_image ( struct jpeg_compress_struct &  cinfo,
JSAMPROW *  row_pointer,
const QImage image,
QIODevice device,
int  sourceQuality,
const QString description,
bool  optimize,
bool  progressive 
)
static

Definition at line 489 of file qjpeghandler.cpp.

References QImage::constScanLine(), device, QImage::Format_Alpha8, QImage::Format_ARGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_Grayscale16, QImage::Format_Grayscale8, QImage::Format_Indexed8, QImage::Format_Invalid, QImage::Format_Mono, QImage::Format_MonoLSB, QImage::Format_RGB32, QImage::Format_RGB888, i, my_error_exit(), my_output_message(), pix, qAbs(), qBlue(), qGreen(), qIsGray(), qMin(), qRed(), QRgb, qRound(), rgb, set_text(), my_error_mgr::setjmp_buffer, and write_icc_profile().

Referenced by write_jpeg_image().

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

◆ ensureValidImage()

static bool ensureValidImage ( QImage dest,
struct jpeg_decompress_struct *  info,
const QSize size 
)
static

Definition at line 186 of file qjpeghandler.cpp.

References QImageIOHandler::allocateImage(), QImage::Format_Grayscale8, QImage::Format_RGB32, and info.

Referenced by read_jpeg_image().

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

◆ exif2Qt()

static QImageIOHandler::Transformations exif2Qt ( int  exifOrientation)
static

◆ getExifOrientation()

static int getExifOrientation ( QByteArray exifData)
static

Definition at line 783 of file qjpeghandler.cpp.

References QDataStream::BigEndian, QDataStream::LittleEndian, QDataStream::Ok, Q_ASSERT, readExifHeader(), QIODeviceBase::ReadOnly, QByteArray::size(), and tag.

Referenced by QJpegHandlerPrivate::readJpegHeader().

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

◆ my_error_exit()

static void my_error_exit ( j_common_ptr  cinfo)
static

Definition at line 50 of file qjpeghandler.cpp.

References my_error_mgr::setjmp_buffer.

Referenced by do_write_jpeg_image(), and QJpegHandlerPrivate::readJpegHeader().

+ Here is the caller graph for this function:

◆ my_output_message()

static void my_output_message ( j_common_ptr  cinfo)
static

Definition at line 57 of file qjpeghandler.cpp.

References qCWarning.

Referenced by do_write_jpeg_image(), read_jpeg_image(), and QJpegHandlerPrivate::readJpegHeader().

+ Here is the caller graph for this function:

◆ qt_convert_rgb888_to_rgb32()

QT_BEGIN_NAMESPACE Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32 ( quint32 dst,
const uchar src,
int  len 
)

Definition at line 679 of file qimage_conversions.cpp.

Referenced by convert_RGB888_to_RGB().

+ Here is the caller graph for this function:

◆ qt_convert_rgb888_to_rgb32_mips_dspr2_asm()

void qt_convert_rgb888_to_rgb32_mips_dspr2_asm ( quint32 dst,
const uchar src,
int  len 
)

◆ qt_convert_rgb888_to_rgb32_neon()

Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon ( quint32 dst,
const uchar src,
int  len 
)

Referenced by QJpegHandler::QJpegHandler().

+ Here is the caller graph for this function:

◆ qt_convert_rgb888_to_rgb32_ssse3()

Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3 ( quint32 dst,
const uchar src,
int  len 
)

Referenced by QJpegHandler::QJpegHandler().

+ Here is the caller graph for this function:

◆ qt_empty_output_buffer()

static boolean qt_empty_output_buffer ( j_compress_ptr  cinfo)
static

Definition at line 416 of file qjpeghandler.cpp.

References my_jpeg_destination_mgr::buffer, my_jpeg_destination_mgr::device, max_buf, and QIODevice::write().

Referenced by my_jpeg_destination_mgr::my_jpeg_destination_mgr().

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

◆ qt_fill_input_buffer()

static boolean qt_fill_input_buffer ( j_decompress_ptr  cinfo)
static

Definition at line 85 of file qjpeghandler.cpp.

References max_buf.

Referenced by my_jpeg_source_mgr::my_jpeg_source_mgr(), and qt_skip_input_data().

+ Here is the caller graph for this function:

◆ qt_imageTransform()

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

Definition at line 5739 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_init_destination()

static void qt_init_destination ( j_compress_ptr  )
static

Definition at line 412 of file qjpeghandler.cpp.

Referenced by my_jpeg_destination_mgr::my_jpeg_destination_mgr().

+ Here is the caller graph for this function:

◆ qt_init_source()

static void qt_init_source ( j_decompress_ptr  )
static

Definition at line 81 of file qjpeghandler.cpp.

Referenced by my_jpeg_source_mgr::my_jpeg_source_mgr().

+ Here is the caller graph for this function:

◆ qt_skip_input_data()

static void qt_skip_input_data ( j_decompress_ptr  cinfo,
long  num_bytes 
)
static

Definition at line 109 of file qjpeghandler.cpp.

References qt_fill_input_buffer(), and void.

Referenced by my_jpeg_source_mgr::my_jpeg_source_mgr().

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

◆ qt_term_destination()

static void qt_term_destination ( j_compress_ptr  cinfo)
static

Definition at line 430 of file qjpeghandler.cpp.

References my_jpeg_destination_mgr::buffer, my_jpeg_destination_mgr::device, max_buf, and QIODevice::write().

Referenced by my_jpeg_destination_mgr::my_jpeg_destination_mgr().

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

◆ qt_term_source()

static void qt_term_source ( j_decompress_ptr  cinfo)
static

Definition at line 132 of file qjpeghandler.cpp.

Referenced by my_jpeg_source_mgr::my_jpeg_source_mgr().

+ Here is the caller graph for this function:

◆ read_jpeg_format()

static bool read_jpeg_format ( QImage::Format format,
j_decompress_ptr  cinfo 
)
inlinestatic

Definition at line 166 of file qjpeghandler.cpp.

References QImage::Format_Grayscale8, and QImage::Format_RGB32.

Referenced by QJpegHandlerPrivate::readJpegHeader().

+ Here is the caller graph for this function:

◆ read_jpeg_image()

static bool read_jpeg_image ( QImage outImage,
QSize  scaledSize,
QRect  scaledClipRect,
QRect  clipRect,
int  quality,
Rgb888ToRgb32Converter  converter,
j_decompress_ptr  info,
struct my_error_mgr err 
)
static

Definition at line 205 of file qjpeghandler.cpp.

References QRect::bottom(), QImage::copy(), ensureValidImage(), Qt::FastTransformation, QRect::height(), QSize::height(), HIGH_QUALITY_THRESHOLD, i, Qt::IgnoreAspectRatio, info, QRect::intersected(), QRect::isEmpty(), QSize::isEmpty(), QImage::isNull(), QSize::isValid(), my_output_message(), out, qBound(), qCeil(), qMin(), QRgb, qRgb(), QRect::right(), QImage::scaled(), QImage::scanLine(), QImage::setDotsPerMeterX(), QImage::setDotsPerMeterY(), my_error_mgr::setjmp_buffer, QRect::size(), Qt::SmoothTransformation, QRect::topLeft(), QRect::translate(), void, QRect::width(), QSize::width(), QRect::x(), and QRect::y().

Referenced by QJpegHandlerPrivate::read().

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

◆ read_jpeg_size()

static bool read_jpeg_size ( int &  w,
int &  h,
j_decompress_ptr  cinfo 
)
inlinestatic

Definition at line 155 of file qjpeghandler.cpp.

References void.

Referenced by QJpegHandlerPrivate::readJpegHeader().

+ Here is the caller graph for this function:

◆ readExifHeader()

static bool readExifHeader ( QDataStream stream)
static

Definition at line 762 of file qjpeghandler.cpp.

Referenced by getExifOrientation().

+ Here is the caller graph for this function:

◆ set_text()

static void set_text ( const QImage image,
j_compress_ptr  cinfo,
const QString description 
)
inlinestatic

Definition at line 454 of file qjpeghandler.cpp.

References QString::begin(), QByteArray::constData(), QString::end(), QByteArray::isEmpty(), it, maxMarkerSize, qt_getImageText(), QByteArray::size(), text, and QByteArray::truncate().

Referenced by do_write_jpeg_image().

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

◆ write_icc_profile()

static void write_icc_profile ( const QImage image,
j_compress_ptr  cinfo 
)
inlinestatic

Definition at line 468 of file qjpeghandler.cpp.

References QByteArray::constData(), QByteArray::isEmpty(), maxMarkerSize, QByteArray::mid(), Q_ASSERT, qMin(), and QByteArray::size().

Referenced by do_write_jpeg_image().

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

◆ write_jpeg_image()

static bool write_jpeg_image ( const QImage image,
QIODevice device,
int  sourceQuality,
const QString description,
bool  optimize,
bool  progressive 
)
static

Definition at line 687 of file qjpeghandler.cpp.

References device, and do_write_jpeg_image().

Referenced by QJpegHandler::write().

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

Variable Documentation

◆ max_buf

◆ maxMarkerSize

constexpr int maxMarkerSize = 65533
staticconstexpr

Definition at line 452 of file qjpeghandler.cpp.

Referenced by set_text(), and write_icc_profile().