mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kimgio: restore device position conditionally
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4bd5d6b609
commit
b2597e71e5
1 changed files with 10 additions and 6 deletions
|
@ -30,7 +30,7 @@ static const char* const s_rawpluginformat = "raw";
|
||||||
class RAWDataStream : public LibRaw_abstract_datastream
|
class RAWDataStream : public LibRaw_abstract_datastream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RAWDataStream(QIODevice* device);
|
RAWDataStream(QIODevice* device, const bool restore);
|
||||||
~RAWDataStream();
|
~RAWDataStream();
|
||||||
|
|
||||||
int valid() final;
|
int valid() final;
|
||||||
|
@ -48,17 +48,21 @@ public:
|
||||||
private:
|
private:
|
||||||
QIODevice* m_device;
|
QIODevice* m_device;
|
||||||
const qint64 m_devicepos;
|
const qint64 m_devicepos;
|
||||||
|
const bool m_restore;
|
||||||
};
|
};
|
||||||
|
|
||||||
RAWDataStream::RAWDataStream(QIODevice* device)
|
RAWDataStream::RAWDataStream(QIODevice* device, const bool restore)
|
||||||
: m_device(device),
|
: m_device(device),
|
||||||
m_devicepos(m_device->pos())
|
m_devicepos(m_device->pos()),
|
||||||
|
m_restore(restore)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RAWDataStream::~RAWDataStream()
|
RAWDataStream::~RAWDataStream()
|
||||||
{
|
{
|
||||||
m_device->seek(m_devicepos);
|
if (m_restore) {
|
||||||
|
m_device->seek(m_devicepos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int RAWDataStream::valid()
|
int RAWDataStream::valid()
|
||||||
|
@ -184,7 +188,7 @@ bool RAWHandler::read(QImage *image)
|
||||||
LibRaw raw;
|
LibRaw raw;
|
||||||
raw.imgdata.params.output_color = LIBRAW_COLORSPACE_sRGB;
|
raw.imgdata.params.output_color = LIBRAW_COLORSPACE_sRGB;
|
||||||
|
|
||||||
RAWDataStream rawdatastream(device());
|
RAWDataStream rawdatastream(device(), false);
|
||||||
int rawresult = raw.open_datastream(&rawdatastream);
|
int rawresult = raw.open_datastream(&rawdatastream);
|
||||||
if (Q_UNLIKELY(rawresult != LIBRAW_SUCCESS)) {
|
if (Q_UNLIKELY(rawresult != LIBRAW_SUCCESS)) {
|
||||||
kWarning() << "Could not open datastream" << libraw_strerror(rawresult);
|
kWarning() << "Could not open datastream" << libraw_strerror(rawresult);
|
||||||
|
@ -266,7 +270,7 @@ bool RAWHandler::canRead(QIODevice *device)
|
||||||
LibRaw raw;
|
LibRaw raw;
|
||||||
raw.imgdata.params.output_color = LIBRAW_COLORSPACE_sRGB;
|
raw.imgdata.params.output_color = LIBRAW_COLORSPACE_sRGB;
|
||||||
|
|
||||||
RAWDataStream rawdevicestream(device);
|
RAWDataStream rawdevicestream(device, true);
|
||||||
const int rawresult = raw.open_datastream(&rawdevicestream);
|
const int rawresult = raw.open_datastream(&rawdevicestream);
|
||||||
if (rawresult == LIBRAW_FILE_UNSUPPORTED) {
|
if (rawresult == LIBRAW_FILE_UNSUPPORTED) {
|
||||||
kDebug() << libraw_strerror(rawresult);
|
kDebug() << libraw_strerror(rawresult);
|
||||||
|
|
Loading…
Add table
Reference in a new issue