PDA

View Full Version : QImage constructor



Lele
11th January 2007, 10:56
Hello,
I'm just trying to create a Qimage passing a buffer or ARGB.
So I tried this:


uchar* testB = new uchar[384*288*4];
QImage image = QImage((uchar*) testB, 384, 288, QImage::Format_ARGB32);


On the second line I get an error and it occurs when in the QImage constructor
I access d->depth (set on 0 at the first line):



QImage::QImage(uchar* data, int width, int height, Format format)
: QPaintDevice()
{
d = 0;
const int depth = depthForFormat(format);
const int bytes_per_line = ((width * d->depth + 31)/32) * 4;


Am I doing something wrong or it's a QT bug? (I'm using 4.2.1)

thanks

bye

edb
11th January 2007, 12:52
Hi,

If you set d to 0, you cannot access any member of d. I assume your program crashes when you run d->depth. What is the type of d? Why do you initialise it to be 0?

Ellen

jpn
11th January 2007, 13:06
Try re-downloading Qt. I recall this bug. Upon releasing, the Trolls accidentally uploaded a wrong version of Qt (having the QImage bug) to their servers. It was soon later fixed to the correct package, but all users who managed to download the package during that time were affected by the bug. Are you even able to launch Qt Assistant and Designer? As far as I remember, the bug even prevented either one or both of them from starting up.

EDIT: By the way, I'm 100% sure the bug was listed on the Task Tracker. I can't find it anymore, though...


If you set d to 0, you cannot access any member of d. I assume your program crashes when you run d->depth. What is the type of d? Why do you initialise it to be 0?
It's QImage's constructor. Not his own code. d is a pointer to the private implementation (http://wiki.qtcentre.org/index.php?title=Private_Implementation).