package com.trongan93.imageprocessingbasicnoneopencv.ImageProcessing;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

/**
 * Created by buitrongan on 26/11/2016.
 */

public class ScaleImage {
    Context mContext;
    private int mSourceWidth, mSourceHeight;
    private int mDstWidth, mDstHeight;

    public ScaleImage(Context mContext, int mDstWidth, int mDstHeight) {
        this.mContext = mContext;
        this.mDstWidth = mDstWidth;
        this.mDstHeight = mDstHeight;
    }
    public Bitmap DownScaleBitmap(Bitmap sourceBitmap){
        Bitmap destinationBitmap;
        mSourceWidth = sourceBitmap.getWidth();
        mSourceHeight = sourceBitmap.getHeight();
        float ratio = Math.min((float)mDstWidth/mSourceWidth,(float)mDstHeight/mSourceHeight);
        int width = Math.round((float)ratio * mSourceWidth);
        int height = Math.round((float)ratio * mSourceHeight);

        if(mSourceWidth > mDstWidth || mSourceHeight > mDstHeight){
            destinationBitmap = Bitmap.createScaledBitmap(sourceBitmap,width,height,false);
        }
        else
        {
            destinationBitmap = sourceBitmap;
        }
        return destinationBitmap;
    }
    public Bitmap DowScaleBitmap(Bitmap sourceBitmap, float maxImageSize, boolean filter){
        float ratio = Math.min((float) maxImageSize / sourceBitmap.getWidth(), (float) maxImageSize / sourceBitmap.getHeight());
        int width = Math.round((float) ratio * sourceBitmap.getWidth());
        int height = Math.round((float) ratio * sourceBitmap.getHeight());
        Bitmap newBitmap = Bitmap.createScaledBitmap(sourceBitmap, width, height, filter);
        return newBitmap;
    }
}

@@ -945,16 +945,18 @@
 ight);%0A%0A
+//
         
@@ -1015,16 +1015,18 @@
 eight)%7B%0A
+//
         
@@ -1109,16 +1109,18 @@
 false);%0A
+//
         
@@ -1113,32 +1113,34 @@
 e);%0A//        %7D%0A
+//
         else%0A   
@@ -1136,16 +1136,18 @@
    else%0A
+//
         
@@ -1148,16 +1148,18 @@
       %7B%0A
+//
         
@@ -1188,32 +1188,34 @@
 = sourceBitmap;%0A
+//
         %7D%0A      
@@ -1204,24 +1204,112 @@
 //        %7D%0A
+        destinationBitmap = Bitmap.createScaledBitmap(sourceBitmap,width,height,false);%0A
         retu

Scale Image function