读书人

高分求相助:根据图象文件,如果知道该图

发布时间: 2011-11-22 23:46:19 作者: rapoo

高分求帮助:根据图象文件,如果知道该图象文件生成IMAGE对象时占用的内存,急.
比如,图象文件 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 );


[解决办法]
up

读书人网 >Java Web开发

热点推荐