4#include <QGuiApplication>
6#include <QImageIOHandler>
28 if (!dev ||
count <= 0)
34 res = dev->
pos() - prevPos;
64 QImageIOPlugin::Capabilities
res;
68 CFIndex
len = CFArrayGetCount(cfSourceTypes);
69 if (CFArrayContainsValue(cfSourceTypes, CFRangeMake(0,
len), cfUti))
73 len = CFArrayGetCount(cfDestTypes);
74 if (CFArrayContainsValue(cfDestTypes, CFRangeMake(0,
len), cfUti))
83 return h.readImage(
out);
89 return h.writeImage(
in, uti);
108 const void *rawData =
b->data().constData() +
b->pos();
109 cgDataProvider = CGDataProviderCreateWithData(
nullptr, rawData,
size_t(
b->data().size() -
b->pos()),
nullptr);
137 out->setDotsPerMeterX(
qRound(dpi / 0.0254f));
139 out->setDotsPerMeterY(
qRound(dpi / 0.0254f));
149 CFNumberRef cfNumber =
static_cast<CFNumberRef
>(CFDictionaryGetValue(
cfImageDict,
property));
152 if (CFNumberGetValue(cfNumber, kCFNumberIntType, &intVal)) {
161static QImageIOHandler::Transformations
exif2Qt(
int exifOrientation)
163 switch (exifOrientation) {
184static int qt2Exif(QImageIOHandler::Transformations transformation)
186 switch (transformation) {
204 qWarning(
"Invalid Qt image transformation");
244 static const CGDataConsumerCallbacks cgCallbacks = { &
cbPutBytes,
nullptr };
253 if (!cgImageDest || !cgImage)
258 const void *dictKeys[2];
259 const void *dictVals[2];
266 float quality = (
ok && writeQuality >= 0 ? (
qMin(writeQuality, 100)) : 75) / 100.0f;
267 cfQuality = CFNumberCreate(
nullptr, kCFNumberFloatType, &quality);
268 dictKeys[dictSize] =
static_cast<const void *
>(kCGImageDestinationLossyCompressionQuality);
269 dictVals[dictSize] =
static_cast<const void *
>(cfQuality);
274 cfOrientation = CFNumberCreate(
nullptr, kCFNumberIntType, &orient);
275 dictKeys[dictSize] =
static_cast<const void *
>(kCGImagePropertyOrientation);
276 dictVals[dictSize] =
static_cast<const void *
>(cfOrientation);
282 cfProps = CFDictionaryCreate(
nullptr, dictKeys, dictVals, dictSize,
283 &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
285 CGImageDestinationAddImage(cgImageDest, cgImage, cfProps);
286 return CGImageDestinationFinalize(cgImageDest);
\inmodule QtCore \reentrant
QList< QVariant > writeOptions
bool getIntProperty(CFStringRef property, int *value)
QCFType< CGImageSourceRef > cgImageSource
bool writeImage(const QImage &in, const QString &uti)
QVariant imageProperty(QImageIOHandler::ImageOption option)
QCFType< CGDataProviderRef > cgDataProvider
void setOption(QImageIOHandler::ImageOption option, const QVariant &value)
QIIOFHelper(QImageIOHandler *q)
QCFType< CFDictionaryRef > cfImageDict
bool readImage(QImage *out)
static bool readImage(QImageIOHandler *q_ptr, QImage *out)
static bool writeImage(QImageIOHandler *q_ptr, const QImage &in, const QString &uti)
static QImageIOPlugin::Capabilities systemCapabilities(const QString &uti)
\inmodule QtCore \reentrant
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
The QImageIOHandler class defines the common image I/O interface for all image formats in Qt.
ImageOption
This enum describes the different options supported by QImageIOHandler.
virtual bool supportsOption(ImageOption option) const
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
@ TransformationRotate270
@ TransformationFlipAndRotate90
@ TransformationMirrorAndRotate90
@ TransformationRotate180
qsizetype size() const noexcept
T value(qsizetype i) const
void resize(qsizetype size)
constexpr int & rheight() noexcept
Returns a reference to the height.
constexpr int & rwidth() noexcept
Returns a reference to the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
Combined button and popup list for selecting options.
QImage qt_mac_toQImage(CGImageRef image)
CGImageRef qt_mac_toCGImage(const QImage &inImage)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
static off_t cbSkipForward(void *info, off_t count)
static void cbRewind(void *)
QImage qt_mac_toQImage(CGImageRef image)
CGImageRef qt_mac_toCGImage(const QImage &qImage)
static QT_BEGIN_NAMESPACE size_t cbGetBytes(void *info, void *buffer, size_t count)
static size_t cbPutBytes(void *info, const void *buffer, size_t count)
static int qt2Exif(QImageIOHandler::Transformations transformation)
static QImageIOHandler::Transformations exif2Qt(int exifOrientation)
static QImageIOHandler::Transformations exif2Qt(int exifOrientation)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLenum GLenum GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
unsigned long long quint64
QFileInfo info(fileName)
[8]
QTextStream out(stdout)
[7]