如何在ImageView中显示压缩图像并显示其大小? [英] How do I display the Compressed image in ImageView and display its Size?
本文介绍了如何在ImageView中显示压缩图像并显示其大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ContentResolver resolver = getContentResolver();
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "Image" + timestamp + ".jpg");
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/*");
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_PICTURES + File.separator + "Compressed_Images");
imageUri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
fos = resolver.openOutputStream(Objects.requireNonNull(imageUri));
bitmap.compress(WEBP_LOSSY, 10, fos);
Objects.requireNonNull(fos);
让它显示在imageview中------>
Got it displayed in imageview------>
InputStream is = getContentResolver().openInputStream(imageUri);
Bitmap bitmap1 = BitmapFactory.decodeStream(is);
compImage.setImageBitmap(bitmap1);
它压缩并保存图像没有问题
Its Compressing and saving the Image No issue in that
推荐答案
InputStream is = getContentResolver().openInputStream(imageUri);
Bitmap bitmap1 = BitmapFactory.decodeStream(is);
compImage.setImageBitmap(bitmap1);
好的....我设法在Imageview中设置了图像(希望它是压缩图像)现在我如何得到它的大小?
Okay....I was managed to set image in Imageview(I hope its Compressed image) Now how do I get the size of this?
这篇关于如何在ImageView中显示压缩图像并显示其大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文