WEB开发网
开发学院手机开发Symbian 开发 Qt与symbian特定格式类对象的转换 阅读

Qt与symbian特定格式类对象的转换

 2010-06-22 03:05:00 来源:WEB开发网   
核心提示:1:FbsBitmap转为QImage应用场景:当使用摄像头时:拍摄的图像都是FBsBitmap,而如果要想让其显示在QWidget上,则需要首先将其转换成QImage格式,Qt与symbian特定格式类对象的转换,参数说明:aBitmap是传入参数,aImage是传出参数

1:FbsBitmap转为QImage

应用场景:当使用摄像头时:拍摄的图像都是FBsBitmap,而如果要想让其显示在QWidget上,则需要首先将其转换成QImage格式。

参数说明:aBitmap是传入参数,aImage是传出参数,当动态拍摄(相当于摄像)时:aStep为4; 当capture拍摄静态图片时:aStep为3.

view plaincopy to clipboardprint?

void FbsBitmapToQImage(CFbsBitmap* aBitmap,QImage* aImage,TInt aStep)

{

int aHeight=aBitmap->SizeInPixels().iHeight;

int aWidth=aBitmap->SizeInPixels().iWidth;

aBitmap->BeginDataAccess();

unsigned char* ptrBitmapPixel=(unsigned char*)(aBitmap->DataAddress()); //0xBBGGRRff

unsigned char* ptrImagePixel=aImage->scanLine(0); //0xBBGGRRff;

for(int i=0;i< p>

{

for(int j=0;j< p>

{

*(ptrImagePixel+2)=

char((int)(*(ptrBitmapPixel+2))/tmp); //Red

*(ptrImagePixel+1)=

char((int)(*(ptrBitmapPixel+1))/tmp); //Green

*(ptrImagePixel+0)=

char((int)(*(ptrBitmapPixel+0))/tmp); //Blue

ptrBitmapPixel+=aStep;

ptrImagePixel+=4;

}

}

aBitmap->EndDataAccess();

}

void FbsBitmapToQImage(CFbsBitmap* aBitmap,QImage* aImage,TInt aStep)

{

int aHeight=aBitmap->SizeInPixels().iHeight;

int aWidth=aBitmap->SizeInPixels().iWidth;

aBitmap->BeginDataAccess();

unsigned char* ptrBitmapPixel=(unsigned char*)(aBitmap->DataAddress()); //0xBBGGRRff

unsigned char* ptrImagePixel=aImage->scanLine(0); //0xBBGGRRff;

for(int i=0;i< p>

{

for(int j=0;j< p>

{

*(ptrImagePixel+2)=

char((int)(*(ptrBitmapPixel+2))/tmp); //Red

1 2  下一页

Tags:Qt symbian 特定

编辑录入:coldstar [复制链接] [打 印]
赞助商链接