Solved

How to load data from QImage into QByteArray ?

Posted on 2011-03-21
2
3,793 Views
Last Modified: 2012-05-11
Hi experts,

How do I load data from a QImage into a QByteArray ? I need only the raw data of the image in the array. For example, if I have a PNG, I only need to read the raw data of the image.

Thanks,
Peter
0
Comment
Question by:PeterVarain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 35184533
You can use 'QImage::bits()' (http://doc.qt.nokia.com/latest/qimage.html#bits-2) for that, e.g.
QImage img;

//...

QByteArray arr((char*)img.bits(),img.byteCount());

Open in new window

0
 

Author Closing Comment

by:PeterVarain
ID: 35184767
Thanks !
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Viewers will learn the basics of creating custom device Racks in Ableton Live. Place instrument(s) and effects onto a track, and select them all by holding the Shift key and clicking on the device title bars: Group them by typing Command-G (Ctrl-G…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question