author | leseb <leseb> | 2002-04-06 22:20:19 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-04-06 22:20:19 (UTC) |
commit | 75bc9d885aa131334a0b906a1a58134740c40783 (patch) (side-by-side diff) | |
tree | 08a05fe92e1e2f1dc67604f9040bf669e5b4c84a /noncore/graphics/drawpad/drawpadcanvas.cpp | |
parent | 8e092bf08c2873dcdec4694573cf715b7a590e41 (diff) | |
download | opie-75bc9d885aa131334a0b906a1a58134740c40783.zip opie-75bc9d885aa131334a0b906a1a58134740c40783.tar.gz opie-75bc9d885aa131334a0b906a1a58134740c40783.tar.bz2 |
- Save album in PNG format instead of XPM
- Small fixes
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 @@ -45,24 +45,25 @@ public: bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName); bool characters(const QString& ch); private: enum State { Unknown, InData }; State m_state; ulong m_dataLenght; + QString m_dataFormat; QList<QPixmap> m_pixmaps; }; DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() { m_state = Unknown; } DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() { } @@ -71,24 +72,29 @@ QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps() return m_pixmaps; } bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) { Q_CONST_UNUSED(namespaceURI) Q_CONST_UNUSED(localName) 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; } bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, const QString& qName) { Q_CONST_UNUSED(namespaceURI) Q_CONST_UNUSED(localName) if (qName.compare("data") == 0) { @@ -124,25 +130,25 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) byteArray[i] = r; } if (m_dataLenght < ch.length() * 5) { m_dataLenght = ch.length() * 5; } 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); } return true; } DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) : QScrollView(parent, name) { @@ -206,36 +212,36 @@ void DrawPadCanvas::save(QIODevice* ioDevice) textStream << "<drawpad>" << endl; textStream << " <images>" << endl; QListIterator<QPixmap> bufferIterator(m_pages); for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { textStream << " <image>" << endl; 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(); buffer.close(); 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++ ) { uchar s = (uchar)byteArrayZipped[i]; textStream << hexchars[s >> 4]; textStream << hexchars[s & 0x0f]; } textStream << "</data>" << endl; textStream << " </image>" << endl; } |