到底该怎么读png图片啊!!!!

hfo38j58gt3hj 2008-04-18 04:58:59
我用DataNewL来读图片,为什么会不能显示呢。返回值是KErrUnderflow。
但我用这个图直接读却可以显示。到底为什么呢。求助!!!!!!!!!!!!!


_LIT8(MimeType, "image/png");
TInt err = file.Open(iFs, aFileName, EFileStream|EFileRead);
if(KErrNone == err)
{
TInt aSize = 0;
file.Size(aSize);
buffer = HBufC8::NewLC(aSize);
TPtr8 ptr(buffer->Des());
file.Read(ptr, aSize);
file.Close();
iImageDecoder = CImageDecoder:: DataNewL( iFs,ptr,MimeType);
}
CleanupStack::PopAndDestroy(buffer);
iBitmap = new (ELeave) CFbsBitmap();
TFrameInfo iFrameInfo=iImageDecoder->FrameInfo(0);
TRect rectOfImage = iImageDecoder->FrameInfo(0).iFrameCoordsInPixels;
TDisplayMode iFrameDisplayMode=iImageDecoder->FrameInfo(0).iFrameDisplayMode;
TInt error=iBitmap->Create(iImageDecoder->FrameInfo(0).iOverallSizeInPixels, iFrameDisplayMode);
iState = EDecoding;
iImageDecoder->Convert( &iStatus, *iBitmap,0);
SetActive();
...全文
660 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenziteng 2008-04-24
  • 打赏
  • 举报
回复
Hi,

我写程序测试过可以将本地.jpg/.png文件读到内存缓冲区里,然后用CImageDecoder:: DataNewL()创建解码器解码成CFbsBitmap对象显示。

如果需要这块代码可以给我发mail: chenziteng@163.com

Regards

Ziteng Chen
hfo38j58gt3hj 2008-04-22
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 caowenbin 的回复:]
iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(),aFileName,ImageType,CImageDecoder::EOptionAlwaysThread);

if (iFrame)
{
delete iFrame;
iFrame = NULL;
}
if (iMaskFrame)
{
delete iMaskFrame;
iMaskFrame = NULL;
}
iFrame = new(ELeave)CFbsBitmap();
iFrame->Create(iImageDecoder->FrameInfo(0).iOverallSizeInPixels,iImageDecoder->FrameInfo(0).iFrameDisplayMode);
iMask…
[/Quote]
我要的是DataNewL出的decoder,不是FileNewL出的。还有,你的意思是我必须创建mask?
文斌 2008-04-22
  • 打赏
  • 举报
回复
iImageDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(),aFileName,ImageType,CImageDecoder::EOptionAlwaysThread);

if (iFrame)
{
delete iFrame;
iFrame = NULL;
}
if (iMaskFrame)
{
delete iMaskFrame;
iMaskFrame = NULL;
}
iFrame = new(ELeave)CFbsBitmap();
iFrame->Create(iImageDecoder->FrameInfo(0).iOverallSizeInPixels,iImageDecoder->FrameInfo(0).iFrameDisplayMode);
iMaskFrame = new(ELeave)CFbsBitmap();
iMaskFrame->Create(iImageDecoder->FrameInfo(0).iOverallSizeInPixels,EGray256);
TRequestStatus status;
iImageDecoder->Convert(&status,*iFrame,*iMaskFrame,0);
User::WaitForRequest(status);
hfo38j58gt3hj 2008-04-22
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 isarc 的回复:]
if( iStatus == KErrNone )
{
//
break;
}
else if( iStatus == KErrUnderflow )
{
iImageDecoder->ContinueConvert( &iStatus );
SetActive();
break;
}


他不是告诉你了吗?还有什么问题?
[/Quote]

我明白KErrUnderflow是什么意思,但我想知道到底是哪里的问题。同样的图片换了个方法却不可以运行。明白吗?
Walker-cheng 2008-04-22
  • 打赏
  • 举报
回复
很多图片转换工具都支持png格式数据
hfo38j58gt3hj 2008-04-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lspo816 的回复:]
sdk这样解释
If the plugin decoder has to be determined from the image header, but not enough of the image header is already loaded, DataNewL() leaves with KErrUnderflow.
When converting the operation can complete with KErrUnderflow, if there is insufficient information in the descriptor. In this situation, ContinueConvert() should be called repeatedly until the descriptor has accumulated enoug…
[/Quote]
ContinueConvert 是跳到下一张图。
hfo38j58gt3hj 2008-04-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 JWZbskywz 的回复:]
CPictureLoader* CPictureLoader::NewL( RFs& aFs )
{
CPictureLoader* self = new(ELeave) CPictureLoader(aFs);
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
return self;
}

CPictureLoader::CPictureLoader( RFs& aFs ) : iFs(aFs)
{
}

CPictureLoader::~CPictureLoader()
{
}

void CPictureLoader::ConstructL()
{
}


TInt CPictureLoader::LoadL( const TDesC…
[/Quote]
你这是用文件路径做的。我需要的是用数据做。文件路径的我这没问题。谢谢!
isarc 2008-04-21
  • 打赏
  • 举报
回复
if( iStatus == KErrNone )
{
//
break;
}
else if( iStatus == KErrUnderflow )
{
iImageDecoder->ContinueConvert( &iStatus );
SetActive();
break;
}


他不是告诉你了吗?还有什么问题?
hfo38j58gt3hj 2008-04-21
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 Atoric 的回复:]
刚刚看了一下SDK HELP
里面说是:
Format:PNG (Portable Network Graphics)
Encode support:No transparency
Decode support:Bitmap mask support
就没想法去尝试了。
我觉得花大量时间去从代码的角度来解决这个问题,是不是花少量时间把想要的图片的格式转换一下好些
[/Quote]
别的格式因为文件比较大。不适合我现在的想法。
Atoric 2008-04-21
  • 打赏
  • 举报
回复
刚刚看了一下SDK HELP
里面说是:
Format:PNG (Portable Network Graphics)
Encode support:No transparency
Decode support:Bitmap mask support
就没想法去尝试了。
我觉得花大量时间去从代码的角度来解决这个问题,是不是花少量时间把想要的图片的格式转换一下好些
hfo38j58gt3hj 2008-04-21
  • 打赏
  • 举报
回复
Have any one help me?
轻轻 2008-04-19
  • 打赏
  • 举报
回复
Symbian的SDK有一个操作png图片例子,看一下,研究一下,好像是在S60 3rd FP1中



------------------------------------------------------------------------
移软Symbian培训中心
http://www.symbian-training.com.cn
lspo816 2008-04-19
  • 打赏
  • 举报
回复
sdk这样解释
If the plugin decoder has to be determined from the image header, but not enough of the image header is already loaded, DataNewL() leaves with KErrUnderflow.
When converting the operation can complete with KErrUnderflow, if there is insufficient information in the descriptor. In this situation, ContinueConvert() should be called repeatedly until the descriptor has accumulated enough information for ContinueConvert() to complete with KErrNone.

所示,你在返回KErrUnderflow的时候尝试调用ContinueConvert
if( iStatus == KErrNone )
{
//
break;
}
else if( iStatus == KErrUnderflow )
{
iImageDecoder->ContinueConvert( &iStatus );
SetActive();
break;
}
JWZbskywz 2008-04-18
  • 打赏
  • 举报
回复
CPictureLoader* CPictureLoader::NewL( RFs& aFs )
{
CPictureLoader* self = new(ELeave) CPictureLoader(aFs);
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
return self;
}

CPictureLoader::CPictureLoader( RFs& aFs ) : iFs(aFs)
{
}

CPictureLoader::~CPictureLoader()
{
}

void CPictureLoader::ConstructL()
{
}


TInt CPictureLoader::LoadL( const TDesC& aFileName, CFbsBitmap* aBitmap, CFbsBitmap* aMask )
{
if( !BaflUtils::FileExists( iFs, aFileName ) )
{
return KErrNotFound;
}

CMdaImageFileToBitmapUtility* util;
util = CMdaImageFileToBitmapUtility::NewL( *this ) ;

CleanupStack::PushL( util );

util->OpenL( aFileName );
CActiveScheduler::Start();

TFrameInfo frameInfo;
util->FrameInfo( 0, frameInfo );

User::LeaveIfError( aBitmap->Create( frameInfo.iOverallSizeInPixels, EColor64K ));

TInt err = aMask->Create( frameInfo.iOverallSizeInPixels, EGray256 );
if( KErrNone == err )
{
util->ConvertL( *aBitmap, *aMask );
CActiveScheduler::Start();
}

//aBitmap = iBitmap;

CleanupStack::PopAndDestroy( util );

return KErrNone;

}

void CPictureLoader::MiuoConvertComplete( TInt aError )
{
CActiveScheduler::Stop();
}

void CPictureLoader::MiuoCreateComplete( TInt aError )
{
}

void CPictureLoader::MiuoOpenComplete( TInt aError )
{
CActiveScheduler::Stop();
}


这是我的,里面包括生产蒙版
hfo38j58gt3hj 2008-04-18
  • 打赏
  • 举报
回复
这里就没有会的人吗?这是世纪技术难点吗?到处看见人在问这个!没答案!

3,119

社区成员

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

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