View Full Version : sending QImage over serial port
yagabey
16th January 2008, 13:38
Hello, i am trying to send a QImage file over serial port; but i couldn't manage it..
There is no data sent in serial port monitor, when i send the file "avatar.gif"..(with send function of Qextserialport)
Am i missing something...
here is my code:
QByteArray bytes;
QImage picture(80, 80,QImage::Format_RGB32);
QImageReader reader("C:/Documents and Settings/pc/MyDocuments/Visual Studio 2005/Projects/videocapture3/avatar.gif");
reader.read(&picture);
picture.loadFromData(bytes);
sp->send(bytes.size(),bytes.data());
jacek
16th January 2008, 15:10
Where do you fill "bytes" with data?
yagabey
16th January 2008, 19:29
Ok.. I havent used QImage or QImagereader before; and perhaps I misunderstand them...
Hello, i am trying to send a QImage file over serial port; but i couldn't manage it..
There is no data sent in serial port monitor, when i send the file "avatar.gif"..(with send function of Qextserialport)
Am i missing something...
What i understand is that:
QByteArray bytes;// a bytes array formed
QImage picture(80, 80,QImage::Format_RGB32); // a picture object formed
QImageReader reader("C:/Documents and Settings/pc/MyDocuments/Visual Studio 2005/Projects/videocapture3/avatar.gif"); //avatar.gif is read into "reader"
reader.read(&picture); // reads the image from reade into picture..
picture.loadFromData(bytes); // bytes are filled here
sp->send(bytes.size(),bytes.data());// bytes are sent here
is that wrong?
jacek
16th January 2008, 19:39
picture.loadFromData(bytes); // bytes are filled here
On the contrary, you load data from bytes into picture. You can access image data using QImage::bits().
What format do you need to send that image in?
yagabey
16th January 2008, 21:20
I need te send it as it is.. I wont change the format while sending..
I checked QImage::bits; it returns a uchar pointer. How to fill the bytes with that?
jacek
16th January 2008, 21:38
I need te send it as it is.. I wont change the format while sending..
Then you don't need QImage, but QFile::readAll().
I checked QImage::bits; it returns a uchar pointer. How to fill the bytes with that?
Using proper QByteArray constructor.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.