QFile file (fileNamesave); if (file.open(QIODevice::WriteOnly )){ QTextStream out(stdout); QTextCodec *concodec = QTextCodec::codecForName("CP-866"); out.setCodec(concodec); QDataStream stream(&file); stream.setVersion(QDataStream::Qt_4_7); stream << image; } file.close();
QByteArray ba;image.loadFromData(ba);//image.loadFromData(QByteArray::fromBase64(ba)); QFile file (fileNamesave); if (file.open(QIODevice::WriteOnly )){ QTextStream out(stdout); QTextCodec *concodec = QTextCodec::codecForName("CP-866"); out.setCodec(concodec); QDataStream stream(&file); stream.setVersion(QDataStream::Qt_4_7); stream << ba; }file.close();
C++ (Qt)QFile file(file);if (file.open(QFile::WriteOnly | QFile::Truncate)) { QDataStream strm(&file); strm << image.width() << image.height(); file.write((const char *) image.bits(), qint64(image.bytesPerLine()) * image.height());}
QFile file("fail.txt"); if ( !file.open(QIODevice::WriteOnly) ) return; QTextStream stream(&file); for (int i=0; i<height_im; i++) for (int j=0; j<width_im; j++) { int rint= red[i][j]; int gint= green[i][j]; int bint= blue[i][j]; QString rtxt = QString::number(rint); QString gtxt = QString::number(gint); QString btxt = QString::number(bint); stream << rtxt << " "; stream << gtxt<< " "; stream << btxt << " "; }
C++ (Qt) int rowSize = sizeof(red[0][0]) * width_im; for (int i=0; i<height_im; i++) { file.write((char *) &red[i][0], rowSize); file.write((char *) &green[i][0], rowSize); file.write((char *) &blue[i][0], rowSize); }