Android Utililty Methods Bitmap Scale

List of utility methods to do Bitmap Scale

Description

The list of methods to do Bitmap Scale are organized into topic(s).

Method

BitmapstretchImage(Bitmap image, int xsize, int ysize)
Stretches Bitmap to a scale in each direction.
Bitmap data = Bitmap.createBitmap(xsize, ysize, image.getConfig());
Canvas canvas = new Canvas(data);
canvas.drawBitmap(image,
        new Rect(0, 0, image.getWidth(), image.getHeight()),
        new Rect(0, 0, xsize, ysize), null);
return data;
BitmapzoomImg(Bitmap bm, int newWidth, int newHeight)
zoom Img
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,
        true);
...
BitmapgetSmallBitmap(String filePath)
get Small Bitmap
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, options);
options.inSampleSize = calculateInSampleSize(options, 320, 480);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(filePath, options);
BitmapgetScaledBitmap(String picturePath, int width, int height)
get Scaled Bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(picturePath, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
int scaleFactor;
if (width > 0 && height > 0) {
    scaleFactor = Math.min(photoW / width, photoH / height);
...
BitmapcleanStretchImage(Bitmap image, int xsize, int ysize)
stretches the middle sections of the image in a cross to avoid the borders looking stretched
image = crossStretchImageX(image, xsize);
image = cleanStretchImageY(image, ysize);
return image;
BitmapcleanStretchImageY(Bitmap image, int ysize)
stretches the middle section of the image on the Y axis to avoid the borders looking stretched
Bitmap cutout = Bitmap.createBitmap(image.getWidth(),
        image.getHeight() / 3, image.getConfig());
Canvas cutoutc = new Canvas(cutout);
Bitmap temp = Bitmap.createBitmap(image.getWidth(), ysize,
        image.getConfig());
Canvas tempc = new Canvas(temp);
cutoutc.drawBitmap(
        image,
...