supports this option is expected to set the image quality level
depending on the value of this option (an int) when writing.
- \value SubType The subtype of the image. A handler that supports
- this option can use the subtype value to help when reading and
- writing images. For example, a PPM handler may have a subtype
- value of "ppm" or "ppmraw".
-
\value Animation Image formats that support animation return
true for this value in supportsOption(); otherwise, false is returned.
CompressionLevel,
Gamma,
Quality,
- SubType,
Animation,
BackgroundColor
};
#ifndef QT_NO_IMAGEFORMAT_PPM
} else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
handler = new QPpmHandler();
- handler->setOption(QImageIOHandler::SubType, form);
#endif
}
QByteArray subType;
if (!handler && QPpmHandler::canRead(device, &subType)) {
handler = new QPpmHandler();
- handler->setOption(QImageIOHandler::SubType, subType);
}
#endif
}
#ifndef QT_NO_IMAGEFORMAT_PPM
} else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
handler = new QPpmHandler();
- handler->setOption(QImageIOHandler::SubType, form);
#endif
}
bool QPpmHandler::supportsOption(QImageIOHandler::ImageOption option) const
{
- return (option == QImageIOHandler::SubType || option == QImageIOHandler::Size);
+ return (option == QImageIOHandler::Size);
}
QVariant QPpmHandler::option(QImageIOHandler::ImageOption option) const
{
- if (option == QImageIOHandler::SubType) {
- return subType;
- } else if (option == QImageIOHandler::Size) {
+ if (option == QImageIOHandler::Size) {
if (state == Error)
return QVariant();
if (state == Ready && !const_cast<QPpmHandler*>(this)->readHeader())
return QVariant();
}
-void QPpmHandler::setOption(QImageIOHandler::ImageOption option, const QVariant &value)
-{
- if (option == QImageIOHandler::SubType)
- subType = value.toByteArray().toLower();
-}
-
QByteArray QPpmHandler::name() const
{
return subType.isEmpty() ? QByteArray("ppm") : subType;
}
QSTACKARRAY(char, head, 2);
- if (device->peek(head, sizeof(head)) != sizeof(head))
+ if (device->peek(head, sizeof(head)) != sizeof(head)) {
return false;
+ }
- if (head[0] != 'P')
+ if (head[0] != 'P') {
return false;
+ }
if (head[1] == '1' || head[1] == '4') {
- if (subType)
- *subType = "pbm";
+ Q_ASSERT(subType);
+ *subType = "pbm";
+ return true;
} else if (head[1] == '3' || head[1] == '6') {
- if (subType)
- *subType = "ppm";
- } else {
- return false;
+ Q_ASSERT(subType);
+ *subType = "ppm";
+ return true;
}
- return true;
+ return false;
}
QT_END_NAMESPACE
bool write(const QImage &image) final;
QVariant option(QImageIOHandler::ImageOption option) const final;
- void setOption(QImageIOHandler::ImageOption option, const QVariant &value) final;
bool supportsOption(QImageIOHandler::ImageOption option) const final;
QByteArray name() const final;