[Qt-creator] Encode with Base 64 of QByteArray

gn pr gn_pr at yahoo.es
Tue May 12 22:21:18 CEST 2009


I have this code : 

QByteArray l ("D:\\grace.jpg");

#include <QtCore/QCoreApplication>
int main(int argc, char *argv[])
{
  QCoreApplication a(argc, argv); 
  
  FILE *  origen;
  
  origen = fopen("d:\\grace.jpg", "rb");
  
  unsigned char * linea;
  
  QByteArray * _content = new QByteArray();

  int _fileSize = 0 ;
   
  while(!feof(origen) )
  {
fread(linea,1,1, origen) ;
QChar caracteres((unsigned char )*linea);
_content->append(caracteres) ;
_fileSize += 1;
   }

fclose(origen) ;

QByteArray tmp =  _content->toBase64();

QByteArray tmp2 = tmp.fromBase64(tmp) ;

FILE * sal ;

sal = fopen ("copia.jpg", "ab+");

fwrite(&tmp2, _fileSize, 1, sal);

fclose(sal);

delete _content ;

return a.exec();

}

Not Run , What is wrong with that snipped code ? please help :) 



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20090512/e6c9c4f7/attachment.html 


More information about the Qt-creator-old mailing list