Converting QPixmap to QByteArray: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Cleanup)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''English''' [[Converting QPixmap to QByteArray Bulgarian|Български]]
{{LangSwitch}}
[[Category:snippets]]
This is one way to convert {{DocLink|QPixmap}} to {{DocLink|QByteArray}}.


=Convert QPixmap to QByteArray=
Useful when you want to store a pixmap in a database etc.
 
This is one way to convert [http://doc.qt.nokia.com/latest/qpixmap.html QPixmap] ''[doc.qt.nokia.com]'' to [http://doc.qt.nokia.com/latest/qbytearray.html QByteArray] ''[doc.qt.nokia.com]''.


Useful when you want to store a pixmap in a database etc.
<code>
QPixmap pixmap;
// Preparation of our QPixmap
QByteArray bArray;
QBuffer buffer(&bArray);
buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, "PNG");
</code>


Now variable ''bArray'' contains the byte array form of pixmap.
Now variable ''bArray'' contains the byte array form of pixmap.
'''Categories'''<br />[[Snippets]]<br />[[HowTo]]

Latest revision as of 12:51, 28 June 2015

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

This is one way to convert QPixmap to QByteArray.

Useful when you want to store a pixmap in a database etc.

QPixmap pixmap;
// Preparation of our QPixmap
QByteArray bArray;
QBuffer buffer(&bArray);
buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, "PNG");

Now variable bArray contains the byte array form of pixmap.