Converting QPixmap to QByteArray: Difference between revisions
Jump to navigation
Jump to search
AutoSpider (talk | contribs) (Convert ExpressionEngine links) |
(Cleanup) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LangSwitch}} | ||
[[Category:snippets]] | |||
This is one way to convert {{DocLink|QPixmap}} to {{DocLink|QByteArray}}. | |||
This is one way to convert | |||
Useful when you want to store a pixmap in a database etc. | Useful when you want to store a pixmap in a database etc. | ||
Line 13: | Line 9: | ||
// Preparation of our QPixmap | // Preparation of our QPixmap | ||
QByteArray bArray; | QByteArray bArray; | ||
QBuffer buffer( & | QBuffer buffer(&bArray); | ||
buffer.open( QIODevice::WriteOnly ); | buffer.open(QIODevice::WriteOnly); | ||
pixmap.save( & | pixmap.save(&buffer, "PNG"); | ||
</code> | </code> | ||
Now variable ''bArray'' contains the byte array form of pixmap. | Now variable ''bArray'' contains the byte array form of pixmap. | ||
Latest revision as of 12:51, 28 June 2015
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.