I'm having trouble with saving a QPixmap to QByteArray, then writing it to char*. For example i'm trying to write to a file with ofstream.
QByteArray bytes;
QBuffer buff(&bytes);
buff.open(QIODevice::ReadOnly);
pixmap.save(&buff, "PNG");
QString str(bytes);
char *data;
data = (char*)qstrdup(str.toAscii().constData());
ofstream myfile;
myfile.open ("test.jpg");
myfile << data;
myfile.close();
But all i get in that file is:
‰PNG
The reason i need a char* , is because i'm having some permission problems when writing to disk, then sending with libcurl. I want to load it to a char* , then send it directly from memory.