mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
Merge branch 'master' of ssh://github.com/fluxer/katie
This commit is contained in:
commit
c8bd68d5fd
6 changed files with 18 additions and 34 deletions
|
@ -83,11 +83,6 @@
|
|||
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.
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ public:
|
|||
CompressionLevel,
|
||||
Gamma,
|
||||
Quality,
|
||||
SubType,
|
||||
Animation,
|
||||
BackgroundColor
|
||||
};
|
||||
|
|
|
@ -144,7 +144,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
|
|||
#ifndef QT_NO_IMAGEFORMAT_PPM
|
||||
} else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
|
||||
handler = new QPpmHandler();
|
||||
handler->setOption(QImageIOHandler::SubType, form);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -179,7 +178,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
|
|||
QByteArray subType;
|
||||
if (!handler && QPpmHandler::canRead(device, &subType)) {
|
||||
handler = new QPpmHandler();
|
||||
handler->setOption(QImageIOHandler::SubType, subType);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
|
|||
#ifndef QT_NO_IMAGEFORMAT_PPM
|
||||
} else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
|
||||
handler = new QPpmHandler();
|
||||
handler->setOption(QImageIOHandler::SubType, form);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -345,14 +345,12 @@ bool QPpmHandler::write(const QImage &image)
|
|||
|
||||
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())
|
||||
|
@ -362,12 +360,6 @@ QVariant QPpmHandler::option(QImageIOHandler::ImageOption option) const
|
|||
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;
|
||||
|
@ -381,22 +373,24 @@ bool QPpmHandler::canRead(QIODevice *device, QByteArray *subType)
|
|||
}
|
||||
|
||||
QSTACKARRAY(char, head, 2);
|
||||
if (device->peek(head, sizeof(head)) != sizeof(head))
|
||||
return false;
|
||||
|
||||
if (head[0] != 'P')
|
||||
return false;
|
||||
|
||||
if (head[1] == '1' || head[1] == '4') {
|
||||
if (subType)
|
||||
*subType = "pbm";
|
||||
} else if (head[1] == '3' || head[1] == '6') {
|
||||
if (subType)
|
||||
*subType = "ppm";
|
||||
} else {
|
||||
if (device->peek(head, sizeof(head)) != sizeof(head)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (head[0] != 'P') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (head[1] == '1' || head[1] == '4') {
|
||||
Q_ASSERT(subType);
|
||||
*subType = "pbm";
|
||||
return true;
|
||||
} else if (head[1] == '3' || head[1] == '6') {
|
||||
Q_ASSERT(subType);
|
||||
*subType = "ppm";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -50,7 +50,6 @@ public:
|
|||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue