framework/src/org/apache/cordova/CameraLauncher.java
/**
     * Scales the bitmap according to the requested size.
     *
     * @param bitmap        The bitmap to scale.
     * @return Bitmap       A new Bitmap object of the same bitmap after scaling.
     */
Scales the bitmap according to the requested size.
@param bitmap        The bitmap to scale.
@return Bitmap       A new Bitmap object of the same bitmap after scaling.
Scales the bitmap according to the requested size . @param bitmap The bitmap to scale . @return Bitmap A new Bitmap object of the same bitmap after scaling .
public Bitmap scaleBitmap(Bitmap bitmap) {
        int newWidth = this.targetWidth;
        int newHeight = this.targetHeight;
        int origWidth = bitmap.getWidth();
        int origHeight = bitmap.getHeight();
        if (newWidth <= 0 && newHeight <= 0) {
            return bitmap;
        }
        else if (newWidth > 0 && newHeight <= 0) {
            newHeight = (newWidth * origHeight) / origWidth;
        }
        else if (newWidth <= 0 && newHeight > 0) {
            newWidth = (newHeight * origWidth) / origHeight;
        }
        else {
            double newRatio = newWidth / (double) newHeight;
            double origRatio = origWidth / (double) origHeight;
            if (origRatio > newRatio) {
                newHeight = (newWidth * origHeight) / origWidth;
            } else if (origRatio < newRatio) {
                newWidth = (newHeight * origWidth) / origHeight;
            }
        }
        Bitmap retval = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true);
        bitmap.recycle();
        System.gc();
        return retval;
    }
public Bitmap scaleBitmap ( Bitmap bitmap ) { int newWidth = this . targetWidth ; int newHeight = this . targetHeight ; int origWidth = bitmap . getWidth ( ) ; int origHeight = bitmap . getHeight ( ) ; if ( newWidth <= 0 && newHeight <= 0 ) { return bitmap ; } else if ( newWidth > 0 && newHeight <= 0 ) { newHeight = ( newWidth * origHeight ) / origWidth ; } else if ( newWidth <= 0 && newHeight > 0 ) { newWidth = ( newHeight * origWidth ) / origHeight ; } else { double newRatio = newWidth / ( double ) newHeight ; double origRatio = origWidth / ( double ) origHeight ; if ( origRatio > newRatio ) { newHeight = ( newWidth * origHeight ) / origWidth ; } else if ( origRatio < newRatio ) { newWidth = ( newHeight * origWidth ) / origHeight ; } } Bitmap retval = Bitmap . createScaledBitmap ( bitmap , newWidth , newHeight , true ) ; bitmap . recycle ( ) ; System . gc ( ) ; return retval ; }
Scales the bitmap according to the requested size.
Scales the bitmap according to the requested size .
// If no new width or height were specified return the original bitmap // Only the width was specified // only the height was specified // If the user specified both a positive width and height // (potentially different aspect ratio) then the width or height is // scaled so that the image fits while maintaining aspect ratio. // Alternatively, the specified width and height could have been // kept and Bitmap.SCALE_TO_FIT specified when scaling, but this // would result in whitespace in the new image.