【发布时间】:2014-05-02 00:30:31
【问题描述】:
我有创建图像的代码:(m_img is javafx.scene.image.Image)
Image m_img = new Image("file:" + p_Fil.getAbsoluteFile(),false);
这很好,但它确实忽略了 exif TAG_ORIENTATION,因此在手机上以纵向模式拍摄的照片不会以正确的方式显示。
当我更改加载方法时,我可以读取此标签并将结果保存到 int (1-8) 中,如下所示:
byte bb[] = FileUtilities.readFile(p_Fil);
getOrientation(new ByteArrayInputStream(bb),p_Fil);
m_img = new Image(new ByteArrayInputStream(bb));
if (m_orientation==1) return; //1 means no transformation required
如果 m_orientation 为 1,那么它是正确的,因此不需要进一步的操作。
但现在我需要根据返回的数字以某种方式转换图像。 (旋转、翻转等)
我认为 javafx.scene.transform.Rotate 类应该对我有所帮助。 任何人都可以提供示例代码,在给定图像对象的情况下,您可以输出另一个旋转的图像对象。
【问题讨论】:
-
迟了两年,但无论如何:
ImageView提供了setRotate方法。这会有帮助吗?
标签: java image javafx transform exif