QImage to byte array doesn't work
-
Hey,
I try to get the raw Bytes from pictre from a QImage like
QImage preview; QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); qDebug() << "Saved: " << preview.save(&buffer);
Yes, there is something in the QImage, I can display it.
But save function returns a false.
I need this to send a char array to my ESP8266 where use C so it can show the picture on an E-Paper Display
-
@Gh0stShell said in QImage to byte array doesn't work:
qDebug() << "Saved: " << preview.save(&buffer);
Have you tried using a file extension / an image format?
preview.save(&buffer, "JPEG");
or"PNG"
Does
buffer.open(....)
returntrue
? -
@Gh0stShell
Since the example for this at https://doc.qt.io/qt-5/qimage.html#save-1 showsimage.save(&buffer, "PNG"); // writes image into ba in PNG format
I presume as @Pl45m4 says you must specify the desired format to save in since you are not using a filename with a suffix.
-
When I do this, my programm is unexpectedly finishing
I am thinking about to read the picture pixel by pixel and then convert the int to char