为什么有些图像在 javafx ImageView 中显示时会旋转?

问题描述 投票:0回答:0

960x1280 的图像水平旋转。 我怎样才能强迫他们保持垂直?

ScrollPane sp = new ScrollPane();
sp.setPrefSize(900, 700);

public void showPicture(String str){
  try{
            
             
            File file = new File("pictures\\"+str+".jpg");
            Image image = new Image(file.toURI().toString());
            
            if(image.getWidth()>900)
            {
                Double x=image.getWidth();
                Double y=image.getHeight();
                Double z=x/900;
                if((y/z)>700)
                {
                    z=y/700;
    
                }
                
                
                image = new Image(file.toURI().toString(),x/z,y/z,false,false);
            }
            
            
            
                ImageView imageView = ImageViewBuilder.create()
                .image(image)
                .build();
                
                
                sp.setContent(imageView);
                
   }catch(Exception e){System.err.println(e);}
}

我试图将 ScrollPane 更改为 700x700,但没有用。 它只发生在 960x1280 的图片上,其他图片显示正常。 文件夹里的图片是竖着的

java image javafx imageview scrollpane
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.