diff options
Diffstat (limited to 'saltoqd/msolimageiohandler.cpp')
-rw-r--r-- | saltoqd/msolimageiohandler.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/saltoqd/msolimageiohandler.cpp b/saltoqd/msolimageiohandler.cpp index c921c20..e6a9065 100644 --- a/saltoqd/msolimageiohandler.cpp +++ b/saltoqd/msolimageiohandler.cpp @@ -1,4 +1,5 @@ #include <QtCore/QtEndian> +#include <QtCore/QBuffer> #include <QtCore/QVariant> #include <QtCore/QDebug> #include <QtGui/QImage> @@ -160,3 +161,28 @@ void MSOLImageIOHandler::setOption(ImageOption option, const QVariant &value) { } + +QByteArray convertImageToMsol(const QImage &img) +{ + MSOLImageIOHandler msolio; + QBuffer msolImg; + msolImg.open(QBuffer::WriteOnly); + msolio.setDevice(&msolImg); + if (!msolio.write(img)) { + return QByteArray(); + } + return msolImg.data(); +} + +QImage convertMsolToImage(const QByteArray &msol) +{ + MSOLImageIOHandler msolio; + QBuffer msolImg; + QImage img; + msolImg.setData(msol); + msolImg.open(QBuffer::ReadOnly); + if (!msolio.read(&img)) { + return QImage(); + } + return img; +} |