Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从imageview(android)获取以字节为单位的图像大小_Android_Image_Imageview_Image Size - Fatal编程技术网

如何从imageview(android)获取以字节为单位的图像大小

如何从imageview(android)获取以字节为单位的图像大小,android,image,imageview,image-size,Android,Image,Imageview,Image Size,我正在开发一个壁纸应用程序,在该应用程序中,我从GridView和全屏图像视图中的Picasa Web Album接收图像 我想使用图像字节大小保存ImageView加载的图像,以防止重复保存,但我不知道如何从ImageView获取图像字节大小` 这是我的代码: int intHeight = fullImageView.getHeight(); int intWidth = fullImageView.getWidth();

我正在开发一个壁纸应用程序,在该应用程序中,我从
GridView
全屏图像视图中的Picasa Web Album接收图像

我想使用
图像字节大小保存
ImageView
加载的图像,以防止重复保存,但我不知道如何从ImageView获取图像字节大小`

这是我的代码:

int intHeight = fullImageView.getHeight();
            int intWidth = fullImageView.getWidth();                    

            String dirname2 = "/Amazing Wallpapers HD/";

            File myDir2 = new File(Environment.getExternalStorageDirectory()
                    .getPath() + dirname2);

            myDir2.mkdirs();

            String fname2 = "image" + intHeight+ intWidth +".jpeg";
            File file2 = new File(myDir2, fname2);

            if (file2.exists())
                file2.delete();
            try {
                FileOutputStream out = new FileOutputStream(file2);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
                out.flush();
                out.close();

            } catch (Exception e) {
                Toast.makeText(_context, "failed", Toast.LENGTH_SHORT).show();
            }

注意:我问的是图像的大小,以字节或千字节为单位。

如果您使用的是Picasa,您只需获得照片描述,它将为您提供许多独特的功能,以便在工作中使用:

photo.getDescription().getPlainText()

您将找到更多详细信息。

您可以使用BitmapFactory。选项。它只提取图像的元数据,而不是整个图像。你应该能够从那里获得足够的数据,以确保你不会有重复。 进一步阅读: