Click here to Skip to main content
11,803,019 members (66,019 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: QT QT-Creator
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();
Posted 5-Aug-11 0:25am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You are converting the image to base64. You must either remove the conversion or convert it back at the other end.
Gokulnath007 at 5-Aug-11 8:46am
Couldnt get your point?? Could you please explain with my code??
Gokulnath007 at 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)

  Print Answers RSS
0 OriginalGriff 335
1 KrunalRohit 291
2 F-ES Sitecore 270
3 CPallini 270
4 Sergey Alexandrovich Kryukov 234
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,735
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 5 Aug 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100