【发布时间】:2013-08-27 09:41:44
【问题描述】:
我在从之前从大型游戏文件加载的原始 bmp 数据加载图像数据时遇到了一些问题。
我确定数据没问题,因为没有到达else 分支,但没有显示图像。
也许我没有以正确的方式使用loadFromData?
有人遇到过这个问题吗?
QByteArray buff((this->current_object->image_buffer));
QPixmap pixmap;
if(pixmap.loadFromData(buff)){
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
this->scene->addItem(item);
this->ui->graphicsView->update();
}else{
QMessageBox::information(0, "Error.", "Could not convert BMP image.");
//TEST IF BITMAP IS CORRECT
FILE *pFile = fopen("/home/konstanty/img.bmp", "wb");
for(int j=0;j<this->current_object->bitmap_size;j++){
fwrite (&this->current_object->image_buffer[j], 1 , 1 , pFile);
}
fclose(pFile);
QPixmap imgg("/home/konstanty/img.bmp");
qDebug() << imgg.isNull(); // output - false
【问题讨论】:
标签: c++ qt qpixmap qbytearray