Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
shahumang8
Posts: 646
Registered: ‎08-09-2010
My Device: Not Specified
Accepted Solution

How to convert QImage to QByteArray?

Hello,

 

   Any one know how to convert QImage to QByteArray?

Please use plain text.
Developer
greenmr
Posts: 882
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: How to convert QImage to QByteArray?

There is sample code here which shows how to copy QImage pixel data into an array of chars. You should be able to modify it to copy into a QByteArray instead.

 


shahumang8 wrote:

Hello,

 

   Any one know how to convert QImage to QByteArray?






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.
Contributor
tredpath
Posts: 11
Registered: ‎12-13-2012
My Device: Blackberry Z10, Blackberry Playbook 16GB/64GB

Re: How to convert QImage to QByteArray?

You can use this:

QImage img = getAnImage();
QByteArray arr;
QBuffer buf(&arr);
buf.open(QIODevice::WriteOnly);
img.save(&buf, "PNG");
buf.close();

 

Please use plain text.