不能得到的文件描述符资产 [英] Can't get File Descriptor for asset

查看:117
本文介绍了不能得到的文件描述符资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要得到一个DAE文件的文件描述符,这样我就可以开始偏移量和长度。我有文件描述符PNG文件,它做工精细。我用这个code这样做。

I need to get a file descriptor for a dae file, so I can get the Start Offset and Length. I have got file descriptors for png files, which work fine. I did this by using this code.

int id = 0;
id = getResources().getIdentifier("duck", "drawable", getPackageName());
mAssetDescriptor = getResources().openRawResourceFd(id);

就像我说的,我的PNG的这个工作得很好,我的DA​​E的,但是,这并不工作,我得到了以下异常:

Like I said, for my png's this worked fine, for my dae's, however, this did not work, I got the following exception:

android.content.res.Resources $ NotFoundException:
  从文件RES /绘制/ duck.dae
  绘制资源ID#0x7f020030

android.content.res.Resources$NotFoundException: File res/drawable/duck.dae from drawable resource ID #0x7f020030

mAssetDescriptor为null。

mAssetDescriptor was null.

于是,我就做另一种方式。我把我的DAE文件的文件夹资产

So I tried to do another way. I put my dae files in the assets folder

mAssetDescriptor = getAssets().openFd("duck.dae");

这想出了一个错误

此文件不能打开一个文件
  描述;它可能是COM pressed。

This file can not be opened as a file descriptor; it is probably compressed.

我想知道的,是我怎么能获得起始偏移和文件长度不使用getFileDescriptor()和getStartOffset()函数,因为它似乎我不能使用这些。

What I would like to know, is how I can get the Start Offset and Length of the file without using the getFileDescriptor() and getStartOffset() functions, as it seems I can not use these.

我想这也没什么看头的DAE文件都在1MB,与duck.dae我试着在500K的时刻加载。

I guess it is also worth nothing the dae files are all under 1mb, with duck.dae which i'm trying to load at the moment at 500k.

非常感谢您的帮助。

汤姆

推荐答案

这可能适用于PNG图像,因为他们不是还COM pressed,而其他大多数文件。看到这个线程:的http://groups.google.com/group/android-ndk/browse_thread/thread/8274a4c51cc9cc1d

This probably works for pngs because they are not additionally compressed, while most other files are. See this thread: http://groups.google.com/group/android-ndk/browse_thread/thread/8274a4c51cc9cc1d

尝试添加和扩展您的文件,那prevents文件被COM pressed。

Try adding and extension to your files, that prevents file from being compressed.

这篇关于不能得到的文件描述符资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆