相关文章推荐
闯红灯的牛肉面  ·  高斯模糊 - 知乎·  1 年前    · 
俊秀的毛衣  ·  XStream、JAXB ...·  1 年前    · 
大鼻子的大熊猫  ·  Is there WebFilter ...·  1 年前    · 
 1   QString filename = QDir::homePath() + "/Desktop/TOF.png";
 2   QImage* img = new QImage;
 3   if(!(img->load(filename))) //加载图像
 5     QMessageBox::information(this, tr("打开图像失败"), tr("打开图像失败!"));
 6         delete img;
 7         return;
 9   //QPixmap->QByteArray
10   QPixmap pixmap = QPixmap::fromImage(*img);
11   QByteArray byteArray = QByteArray();
12   QBuffer buffer(&byteArray);
13   buffer.open(QIODevice::WriteOnly);
14   pixmap.save(&buffer,"png",0);
15   //QByteArray->QString
16   QString str2 = QString(byteArray.toBase64());
17   printf("%s", str2.toStdString()); 
18   //QString->QByteArray
19   QByteArray byteArray = QByteArray::fromBase64(str2.toLocal8Bit();
20   //QByteArray->QPixmap
21   QPixmap pix; 
22   pix.loadFromData(byteArray, "png");