Search in sources :

Example 21 with Options

use of android.graphics.BitmapFactory.Options in project SmartAndroidSource by jaychou2012.

the class BitmapAjaxCallback method decodeFile.

private static Bitmap decodeFile(String path, BitmapFactory.Options options) {
    Bitmap result = null;
    if (options == null) {
        options = new Options();
    }
    options.inInputShareable = true;
    options.inPurgeable = true;
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(path);
        FileDescriptor fd = fis.getFD();
        //AQUtility.debug("decoding file");
        //AQUtility.time("decode file");
        result = BitmapFactory.decodeFileDescriptor(fd, null, options);
    //AQUtility.timeEnd("decode file", 0);
    } catch (IOException e) {
        AQUtility.report(e);
    } finally {
        AQUtility.close(fis);
    }
    return result;
}
Also used : Options(android.graphics.BitmapFactory.Options) Bitmap(android.graphics.Bitmap) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) FileDescriptor(java.io.FileDescriptor)

Example 22 with Options

use of android.graphics.BitmapFactory.Options in project SmartAndroidSource by jaychou2012.

the class BitmapAjaxCallback method getResizedImage.

/**
	 * Utility method for downsampling images.
	 *
	 * @param path the file path
	 * @param data if file path is null, provide the image data directly
	 * @param target the target dimension
	 * @param width use width as target, otherwise use the higher value of height or width
	 * @param round corner radius
	 * @return the resized image
	 */
public static Bitmap getResizedImage(String path, byte[] data, int target, boolean width, int round) {
    Options options = null;
    if (target > 0) {
        Options info = new Options();
        info.inJustDecodeBounds = true;
        decode(path, data, info);
        int dim = info.outWidth;
        if (!width)
            dim = Math.max(dim, info.outHeight);
        int ssize = sampleSize(dim, target);
        options = new Options();
        options.inSampleSize = ssize;
    }
    Bitmap bm = null;
    try {
        bm = decode(path, data, options);
    } catch (OutOfMemoryError e) {
        clearCache();
        AQUtility.report(e);
    }
    if (round > 0) {
        bm = getRoundedCornerBitmap(bm, round);
    }
    return bm;
}
Also used : Options(android.graphics.BitmapFactory.Options) Bitmap(android.graphics.Bitmap) Paint(android.graphics.Paint)

Example 23 with Options

use of android.graphics.BitmapFactory.Options in project Android-Universal-Image-Loader by nostra13.

the class BaseImageDecoder method defineImageSizeAndRotation.

protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo) throws IOException {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(imageStream, null, options);
    ExifInfo exif;
    String imageUri = decodingInfo.getImageUri();
    if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
        exif = defineExifOrientation(imageUri);
    } else {
        exif = new ExifInfo();
    }
    return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
}
Also used : Options(android.graphics.BitmapFactory.Options) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize)

Example 24 with Options

use of android.graphics.BitmapFactory.Options in project androidquery by androidquery.

the class AdhocActivity method decode.

private Bitmap decode(File file) throws Exception {
    BitmapFactory.Options options = new Options();
    options.inInputShareable = true;
    options.inPurgeable = true;
    FileInputStream fis = new FileInputStream(file);
    //Bitmap result = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
    Bitmap result = BitmapFactory.decodeFileDescriptor(fis.getFD(), null, options);
    AQUtility.debug("bm", result.getWidth() + "x" + result.getHeight());
    fis.close();
    return result;
}
Also used : ImageOptions(com.androidquery.callback.ImageOptions) Options(android.graphics.BitmapFactory.Options) Bitmap(android.graphics.Bitmap) Options(android.graphics.BitmapFactory.Options) BitmapFactory(android.graphics.BitmapFactory) FileInputStream(java.io.FileInputStream)

Example 25 with Options

use of android.graphics.BitmapFactory.Options in project 9GAG by Mixiaoxiao.

the class Converters method byteArrayToBitmap.

/**
     * Converts a byte array into a Bitmap, using the provided options.
     *
     * @param image The byte array representing the image.
     * @param opts  The decoding options to use, or null if you'd like to use predefined
     *              options (scaling will be not active).
     *
     * @return The initialized BitmapDrawable.
     */
public static Bitmap byteArrayToBitmap(byte[] image, Options opts) {
    if (opts == null) {
        Log.v(TAG, "opts is null, initializing without scaling");
        opts = new Options();
        opts.inScaled = false;
    }
    return BitmapFactory.decodeByteArray(image, 0, image.length, opts);
}
Also used : Options(android.graphics.BitmapFactory.Options)

Aggregations

Options (android.graphics.BitmapFactory.Options)30 Bitmap (android.graphics.Bitmap)12 IOException (java.io.IOException)10 BitmapFactory (android.graphics.BitmapFactory)6 FileInputStream (java.io.FileInputStream)6 InputStream (java.io.InputStream)4 File (java.io.File)3 Matrix (android.graphics.Matrix)2 Paint (android.graphics.Paint)2 Point (android.graphics.Point)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 ExifInterface (android.media.ExifInterface)2 Handler (android.os.Handler)2 ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)2 ImageSize (com.smartandroid.sa.zUImageLoader.core.assist.ImageSize)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileDescriptor (java.io.FileDescriptor)2 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2