首页 > 解决方案 > 垂直图像作为水平图像加载

问题描述

我正在编写一个简单的应用程序,它基本上会加载一些图片并将它们显示给用户。问题是,当我初始化手机拍摄的垂直图像时,它无法识别图像是垂直的,只是交换了宽度和高度。

否则,如果我加载一个垂直图像,例如从互联网下载的,一切正常。

在这里,您可以看到我的应用程序和两张加载的图片。左边是下载的,垂直显示。但是用我的手机拍的那张不是垂直显示的。

这是我的课程/代码:

import javafx.scene.CacheHint;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class Picture {
    String name;
    String path;
    String res;
    String size;
    ImageView iv;
    Image image;

    public Picture(String name, String path) {
        this.image = new Image("file:" + path);
        this.name = name;
        this.path = path;
        this.res = image.getWidth() + " x " + image.getHeight();

        this.iv = new ImageView(image);
        this.iv.setFitHeight(180);
        this.iv.setFitWidth(180);
        this.iv.setPreserveRatio(true);
        this.iv.setCache(true);
        this.iv.setCacheHint(CacheHint.SPEED);
        this.iv.setStyle("-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 0);");
    }
}

这是我的第一个问题,所以不要责怪我的布局;)

感谢对我的代码或问题的任何反馈。如果您需要整个代码,请告诉我。

谢谢你的帮助

标签: javaimagejavafx

解决方案


推荐阅读