【问题标题】:Samsung s4 and s3 difference bitmap decodeStream三星s4和s3区别位图decodeStream
【发布时间】:2014-04-10 11:46:42
【问题描述】:

三星 S4

三星 S3

我从网站下载图像并将它们保存到 SD 卡。当我使用 samsung s3 时,一切都是正常的图像被缩放并且宽度是 match_parent 但是当我使用 samsung s4 图像的宽度是 maxmımum 这个尺寸时,我从 sd 卡读取图像时检查图像的宽度和高度,这些是相同的,没有区别 samsung s3 和 s4。我用于从 sd 卡读取图像的代码

String root = Environment.getExternalStorageDirectory().toString();
            File myDir = new File(root + "/sample");    
            myDir.mkdirs();

            String fname = "Image_"+ ana.haberBanner.get(position).getId() +".jpg";

            File file = new File (myDir, fname);
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
                    Bitmap bitmap = null;
                    try {
                        bitmap = BitmapFactory.decodeStream(new FileInputStream(file), null, options);
                    } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }



            haberResim.setImageBitmap(bitmap);

这段代码运行正常。

【问题讨论】:

    标签: android bitmap bitmapfactory


    【解决方案1】:

    图像似乎比ImageView 小(S4 屏幕上有更多像素)。为您的ImageView 设置一个适当的scaleTypeFIT_XY 应该可以解决问题)。

    【讨论】:

    • 对于 imageview 来说没问题,但我正在使用 fancycoverflow 来制作轮播动画图像。我尝试了同样的事情但没有受到影响:/
    【解决方案2】:

    喜欢不容易,但它是:/

    bMapScaled = Bitmap.createScaledBitmap(bimages2.get(i), dpToPx(340), dpToPx(200), true);
    

    【讨论】:

      猜你喜欢
      • 2015-08-03
      • 1970-01-01
      • 2015-02-15
      • 1970-01-01
      • 2013-10-30
      • 2012-08-28
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多