我编写的一个显示16bpp (rgb565)的视频数据
实验程序如下,用0xcccc来构建(setPixel)一个QImage,然后用QPainter显示在一个Widget上
现在只有用QT-X11编可以正常显示,用qt-embeded-forx86编译,用qvfb显示,不管用16bpp还是32bpp的qvfb都显示不出来,就是执行完p.drawImage(0,0,*img);但是什么也没显示,而且更怪的是普通的BMP图像在X11下也可以显示,但在QVFB中就显示不出来,这时为什么?
#include "VideoWidget.h"
#include "YUV2RGBConverter.h"
#include "common.h"
#include <qpainter.h>
#include <qpixmap.h>
#include <qstring.h>
#include <malloc.h>
#include <qimage.h>
#include <qcolor.h>
#include <qiodevice.h>
VideoWidget::VideoWidget(QWidget* parent):QWidget(parent)
{}
void VideoWidget::playVideo ()
{
int i,j;
qDebug("before painter\n");
QPainter p (this);
qDebug("after conver\n");
qDebug("before new\n");
//QImage *img=new QImage ("/root/Code/testyuv/1.bmp");
//QImage *img=new QImage (400,400,16,0,QImage::IgnoreEndian);
//QImage *img=new QImage (400,400,16,0,QImage::BigEndian);
QImage *img=new QImage (176,144,16,0,QImage::LittleEndian);
/*
int filesize=img->bytesPerLine();
int hei=img->height();
int wid=img->width();
int depth= img->depth();
int order = img->bitOrder();
qDebug("filesize = %d",filesize);
qDebug("hei = %d",hei);
qDebug("wid = %d",wid);
qDebug("depth = %d",depth);
qDebug("order = %d",order);
*/
//img->load("/root/Code/testyuv/1.bmp");
unsigned short rgb = 0xcccc;
unsigned short *out = &rgb;
qDebug("after rgb\n");
for(i=0; i<144; i++)
{
for(j=0; j<176; j++)
{
img->setPixel(j, i, *out);
// out++;
}
}
//free(p);
qDebug("before draw\n");
p.drawImage(0,0,*img);
qDebug("after draw\n");
//p.drawPixmap(40,40,pix);
// bool flag=img->loadFromData(dest_ori,558200);
// if(!flag) qWarning("not loaded!");
//p.drawImage(x1,y1,*img);
}
[ 此贴被XChinux在2006-03-27 12:45重新编辑 ]