01-25-2013 09:59 AM - edited 01-25-2013 10:03 AM
Can any one help me for getting the byte array from image path in blackberry 10 cascades?
01-25-2013 11:05 AM
01-25-2013 11:51 AM
Can you give some code for that?
I have tried the following but it will display the empty data only.
QFile file(QDir::currentPath()+filepath);
file.open(QIODevice::ReadOnly);
QByteArray data = file.readAll(); //Here the data is empty
01-25-2013 12:14 PM
01-26-2013 05:34 AM
I have changed the image path and now am getting the bytes array like this ÿØÿà.
MyCode
QFile file(QDir::currentPath() + "/app/native/assets/Icon/img.png");
if (!file.open(QIODevice::ReadOnly))
{
qDebug() << "error in open the image path";
return;
}
else
{
qDebug()<< QString(file.readAll()); //Here am getting this symbol ÿØÿà
}
01-26-2013 07:20 AM
In normal Qt (not Cascades) this works with transfering image over network socket (taken from here).
QImage image; // See the documentation on how to use QImage objects
image.load("test.png", "PNG");
QByteArray ba; // Construct a QByteArray object
QBuffer buffer(&ba); // Construct a QBuffer object using the QbyteArray
image.save(&buffer, "PNG"); // Save the QImage data into the QBuffer
//do whatever you want with the buffer