@@ -29,7 +29,7 @@ export class SelectedAsset extends observable.Observable {
29
29
return Promise . reject ( new Error ( "Not implemented." ) ) ;
30
30
}
31
31
32
- getImage ( options ?) : Promise < imagesource . ImageSource > {
32
+ getImage ( options ?: { maxWidth : number , maxHeight : number } ) : Promise < imagesource . ImageSource > {
33
33
return new Promise < imagesource . ImageSource > ( ( resolve , reject ) => {
34
34
try {
35
35
resolve ( this . decodeUri ( this . _uri , options ) ) ;
@@ -123,9 +123,7 @@ export class SelectedAsset extends observable.Observable {
123
123
} ;
124
124
125
125
// Decode with scale
126
- var downsampleOptions = new BitmapFactory . Options ( ) ;
127
- downsampleOptions . inSampleSize = this . getSampleSize ( this . _uri , REQUIRED_SIZE ) ;
128
- this . _thumb = this . decodeUri ( this . _uri , downsampleOptions ) ;
126
+ this . _thumb = this . decodeUri ( this . _uri , REQUIRED_SIZE ) ;
129
127
this . notifyPropertyChange ( "thumb" , this . _thumb ) ;
130
128
}
131
129
@@ -135,7 +133,7 @@ export class SelectedAsset extends observable.Observable {
135
133
* @param uri The URI of the image that should be scaled.
136
134
* @param options The options that should be used to produce the correct image scale.
137
135
*/
138
- private getSampleSize ( uri : android . net . Uri , options ?) : number {
136
+ private getSampleSize ( uri : android . net . Uri , options ?: { maxWidth : number , maxHeight : number } ) : number {
139
137
var boundsOptions = new BitmapFactory . Options ( ) ;
140
138
boundsOptions . inJustDecodeBounds = true ;
141
139
BitmapFactory . decodeStream ( this . openInputStream ( uri ) , null , boundsOptions ) ;
@@ -168,8 +166,10 @@ export class SelectedAsset extends observable.Observable {
168
166
* @param uri The URI that should be decoded into an ImageSource.
169
167
* @param options The options that should be used to decode the image.
170
168
*/
171
- private decodeUri ( uri : android . net . Uri , options : android . graphics . BitmapFactory . Options ) : imagesource . ImageSource {
172
- var bitmap = BitmapFactory . decodeStream ( this . openInputStream ( uri ) , null , options ) ;
169
+ private decodeUri ( uri : android . net . Uri , options ?: { maxWidth : number , maxHeight : number } ) : imagesource . ImageSource {
170
+ var downsampleOptions = new BitmapFactory . Options ( ) ;
171
+ downsampleOptions . inSampleSize = this . getSampleSize ( uri , options ) ;
172
+ var bitmap = BitmapFactory . decodeStream ( this . openInputStream ( uri ) , null , downsampleOptions ) ;
173
173
var image = new imagesource . ImageSource ( ) ;
174
174
image . setNativeSource ( bitmap ) ;
175
175
return image ;
0 commit comments