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
Posts: 673
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?

Developer
Posts: 1,022
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

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.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Contributor
Posts: 11
Registered: ‎12-13-2012
My Device: Blackberry Z10, Blackberry Playbook 16GB/64GB
My Carrier: Rogers

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();