PDA

View Full Version : On memory png data



^NyAw^
20th December 2012, 12:13
Hi,

I want to create a PNG structure from a buffer pointer.

What I want to do is to store PNG files into MySQL database in a BLOB column. The data for create the PNG file comes from a USB camera.

What I don't want to do is to get the camera data, write into a file, open the file and write the file data into database because writing and reading from a file will slow down speed(high speed will be needed).

So, how can I get the PNG compressed structure into memory without using a file? Maybe have I to create a memory file? Is that possible?

Thanks,

Jonny174
20th December 2012, 13:01
QByteArray bytes;
QBuffer buffer( &bytes );
buffer.open( QIODevice::WriteOnly );
image.save( &buffer, "PNG" );

And write bytes in DB. (This load from exist image)

Load from BD:


QByteArray loadImage = q.value(0).toByteArray();

if (!loadImage.isEmpty())
{
QImage img;
img.loadFromData( loadImage );
}