Diffstat (limited to 'noncore/graphics/drawpad/drawpadcanvas.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 8818c03..b8a1c2e 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp @@ -53,8 +53,9 @@ private: }; State m_state; ulong m_dataLenght; + QString m_dataFormat; QList<QPixmap> m_pixmaps; }; DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() @@ -79,8 +80,13 @@ bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QS if (qName.compare("data") == 0) { m_state = InData; m_dataLenght = atts.value("length").toULong(); + m_dataFormat = atts.value("format"); + + if (m_dataFormat.isEmpty()) { + m_dataFormat = "XPM"; + } } return true; } @@ -132,9 +138,9 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) QByteArray byteArrayUnzipped(m_dataLenght); ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); QImage image; - image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, "XPM"); + image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); QPixmap* pixmap = new QPixmap(image.width(), image.height()); pixmap->convertFromImage(image); m_pixmaps.append(pixmap); @@ -214,9 +220,9 @@ void DrawPadCanvas::save(QIODevice* ioDevice) QImage image = bufferIterator.current()->convertToImage(); QByteArray byteArray; QBuffer buffer(byteArray); - QImageIO imageIO(&buffer, "XPM"); + QImageIO imageIO(&buffer, "PNG"); buffer.open(IO_WriteOnly); imageIO.setImage(image); imageIO.write(); @@ -225,9 +231,9 @@ void DrawPadCanvas::save(QIODevice* ioDevice) ulong size = byteArray.size() * 2; QByteArray byteArrayZipped(size); ::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size()); - textStream << " <data length=\"" << byteArray.size() << "\">"; + textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">"; static const char hexchars[] = "0123456789abcdef"; for (int i = 0; i < (int)size; i++ ) { |