@@ -53,16 +53,16 @@ public TiBlob resize(TiBlob blob){
53
53
54
54
@ Kroll .method
55
55
public TiBlob resizeTo (TiBlob blob , KrollDict args ){
56
- int width = args .optInt ("width" , 320 ).intValue ();
57
- int height = args .optInt ("height" , 480 ).intValue ();
58
- boolean keepAspect = args .optBoolean ("keepAspect" , true );
59
- String mimeType = args .optString ("mimeType" , MIME_JPEG );
56
+ final int width = args .optInt ("width" , 320 ).intValue ();
57
+ final int height = args .optInt ("height" , 480 ).intValue ();
58
+ final boolean keepAspect = args .optBoolean ("keepAspect" , true );
59
+ final String mimeType = args .optString ("mimeType" , MIME_JPEG );
60
60
61
61
return resizeFromBlob (blob , width , height , keepAspect , mimeType );
62
62
}
63
63
64
64
private TiBlob compress (Bitmap bitmap , CompressFormat format , String mimeType ){
65
- ByteArrayOutputStream out = new ByteArrayOutputStream ();
65
+ final ByteArrayOutputStream out = new ByteArrayOutputStream ();
66
66
if (bitmap .compress (format , 80 , out )){
67
67
return TiBlob .blobFromData (context , out .toByteArray (), mimeType );
68
68
}
@@ -90,12 +90,14 @@ private TiBlob resizeFromBlob(TiBlob blob, int width, int height, boolean keepAs
90
90
}
91
91
92
92
private Bitmap resizeToSize (Bitmap bitmap , int targetWidth , int targetHeight , boolean preserveAspectRatio ){
93
- final int imageWidth = bitmap .getWidth ();
94
- final int imageHeight = bitmap .getHeight ();
95
- if (imageWidth < 1 ){
93
+ final int originalWidth = bitmap .getWidth ();
94
+ final int originalHeight = bitmap .getHeight ();
95
+ final float imageWidth = 0.0f + originalWidth ;
96
+ final float imageHeight = 0.0f + originalHeight ;
97
+ if (imageWidth < 1.0f ){
96
98
return Bitmap .createBitmap (bitmap , 0 , 0 , 0 , 0 );
97
99
}
98
- if (imageHeight < 1 ){
100
+ if (imageHeight < 1.0f ){
99
101
return Bitmap .createBitmap (bitmap , 0 , 0 , 0 , 0 );
100
102
}
101
103
@@ -116,7 +118,7 @@ private Bitmap resizeToSize(Bitmap bitmap, int targetWidth, int targetHeight, bo
116
118
// Don't preserve the aspect ratio.
117
119
projectTo .postScale (targetWidth / imageWidth , targetHeight / imageHeight );
118
120
}
119
- return Bitmap .createBitmap (bitmap , 0 , 0 , imageWidth , imageHeight , projectTo , true );
121
+ return Bitmap .createBitmap (bitmap , 0 , 0 , originalWidth , originalHeight , projectTo , true );
120
122
}
121
123
122
124
}
0 commit comments