Code example for Bitmap

Methods: getHeightgetWidthhasAlpharecycle

0
            return Math.max(sampeSize, lowerBound);
        } 
    } 
 
    public static Bitmap resize(Bitmap original, int targetPixels) {
        int width = original.getWidth();
        int height = original.getHeight();
        float scale = (float) Math.sqrt(
                (double) targetPixels / (width * height));
        if (scale >= 1.0f) return original;
 
        int scaledWidth = (int) (width * scale + 0.5f);
        int scaledHeight = (int) (height * scale + 0.5f);
        Bitmap bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight,
                original.hasAlpha() ? Config.ARGB_8888 : Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        canvas.scale((float) scaledWidth / width, (float) scaledHeight / height);
        canvas.drawBitmap(original, 0, 0, null);
        original.recycle();
        return bitmap;
    } 
 
    public static final Bitmap resizeBitmap(Bitmap bitmap, int maxSize) {
        int srcWidth = bitmap.getWidth();
Connect your IDE to all the code out there  Get Codota for Java