Skip to content

Commit b26273c

Browse files
committed
feat(PixelRatio): Added PixelRatio to set pixel density
1 parent f4148aa commit b26273c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ yarn add react-native-image-cropper
2929
- `pinchToZoom` Use pinch to zoom image? (default: true)
3030
- `quality`: a value from 0 to 1 to describe the quality of the snapshot. 0 means 0% (most compressed) and 1 means 100% (best quality). (default: 1)
3131
- `type`: the file type default value is **"png"**, **"jpg"** is also supported. Refer to implementations to see more supported values. (default: jpg)
32+
- `pixelRatio`: the pixel ratio to use for the rendering. By default the screen pixel scale will be used.
3233

3334
#### `{ImageCrop}` Functions
3435
- `crop()`: returns a base64 encoded image.

src/ImageCrop.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react'
22
import {
33
View,
44
Image,
5+
PixelRatio,
56
PanResponder
67
} from 'react-native'
78

@@ -177,7 +178,7 @@ class ImageCrop extends Component {
177178
render() {
178179
return (
179180
<View {...this._panResponder.panHandlers}>
180-
<Surface width={this.props.cropWidth} height={this.props.cropHeight} ref="cropit">
181+
<Surface width={this.props.cropWidth} height={this.props.cropHeight} pixelRatio={this.props.pixelRatio} ref="cropit">
181182
<GLImage
182183
source={{ uri: this.props.image}}
183184
imageSize={{height: this.state.imageHeight, width: this.state.imageWidth}}
@@ -201,6 +202,7 @@ ImageCrop.defaultProps = {
201202
minZoom: 0,
202203
maxZoom: 100,
203204
quality: 1,
205+
pixelRatio: PixelRatio.get(),
204206
type: 'jpg',
205207
format: 'base64',
206208
}
@@ -212,6 +214,7 @@ ImageCrop.propTypes = {
212214
maxZoom: React.PropTypes.number,
213215
minZoom: React.PropTypes.number,
214216
quality: React.PropTypes.number,
217+
pixelRatio: React.PropTypes.number,
215218
type: React.PropTypes.string,
216219
format: React.PropTypes.string,
217220
}

0 commit comments

Comments
 (0)