Click here to Skip to main content
15,744,304 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to save this blob data into database?? I am reading the jpeg image in Qbytearray; But while saving to database, the image size is doubled and while retrieving from database, the file is being corrupted. How to read the image properly??

QByteArray buf=NULL;
originalPixmap =QPixmap();
originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
QString strfname;
strfname.sprintf("%d",c);"C:\\Program Files\\image"+strfname+".jpeg","jpeg");
char Data;
QFile file("C:\\Program Files\\image"+strfname+".jpeg");;
int len=file.size();
QSqlQuery query;
query.exec("INSERT INTO log (grab_date, ip_address, image,logged_user) "
"VALUES (?,?,?,?)");
query.bindValue (3,hostname);
bool qry=query.exec();

1 solution

You are converting the image to base64. You must either remove the conversion or convert it back at the other end.
Share this answer
Gokulnath007 5-Aug-11 8:46am    
Couldnt get your point?? Could you please explain with my code??
Gokulnath007 5-Aug-11 8:47am    
I have tried in removing the conversion of to base64 also, again the same thing happens.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900