Skip to content

Commit

Permalink
fix(android): fix imageAsResized (#11667)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27774
  • Loading branch information
jquick-axway authored Apr 29, 2020
1 parent f3e9507 commit cf4cc22
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions android/titanium/src/java/org/appcelerator/titanium/TiBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
*/
package org.appcelerator.titanium;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ThumbnailUtils;
import android.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
Expand All @@ -14,7 +20,6 @@
import java.io.UnsupportedEncodingException;
import java.net.URLConnection;
import java.util.HashMap;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.KrollRuntime;
Expand All @@ -27,13 +32,6 @@
import org.appcelerator.titanium.util.TiImageHelper;
import org.appcelerator.titanium.util.TiMimeTypeHelper;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ThumbnailUtils;
import android.util.Base64;

/**
* A Titanium Blob object. A Blob can represent any opaque data or input stream.
*/
Expand Down Expand Up @@ -768,7 +766,10 @@ public TiBlob imageAsResized(Number width, Number height)
imgWidth = img.getWidth();
imgHeight = img.getHeight();
if (rotation != 0) {
float scaleWidth = (float) dstWidth / imgWidth;
float scaleHeight = (float) dstHeight / imgHeight;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
matrix.postRotate(rotation);
imageResized = Bitmap.createBitmap(img, 0, 0, imgWidth, imgHeight, matrix, true);
} else {
Expand Down

0 comments on commit cf4cc22

Please sign in to comment.