【问题标题】:Retrieving a jpg image via fileUri通过 fileUri 检索 jpg 图像
【发布时间】:2013-01-24 08:27:21
【问题描述】:

我需要一些帮助。我想知道是否有办法从 fileUri 中检索 jpg 照片对象。

我基本上在使用一个 API,其中所需的参数是照片对象 (jpg)。 我不需要以缩略图等形式显示或显示任何内容。

只需将 jpg 文件传入 API。

一些示例代码会很有帮助!

请协助:) 谢谢!

【问题讨论】:

    标签: android android-layout android-intent android-emulator android-widget


    【解决方案1】:

    不了解您的 API,但如果您可以传递位图,那么您可以使用它 -

    public static Bitmap getImagefromURL(String url) {
        HttpURLConnection connection  = (HttpURLConnection) url.openConnection();
        InputStream is = connection.getInputStream();
        Bitmap img = BitmapFactory.decodeStream(is);  
        return img;
     }
    

    然后就可以把位图转成jpg了... bmp to jp

    【讨论】:

    • 我用另一种方式做到了。将位图更改为 Base 64 字符串。感谢您的帮助。
    【解决方案2】:

    检索位图格式的图像 将位图转换为字节数组 通过编码将字节数组转换为base64字符串。

    在 api 中传递字符串。服务器需要将其解码回图像文件。

    【讨论】:

      猜你喜欢
      • 2011-09-06
      • 2010-11-03
      • 2014-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多