Code example for Bitmap

Methods: createScaledBitmapgetWidth

        if (mIconBitmap == null || mActualWidth == 0 || mActualHeight == 0) {
        if (mScalingExpected && mActualWidth != mIconBitmap.getWidth()) {
            // Don't scale the image every time something changes. 
            mScalingExpected = false;
        // After scaling, determine if we have empty space around the scaled image which we need to 
        // fill with the coloured background. If applicable, show it. 
        // We assume Favicons are still squares and only bother with the background if more than 3px 
        // of it would be displayed. 
        if (Math.abs(mIconBitmap.getWidth() - mActualWidth) > 3) {
        } else { 
    private void scaleBitmap() { 
        // If the Favicon can be resized to fill the view exactly without an enlargment of more than 
        // a factor of two, do so. 
        int doubledSize = mIconBitmap.getWidth()*2;
        if (mActualWidth > doubledSize) {
            // If the view is more than twice the size of the image, just double the image size 
            // and do the rest with padding. 
            mIconBitmap = Bitmap.createScaledBitmap(mIconBitmap, doubledSize, doubledSize, true);
        } else { 
            // Otherwise, scale the image to fill the view. 
            mIconBitmap = Bitmap.createScaledBitmap(mIconBitmap, mActualWidth, mActualWidth, true);
     * Helper method to display background of the dominant colour of the favicon to pad the remaining 
Contextual code suggestions in your IDE  Get Codota for Java