Skip to content

Commit

Permalink
added stupid workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
yagitoshiro committed Aug 7, 2013
1 parent 6decf3f commit 3325d3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Binary file modified dist/ImageAsResized.jar
Binary file not shown.
Binary file modified dist/org.selfkleptomaniac.ti.imageasresized-android-0.6.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,24 @@ private Matrix getScaleMatrix(int orig_w, int orig_h, int w, int h){
// float scale = (float)w / (float)orig_w;
int n = 3;
float scale = (float)Math.exp(Math.log((float)w / (float)orig_w) / (float)n);
//Log.d(LCAT, "scale:" + scale);
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
return matrix;
}

private TiBlob returnBlob(BitmapFactory.Options opts, Bitmap image_base, Matrix matrix, int w, int h, int x, int y)
throws NullPointerException{
// Log.d(LCAT, "returnBlob w:" + w);
// Log.d(LCAT, "returnBlob h:" + h);
// Log.d(LCAT, "image_base w: " + image_base.getWidth());
// Log.d(LCAT, "image_base h: " + image_base.getHeight());
// Log.d(LCAT, "returnBlob x:" + x);
// Log.d(LCAT, "returnBlob y:" + y);
Bitmap scaled_image = Bitmap.createBitmap(image_base, x, y, (int)image_base.getWidth(), (int)image_base.getHeight(), matrix, true);
for(int i = 0; i < 2; i++){
scaled_image = Bitmap.createBitmap(scaled_image, x, y, scaled_image.getWidth(), scaled_image.getHeight(), matrix, true);
}
//I know it's stupid but it works.
if(scaled_image.getWidth() > w && scaled_image.getHeight() > h){
float scale = Math.min((float)w/scaled_image.getWidth(), (float)h/scaled_image.getHeight());
Matrix matrixEnd = new Matrix();
matrixEnd.postScale(scale, scale);
scaled_image = Bitmap.createBitmap(scaled_image, x, y, scaled_image.getWidth(), scaled_image.getHeight(), matrixEnd, true);
}
TiBlob blob = TiBlob.blobFromImage(scaled_image);
image_base.recycle();
image_base = null;
Expand Down

0 comments on commit 3325d3c

Please sign in to comment.