现在的位置: 首页 > 综合 > 正文

Android 读取Assets中图片

2013年06月26日 ⁄ 综合 ⁄ 共 329字 ⁄ 字号 评论关闭
 
  bgimg0 = getImageFromAssetsFile("Cat_Blink/cat_blink0000.png");

     /**
     * 从Assets中读取图片
     */
    private Bitmap getImageFromAssetsFile(String fileName)
    {
        Bitmap image = null;
        AssetManager am = getResources().getAssets();
        try
        {
            InputStream is = am.open(fileName);
            image = BitmapFactory.decodeStream(is);
            is.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

        return image;

    }

抱歉!评论已关闭.