Qt与symbian特定格式类对象的转换
2010-06-22 03:05:00 来源:WEB开发网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
{
for(int j=0;j
{
*(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
{
for(int j=0;j
{
*(ptrImagePixel+2)=
char((int)(*(ptrBitmapPixel+2))/tmp); //Red
更多精彩
赞助商链接