mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 00:58:15 -04:00
Support to QImageIOHandler::Size option
This commit is contained in:
parent
52134fc2e9
commit
f8a251e268
@ -820,6 +820,38 @@ bool PSDHandler::read(QImage *image)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PSDHandler::supportsOption(ImageOption option) const
|
||||
{
|
||||
if (option == QImageIOHandler::Size)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant PSDHandler::option(ImageOption option) const
|
||||
{
|
||||
QVariant v;
|
||||
|
||||
if (option == QImageIOHandler::Size) {
|
||||
if (auto d = device()) {
|
||||
// transactions works on both random and sequential devices
|
||||
d->startTransaction();
|
||||
auto ba = d->read(sizeof(PSDHeader));
|
||||
d->rollbackTransaction();
|
||||
|
||||
QDataStream s(ba);
|
||||
s.setByteOrder(QDataStream::BigEndian);
|
||||
|
||||
PSDHeader header;
|
||||
s >> header;
|
||||
|
||||
if (s.status() == QDataStream::Ok && IsValid(header))
|
||||
v = QVariant::fromValue(QSize(header.width, header.height));
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
bool PSDHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
|
@ -18,6 +18,9 @@ public:
|
||||
bool canRead() const override;
|
||||
bool read(QImage *image) override;
|
||||
|
||||
bool supportsOption(QImageIOHandler::ImageOption option) const override;
|
||||
QVariant option(QImageIOHandler::ImageOption option) const override;
|
||||
|
||||
static bool canRead(QIODevice *device);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user