I have captured a fingerprint image in imgBuffer.
BYTE *imgBuffer = new BYTE[m_ImageWidth*m_ImageHeight];
myObj->GetImage(imgBuffer);
Convert it into Base64.
int imgBufferSize = sizeof(imgBuffer) - 1;
QByteArray temp = QByteArray(*imgBuffer, imgBufferSize);
QByteArray base64Image = temp.toBase64();
But I am getting something like this:
BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBw==
I followed this: How to convert an array into QByteArray?
Edit: Actually after implementing Jacob's solution I got another Base64 string but that was not also an image. Though Jacob's solution was correct. The problem was that the image didn't have any meta data. So, I solved it using following procedure:
QImage jpgImage((const unsigned char*)imgBuffer, m_ImageWidth, m_ImageHeight, QImage::Format_Grayscale8);
QByteArray mImage64ByteArray;
QBuffer buffer(&mImage64ByteArray);
buffer.open(QIODevice::WriteOnly);
jpgImage.save(&buffer, "JPG");
mImage64ByteArray = mImage64ByteArray.toBase64();