【发布时间】:2011-10-20 03:52:15
【问题描述】:
我正在尝试将我的计算机文件夹图像加载到缩略图墙上。我从另一个论坛读到on a thread ImageView "url" 实例变量不支持系统路径。我尝试了那里的解决方案,但它引发了异常:java.lang.OutOfMemoryError: Java heap space as it keeps reading the file。
另一个问题是它一直在警告我使用包 javafx.ext -> SwingUtils.toFXImage 方法。
我也试过这样输入网址:
"file://localhost//Users/USER/Pictures/Camera/test/1.JPG"
我尝试显示多张图片,但总是只显示 3 到 4 张图片。
我检查了ImageView给出的错误函数,它并不表示我的图像读取遇到了错误。
还有其他选择吗?
代码
function load() {
println("RUNTIME {Runtime.getRuntime().maxMemory()}");
System.gc();
Runtime.getRuntime().freeMemory();
//MAC Folder PATH
var path: String = "/Users/username/Pictures/camera/test/1.JPG";;
var file: File = new File(path);
//http://download.oracle.com/docs/cd/E17802_01/javafx/javafx/1.3/docs/api/javafx.ext.swing/javafx.ext.swing.SwingUtils.html
//public toFXImage(image: java.awt.image.BufferedImage) : Image
//Creates a JavaFX Image from a BufferedImage.
img = SwingUtils.toFXImage(ImageIO.read(file));
}
【问题讨论】: