您的位置:首页 > 移动开发 > Unity3D

从Android读取Unity assets下的图片并保存为Bitmap格式

2014-09-28 19:17 441 查看
        首先,在unity工程下,建立文件夹“Plugins/Android/assets”,然后把需要的图片放在这个文件夹下,并取一个好用的名字

("Logo.png"),这个名字在Android这边是需要用到的,unity的工作做完之后,在Android这边写代码:

AssetManager asm = getAssets();
InputStream inputStream = null;
try {
inputStream = asm.open("Logo.png");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Drawable d =Drawable.createFromStream(inputStream, null);
Bitmap B = ((BitmapDrawable) d).getBitmap();


        这样就完成了unity图片的读取与转化Bitmap。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unity android Bitmap