Click here to Skip to main content
Rate this: bad
good
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);
    originalPixmap.save("C:\\Program Files\\image"+strfname+".jpeg","jpeg");
    c++;
    char Data;
    QFile file("C:\\Program Files\\image"+strfname+".jpeg");
    file.open(QIODevice::ReadOnly);
    int len=file.size();
    //buf=file.read(len);
    buf=file.readAll();
    file.close();
    file.remove();
    QSqlQuery query;
    query.exec("INSERT INTO log (grab_date, ip_address, image,logged_user) "
    "VALUES (?,?,?,?)");
    query.bindValue(0,dd);
    query.bindValue(1,address);
    query.bindValue(2,buf.toBase64());
    query.bindValue (3,hostname);
    bool qry=query.exec();
Posted 5-Aug-11 1:25am

1 solution

Rate this: bad
good
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.
  Permalink  
Comments
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 451
1 Afzaal Ahmad Zeeshan 184
2 /\jmot 176
3 Marcin Kozub 150
4 Sergey Alexandrovich Kryukov 150
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 5 Aug 2011
Copyright © CodeProject, 1999-2014
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