java - Given a javafx.scene.image.Image object rotate it and produce a rotated javafx.scene.image.Image object -


i have code create image: (m_img javafx.scene.image.image)

image m_img = new image("file:" + p_fil.getabsolutefile(),false); 

this fine, ignore exif tag_orientation pictures taken on phone in portrait mode not appear correct way up.

when change load method, able read tag , save result int (1-8) follows:

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 

if m_orientation 1 correct no further action required.

but need somehow transform image depending on number returned. (rotation, or flip etc.)

i think javafx.scene.transform.rotate class should me. can provide sample code given image object can output rotated image object.

you have rely on awt this:

i recommend having method:

public bufferedimage getrotatedimage(bufferedimage bufferedimage, int angle) {      affinetransform transform = new affinetransform();      transform.rotate(angle);      affinetransformop op = new affinetransformop(transform, affinetransformop.type_bilinear);      bufferedimage = op.filter(bufferedimage, null);      return bufferedimage; } 

then:

bufferedimage buffimg= swingfxutils.fromfximage(m_img, null); buffimg = getrotatedimage(buffimage, 90); //or other angle if needed m_img = swingfxutils.tofximage(buffimg, null); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -