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

very long image, ViewShot capture a blank image #265

Closed
Liaozhenting opened this issue Oct 11, 2019 · 6 comments
Closed

very long image, ViewShot capture a blank image #265

Liaozhenting opened this issue Oct 11, 2019 · 6 comments

Comments

@Liaozhenting
Copy link

Liaozhenting commented Oct 11, 2019

bug report

I want to capture a 9292 pixel height view, finally it is a blank. But if i change my code from 9292 to 4646. ViewShot works right.
And this is on the mobile phone , the simulator works but the captured image is blurry.
The origin image is 9292 pixel height , 750 pixel width.

Version

IOS 10
"react": "16.0.0-alpha.12",
"react-native": "0.48.4",
"react-native-view-shot": "2.4.0",

Platform: iOS , iPhone 6/6s/SE/X

Expected behavior

QQ20191011-172708@2x

Actual behavior

IMG_0313

Steps to reproduce the behavior

import React, { PureComponent } from "react";
import { View, StyleSheet, Image, PixelRatio } from "react-native";
import ViewShot from "react-native-view-shot";
const pxRatio = PixelRatio.get();

class Preview extends PureComponent {
  state={
    baseImageURL: 'http://clickeggsdev-10081362.file.myqcloud.com/1565861000245-ae3fe03d987243485026191875de8137/%E7%BA%BF%E4%B8%8A%E5%88%86%E5%8F%91%E5%9B%BE%E7%89%87-e47bb1a0-bf3e-11e9-a9c5-43eb9d096463.jpg'
  }
  render() {
    <ViewShot
      ref={ref => (this.ViewShot = ref)}
      options={{
        format: "jpg",
        quality: 1,
        result: "tmpfile"
      }}
    >
      <View style={styles.image}>
        <Image
          source={{ uri: baseImageURL }}
          style={[styles.image, { height: 9292 / pxRatio }]}
          onLoad={this.onBaseImageLoaded}
          onError={this.onImageLoadFailed}
        />
        {this.renderQRCode()}
      </View>
    </ViewShot>;
  }

  onBaseImageLoaded() {
    setTimeout(() => {
      this.ViewShot.capture().then(uri => {
        this.setState({ compositeImageURI: uri }, () => {});
      });
    }, 1000);
  }
}

const styles = StyleSheet.create({
  image: {
    width: 750 / pxRatio
  }
});
@Liaozhenting Liaozhenting changed the title very long image, ViewShot capture a blank view very long image, ViewShot capture a blank image Oct 11, 2019
@jile10
Copy link

jile10 commented Dec 5, 2019

Same issue in ios device

@gre
Copy link
Owner

gre commented Jan 19, 2020

I imagine we are reaching the limit of the phone / ios capabilities regarding image.

it would be great if we could show the problem in the example project.

@Liaozhenting
Copy link
Author

@gre Thanks. I have told users not to use such long pictures

@471595249
Copy link

Add "useRenderInContext" In options, it works, try it;
options={{
format: 'jpg',
quality: 1,
width: deviceWidth,
height: this.state.webViewHeight,
useRenderInContext: true
}}

@xiezzz
Copy link

xiezzz commented Jul 28, 2022

在options中加入“useRenderInContext”,就可以了,试试看; options={{ 格式:'jpg', 质量:1, 宽度:deviceWidth, 高度:this.state.webViewHeight, useRenderInContext:true }}

TypeScript: useRenderincontext does not exist in CaptureOptions

@babyrusa
Copy link

@471595249 When I use useRenderInContext: true, it does not save the elements that are position:"absolute" on top of my view. is there a way to save it?

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

No branches or pull requests

6 participants