全部分奉上:如何用server端发过来的bytes构造一个图片

dongfengsun 2007-01-31 05:01:14
Symbian中有什么方法能用server端发过来的bytes构造一个图片,
server端放送过来的是一张jpg图片的bytes.

我接收过来并存放在一个HBufC8中

如果用这个HBufC8构造一张图片!

我知道有CImageEncoder这个类

但是不知道具体该如何构造?

谁有这方面的例子吗?
...全文
400 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
UltraBejing 2008-05-01
  • 打赏
  • 举报
回复
这个简单啊,网上搜一下就得到答案了.
isarc 2008-04-07
  • 打赏
  • 举报
回复
Atoric 你好厉害呀。

到今天也没给分。人品啊。
isarc 2008-04-07
  • 打赏
  • 举报
回复
Atoric 你好厉害呀。

到今天也没给分。人品啊。
Atoric 2008-04-02
  • 打赏
  • 举报
回复
这里是图片转换代码:

void CMyController::ImageReady()
{
if(iBitmap)
{
delete iBitmap;
iBitmap = NULL;
}
if(!iImageDecoder)
{
iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(), iEngine->PicFileName());
}
if(!IsActive())
{
iBitmap = new(ELeave)CFbsBitmap();
TDisplayMode displayMode = EColor16M;
iBitmap->Create( iImageDecoder->FrameInfo(0).iOverallSizeInPixels, displayMode);
iImageDecoder->Convert(&iStatus, *iBitmap);
SetActive();
}
}

void CMyController::RunL()
{
if(iImageDecoder)
{
delete iImageDecoder;
iImageDecoder = NULL;
}
//这里图片转换OK
}
Atoric 2008-04-02
  • 打赏
  • 举报
回复
保存图片文件代码(用的是HTTP),希望能帮上忙:


void CHTTPEngine::MHFRunL(RHTTPTransaction aTransaction,
const THTTPEvent& aEvent)
{
switch(aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
{
RHTTPResponse resp = aTransaction.Response();

TInt statusCode = resp.StatusCode();
if(statusCode == 200)
{
if(iState==EGettingPicture) //自己定义的
{
User::LeaveIfError(iFs.Connect());
if (BaflUtils::FileExists( iEikEnv->FsSession(),iFileName) )
iFile.Replace(iFs,iFileName,EFileWrite);
else
iFile.Create(iFs,iFileName,EFileWrite);
}
}
else //这里是网络异常处理,省略
{
}
}
break;
case THTTPEvent::EGotResponseBodyData:
{
MHTTPDataSupplier* body = aTransaction.Response().Body();
TPtrC8 ptr;
iIsLast = body->GetNextDataPart(ptr);

if(iState==EGettingPicture)
{
TInt index = 0;
iFile.Seek(ESeekEnd,index);
iFile.Write(index,ptr);
if(iIsLast)
{
iFile.Close();
iFs.Close();

iController.ImageReady(); //这里调用函数转换图片->CFbsBitmap
}
}
else
{
HBufC* buf = HBufC::NewLC(ptr.Length());
buf->Des().Copy(ptr);
if(!iResponseBuffer)
iResponseBuffer = buf->AllocL();
else
{
iResponseBuffer = iResponseBuffer->
ReAllocL(iResponseBuffer->Length()+buf->Length());
iResponseBuffer->Des().Append(*buf);
}
CleanupStack::PopAndDestroy(buf);
}

body->ReleaseData();
}
……
)
Atoric 2008-04-02
  • 打赏
  • 举报
回复
做过类似的东西,我是这样实现的:
1、直接将获取到的数据保存到JPG格式的文件;
2、再用CImageDecoder将文件转化为CFbsBitmap用来在手机上显示;
这样实现也是比较简单的,这样做的另一个好处就是下回可以不用在获取相同的数据了。

另外,还有一种是从数据(data)直接转为CFbsBitmap格式的,没有用过,不敢妄言
lanzihe 2008-04-02
  • 打赏
  • 举报
回复
还是不太懂
matchboy 2008-03-16
  • 打赏
  • 举报
回复
可以用CImageDecoder::DataNewL吧。
yiekai 2007-02-05
  • 打赏
  • 举报
回复
TBuf<400> tmp(aFolderUrl->Des());
tmp.Append(((HBufC16*)(ImageCach[localArrayIndex].pPath))->Des());
//this->FormatFileNameIn(tmp);
//pDecoder = CImageDecoder::FileNewL(fsSession, tmp);
TRAPD(errormsg, pDecoder = CImageDecoder::FileNewL(iFs, tmp));

if (NULL == pDecoder)
{
return;
}

TFrameInfo frmInfo = pDecoder->FrameInfo(0);
TRect rectOfImage = frmInfo.iFrameCoordsInPixels;

pDecoder->Convert(&iStatus, *(pImage));
SetActive();
yiekai 2007-02-05
  • 打赏
  • 举报
回复
可以使用nokia的那个图片例子,一个是用dataconvert,直接拿图片二进制数据转。还有一个就是先缓存成图片文件,之后用fileconvert都挺好用的。
anel 2007-02-01
  • 打赏
  • 举报
回复
可参考Examples\multimedia
chenziteng 2007-02-01
  • 打赏
  • 举报
回复
类似下面这贴中的小广告:

http://community.csdn.net/Expert/topic/5303/5303715.xml?temp=.2773859

不知道是发广告的人良心发现自己删了还是版务发威删了。
ManZY 2007-02-01
  • 打赏
  • 举报
回复
小广告?
chenziteng 2007-01-31
  • 打赏
  • 举报
回复
给我发邮件获取一份符合你要求的示例程序: chenziteng@163.com

顺便鄙视楼上乱发小广告。

3,119

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧