Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with dimension!, very big size compared to the original #251

Open
luigbren opened this issue Jun 11, 2020 · 2 comments
Open

problem with dimension!, very big size compared to the original #251

luigbren opened this issue Jun 11, 2020 · 2 comments
Labels

Comments

@luigbren
Copy link

luigbren commented Jun 11, 2020

Hello friends, I'm having problems at the moment of capturing the change made with a selected filter, the dimensions of the new image are much bigger than the original..

import { Surface } from 'gl-react-native';
import GLImage from 'gl-react-image'
import....
.....

//mobwidth = 411.428
//responHeigh of this file = 731.428
<View style={{ alignItems: 'center', justifyContent: 'center', width: mobwidth, height: responHeigh }}>
    <Surface
        ref={ref => this.SurfaceRef = ref}
        style={{ width: mobwidth, height: responHeigh }}
    >
        <Valencia>
            <GLImage style={{ width: mobwidth, height: responHeigh }} source={{ uri: this.props.route.params.datimag[0].uri }} />
        </Valencia>
    </Surface>
</View>

onPress={() => this.saveFilters()

    saveFilters = async () => {
        let fiwidth = this.props.route.params.datimag[0].width     
        let fiheigh = this.props.route.params.datimag[0].height   

        const result = await this.SurfaceRef.glView.capture();
        console.log(fiwidth);  // Image orig: 1080
        console.log(fiheigh);  // Image orig: 1920
        console.log(result);

result is: 
{"height": 2560, 
"localUri": "file:///data/user/0/com.myapp/cache/GLView/640ad8e1-7470-465c-9e95-21b546ec512e.jpeg", 
"uri": "file:///data/user/0/com.myapp/cache/GLView/640ad8e1-7470-465c-9e95-21b546ec512e.jpeg", 
"width": 1440}

}

I don't understand why the resulting dimensions are so much larger than the original dimensions,
How can I keep the dimension of the original image?, just in case I leave the code of Valencia.js
https://github.com/beqaweb/gl-react-native-filters/blob/master/filters/Valencia.js

@luigbren luigbren changed the title problem with dimensiones! problem with dimension!, very big size compared to the original Jun 12, 2020
@gre
Copy link
Owner

gre commented Dec 23, 2020

Are you sure it's not due to the fact the phone have a pixel ratio that multiplies the surface's point dimension 🤔

@gre gre added the question label Dec 23, 2020
@mrwerner392
Copy link

@gre Is there a way to override the device's pixel ratio with the react native surface? It looks like the PixelRatio prop is only available for the react DOM surface. I want to capture the surface and maintain the original image dimensions, but for larger images the screen is too small to show a large enough surface. I want to maintain the original dimensions because I need to maintain the printing quality of these images.

As a workaround I am currently rendering a second, off-screen surface with the appropriate dimensions. This seems to work well enough, but I do have concerns about the performance potentially dropping off with multiple canvases updating at the same time.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants