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
qjpeghandler.cpp File Reference

(7f72a93e874f5e52612983ad3b764f07216bf62e)

#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, bool invertCMYK)
 
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, bool invertCMYK)
 
static bool write_jpeg_image (const QImage &image, QIODevice *device, int sourceQuality, const QString &description, bool optimize, bool progressive, bool invertCMYK)
 
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
 
static const char SupportedJPEGSubtypes [][14]
 

Macro Definition Documentation

◆ HIGH_QUALITY_THRESHOLD

#define HIGH_QUALITY_THRESHOLD   50

Definition at line 164 of file qjpeghandler.cpp.

Referenced by read_jpeg_image().

◆ 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,
bool invertCMYK )
static

Definition at line 500 of file qjpeghandler.cpp.

References my_jpeg_destination_mgr::my_jpeg_destination_mgr(), device, QImage::Format_Alpha8, QImage::Format_ARGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_CMYK8888, 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(), 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 191 of file qjpeghandler.cpp.

References QImageIOHandler::allocateImage(), QImage::Format_CMYK8888, 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 834 of file qjpeghandler.cpp.

References QDataStream::BigEndian, QDataStream::LittleEndian, Q_ASSERT, readExifHeader(), QIODeviceBase::ReadOnly, 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.

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 678 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 427 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 )
extern

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_init_destination()

static void qt_init_destination ( j_compress_ptr )
static

Definition at line 423 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 441 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_CMYK8888, 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,
bool invertCMYK )
static

Definition at line 215 of file qjpeghandler.cpp.

References QRect::bottom(), ensureValidImage(), Qt::FastTransformation, QRect::height(), QSize::height(), HIGH_QUALITY_THRESHOLD, i, Qt::IgnoreAspectRatio, info, QRect::intersected(), QRect::isEmpty(), QSize::isEmpty(), QSize::isValid(), my_output_message(), out, qBound(), qCeil(), qMin(), QRgb, QRect::right(), 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 813 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 465 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 479 of file qjpeghandler.cpp.

References QByteArray::constData(), QByteArray::isEmpty(), maxMarkerSize, QByteArray::mid(), Q_ASSERT, QByteArray(), 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,
bool invertCMYK )
static

Definition at line 714 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 463 of file qjpeghandler.cpp.

Referenced by set_text(), and write_icc_profile().

◆ SupportedJPEGSubtypes

const char SupportedJPEGSubtypes[][14]
static
Initial value:
= {
"Automatic",
"Inverted_CMYK",
"CMYK"
}

Definition at line 805 of file qjpeghandler.cpp.

Referenced by QJpegHandler::option(), and QJpegHandler::setOption().