1:FbsBitmap转为QImage
应用场景:当使用摄像头时:拍摄的图像都是FBsBitmap,而如果要想让其显示在QWidget上,则需要首先将其转换成QImage格式。
参数说明:aBitmap是传入参数,aImage是传出参数,当动态拍摄(相当于摄像)时:aStep为4; 当capture拍摄静态图片时:aStep为3.
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<aHeight;i++)
{
for(int j=0;j<aWidth;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();
}
2:QString转为TPtr
void
QStringToTPtr(QString* aQtMsg,TPtr* aS60Msg)
{
aS60Msg->
Delete(0,aS60Msg->Length());
for(int i=0;i<aQtMsg->length();i++)
aS60Msg->
Append((*aQtMsg)[i].unicode());
}
3:TDesC转为QString
char* ptrDes=(char*)aDes->Ptr();
for(int i=0;i<aDes->Length();i++)
{
*aChar=*ptrDes;
aChar++;
ptrDes+=2;
}
*aChar=
'/0';
}
还有一些其他的,暂时没想全,以后再补充。