src/main/java/ru/mail/dondokidon/extensions/BitmapCreator.java
/**
     * Create new Bitmap with scaled according ScaleType param source Bitmap within
     *
     * @param source The bitmap which should be scaled
     * @param width Returned bitmap's width
     * @param height Returned bitmap's height
     * @param scaleType Scale type to decoded bitmap to fit into created bitmap
     * @return Created Bitmap
     *
     * @throws IllegalArgumentException if width, height exceed the
     *         bounds of the source bitmap
     * @throws IllegalStateException if the source bitmap's config is {@link Config#HARDWARE}
     */


@throws IllegalArgumentException if width, height exceed the
bounds of the source bitmap
@throws IllegalStateException if the source bitmap's config is  Config#HARDWARE
@throws IllegalArgumentException if width height exceed the bounds of the source bitmap @throws IllegalStateException if the source bitmap ' s config is Config#HARDWARE
public static Bitmap createScaleTyped(@NotNull Bitmap source, int width, int height, @NotNull ScaleType scaleType){
        if (width == SIZE_PROPORTIONAL && height == SIZE_PROPORTIONAL)
            return Bitmap.createBitmap(source);
        else if (width == SIZE_PROPORTIONAL){
            width = (int)((double)height / source.getHeight() * source.getWidth());
        } else if (height == SIZE_PROPORTIONAL){
            height = (int)((double)width / source.getWidth() * source.getHeight());
        }
        Bitmap result = Bitmap.createBitmap(width, height, source.getConfig());
        copyScaleTyped(source, result, scaleType);
        return result;
    }
public static Bitmap createScaleTyped ( @ NotNull Bitmap source , int width , int height , @ NotNull ScaleType scaleType ) { if ( width == SIZE_PROPORTIONAL && height == SIZE_PROPORTIONAL ) return Bitmap . createBitmap ( source ) ; else if ( width == SIZE_PROPORTIONAL ) { width = ( int ) ( ( double ) height / source . getHeight ( ) * source . getWidth ( ) ) ; } else if ( height == SIZE_PROPORTIONAL ) { height = ( int ) ( ( double ) width / source . getWidth ( ) * source . getHeight ( ) ) ; } Bitmap result = Bitmap . createBitmap ( width , height , source . getConfig ( ) ) ; copyScaleTyped ( source , result , scaleType ) ; return result ; }
Create new Bitmap with scaled according ScaleType param source Bitmap within
 @param source The bitmap which should be scaled
 @param width Returned bitmap's width
 @param height Returned bitmap's height
 @param scaleType Scale type to decoded bitmap to fit into created bitmap
 @return Created Bitmap
Create new Bitmap with scaled according ScaleType param source Bitmap within @param source The bitmap which should be scaled @param width Returned bitmap ' s width @param height Returned bitmap ' s height @param scaleType Scale type to decoded bitmap to fit into created bitmap @return Created Bitmap