Incorrect rotation of the image ( iOS 12 )
Incorrect rotation of the image ( iOS 12 )
library versions
"gl-react": "^3.14.0",
"gl-react-image": "^3.1.1",
"gl-react-native": "^3.14.0",
"react-native-webgl": "^0.8.0"
Expected behavior
Image is properly shown and not rotated, works similarly as native
Actual behavior
Image is rotated.
Steps to reproduce the behavior
Hi,
I use a camera ( see the link: https://github.com/react-native-community/react-native-camera ).
After it I managed to insert a link to the local file ( ie file:// ), using two options:
<Surface style={{width: 300, height: 400}}>
<Saturate {...filterProps}>
{{ image : { uri: photoUri }}}
</Saturate>
</Surface>
or
<Surface style={{width: 300, height: 400}}>
<Saturate {...filterProps}>
<GLImage source={{ image : { uri: photoUri }}} height={300} width={400}/>
</Saturate>
</Surface>
In both cases an image is rotated. If I use standard
Any clues? Thank you.
@Orxcle-xx Can I assume both cases use the same orientation? Portrait or landscape? It would also be helpful to see the code for your
With the above assumptions my guess is that you need to rotate the image according to it's orientation. This can be done inside the shader.
Here is some example code from one of my projects
vec3 ouv;
if (resolution.y > resolution.x) {
float flipY = 1.0 - uv.y;
ouv = vec3(flipY, uv.x, 0);
} else {
ouv = vec3(uv.x, uv.y, 0);
}
vec4 c = texture2D(backgroundImage, vec2(ouv.x, ouv.y));
Note that the above first switches the x and y values for the uv according to orientation and because portraits always come out upside-down I simply flip that across the Y axis.
@Orxcle-xx I updated by answer on anther thread you made but for reference, please try and shrink your image, the rotation issue should go away.
I'm also having the exact same issue, has anyone found a solution yet?
What you can do is flip the camera stream, the data of the image stream are yflipped but this is possible to do this:
https://github.com/gre/gl-react/blob/master/examples/cookbook-rn-shared/examples/camera/GLCamera.js
and
https://github.com/gre/gl-react/blob/master/examples/cookbook-rn-shared/examples/camera/index.js