仅使用图像名称获取字节数组 [英] Getting the Byte Array using just the image name

查看:90
本文介绍了仅使用图像名称获取字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷入困境.我在drawable文件夹中有一组10张图像.在我的代码中,我只有图像名称.例如"elephant.png",我希望图像的 byte数组与图像名称相对应.

I am stuck in a situation. I have some set of 10 images in drawable folder. During my code I have just the image name. for e.g "elephant.png" and I want the byte array of the image( drawable ) corressponding to image name.

String imageName = getResources().getResourceEntryName(GroupIconAdapter.mThumbIds[position]);

从这里我得到图像名称,我想要字节数组.

From here I get the image name and I want byte array.

有可能吗?

谢谢

推荐答案

将此图像放入assests目录中,您可以通过这种方式进行访问

Put this images into your assests directory and you can access like this way

String url = "file:///android_asset/elephant.png";

这篇关于仅使用图像名称获取字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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