mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kimgio: partial fix for blended webp animations
not sure what to do with the offsets Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c8056b579b
commit
08154cd8c1
2 changed files with 27 additions and 1 deletions
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
#include "webp.h"
|
#include "webp.h"
|
||||||
#include "kdebug.h"
|
#include "kdebug.h"
|
||||||
#include <QImage>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
#include <webp/decode.h>
|
#include <webp/decode.h>
|
||||||
#include <webp/encode.h>
|
#include <webp/encode.h>
|
||||||
|
@ -119,10 +120,33 @@ bool WebPHandler::read(QImage *image)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (webpiter.blend_method) {
|
||||||
|
case WEBP_MUX_BLEND: {
|
||||||
|
if (Q_UNLIKELY(m_lastframe.isNull())) {
|
||||||
|
kWarning() << "Last frame is null";
|
||||||
|
} else {
|
||||||
|
QPainter p(image);
|
||||||
|
// TODO: offsets (webpiter.x_offset and webpiter.y_offset)
|
||||||
|
p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
|
||||||
|
p.drawImage(0, 0, m_lastframe);
|
||||||
|
p.end();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WEBP_MUX_NO_BLEND: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
kWarning() << "Unknown blend method" << webpiter.blend_method;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_currentimage++;
|
m_currentimage++;
|
||||||
if (m_currentimage >= m_imagecount) {
|
if (m_currentimage >= m_imagecount) {
|
||||||
m_currentimage = 0;
|
m_currentimage = 0;
|
||||||
}
|
}
|
||||||
|
m_lastframe = *image;
|
||||||
|
|
||||||
WebPDemuxReleaseIterator(&webpiter);
|
WebPDemuxReleaseIterator(&webpiter);
|
||||||
WebPAnimDecoderDelete(webpanimdec);
|
WebPAnimDecoderDelete(webpanimdec);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QImageIOHandler>
|
#include <QImageIOHandler>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
class WebPHandler : public QImageIOHandler
|
class WebPHandler : public QImageIOHandler
|
||||||
{
|
{
|
||||||
|
@ -52,6 +53,7 @@ private:
|
||||||
int m_imagecount;
|
int m_imagecount;
|
||||||
int m_imagedelay;
|
int m_imagedelay;
|
||||||
int m_currentimage;
|
int m_currentimage;
|
||||||
|
QImage m_lastframe;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue