上源码
char *InBuf =NULL ;
unsigned char *OutBuf ;
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), QDir::currentPath());
QFile file(fileName);
file.open(QIODevice::ReadOnly);
QDataStream in(&file); // read the data serialized from the file
in >> InBuf;
fileSize=strlen(InBuf);
if(InBuf==NULL)
QMessageBox::information(this, tr("Image Viewer"),
tr("Cannot load %1.").arg("a"));
memcpy(InBuf,OutBuf,fileSize);
QImage image(OutBuf,320,240,QImage::Format_888);
if (image.isNull()) {
QMessageBox::information(this, tr("Image Viewer"),
tr("Cannot load %1.").arg(fileName));
return;
}
QPixmap *pixmap=new QPixmap;
pixmap->fromImage(image);
imageLabel->setPixmap(*pixmap);最后在label上显示
就是把把RGB读入InBuf在写入 QImage ,然后显示
可是在QT上一run ,窗口就自动关闭了 ……调了一下午 ,求解