比如,图象文件 File imageFile = new File("E:\\200704\\CIMG0690.JPG");
我想根据此信息,知道执行以下代码将要占用的内存,确切的说,就是想知道,图象的内存分配方法,必须要再下边代码执行前知道,谢谢.Image image = new ImageIcon(imageFile.getAbsolutePath()).getImage();我本人知道用以下方法可以知道,但都是执行后才知道,而且是侧面知道,所以这样满足不了我的要求,谢谢,希望高手帮忙下:
File imageFile = new File("E:\\200704\\CIMG0690.JPG");
long start = Runtime.getRuntime().freeMemory();
Image image = new ImageIcon(imageFile.getAbsolutePath()).getImage();
long end = Runtime.getRuntime().freeMemory();
long difference = end-start ;
System.out.println( "difference:" + difference );
我想根据此信息,知道执行以下代码将要占用的内存,确切的说,就是想知道,图象的内存分配方法,必须要再下边代码执行前知道,谢谢.Image image = new ImageIcon(imageFile.getAbsolutePath()).getImage();我本人知道用以下方法可以知道,但都是执行后才知道,而且是侧面知道,所以这样满足不了我的要求,谢谢,希望高手帮忙下:
File imageFile = new File("E:\\200704\\CIMG0690.JPG");
long start = Runtime.getRuntime().freeMemory();
Image image = new ImageIcon(imageFile.getAbsolutePath()).getImage();
long end = Runtime.getRuntime().freeMemory();
long difference = end-start ;
System.out.println( "difference:" + difference );
假设图片对象为img,则img在内存中的大小约为:
(每像素所占位数/8)*图片高度*图片宽度*帧数
(img.GetPixelFormatSize( img.PixelFormat)/8)*img.Width *img.Height*img.FrameDimensionsList.Length