且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Glide破坏图像质量加载图像

更新时间:2023-02-13 22:58:40

要使用Glide加载原始图像,请使用以下代码:

To load the original image using Glide I use the code below:

  Glide.with(view.getContext())
                    .load(pictureFile)
                    .asBitmap()
                    .into(new SimpleTarget<Bitmap>(Target.SIZE_ORIGINAL,Target.SIZE_ORIGINAL) {
                        @Override
                        public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
                            imageView.setImageBitmap(resource);
                        }
                    });

请记住,由于设备的屏幕分辨率,浏览器中的图片在设备上可能看起来有所不同.使用此方法,您将可以使用Bitmap对象检查像素. 另外,请记住,您的ImageView必须具有widthheight且具有WRAP_CONTENT值.

Remember that the picture in browser may look different on the device due to the screen resolution of your device. Using this method you will be able to check the pixels using the Bitmap object. Also, keep in mind that your ImageView must have width and height with WRAP_CONTENT value.