Search in sources :

Example 11 with Options

use of android.graphics.BitmapFactory.Options in project PocketHub by pockethub.

the class ImageUtils method getBitmap.

/**
     * Get a bitmap from the image
     *
     * @param image
     * @param sampleSize
     * @return bitmap or null if read fails
     */
public static Bitmap getBitmap(final byte[] image, int sampleSize) {
    final Options options = new Options();
    options.inDither = false;
    options.inSampleSize = sampleSize;
    return BitmapFactory.decodeByteArray(image, 0, image.length, options);
}
Also used : Options(android.graphics.BitmapFactory.Options)

Example 12 with Options

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

the class PostActivity method photoPost.

private void photoPost(String id, String message, File file) {
    String url = "https://graph.facebook.com/" + id + "/photos";
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("message", message);
    Options size = getSize(photo);
    if (bm.getWidth() == size.outWidth) {
        AQUtility.debug("use file");
        params.put("source", file);
    } else {
        AQUtility.debug("use byte[]");
        params.put("source", toBytes(bm));
    }
    putLocation(params, place, location);
    putPhotoTags(params, tags);
    AQUtility.debug("params", params);
    AQuery aq = new AQuery(getApplicationContext());
    aq.auth(handle).ajax(url, params, JSONObject.class, this, "photoCb");
}
Also used : AQuery(com.androidquery.AQuery) Options(android.graphics.BitmapFactory.Options) HashMap(java.util.HashMap) JSONObject(org.json.JSONObject)

Example 13 with Options

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

the class PostActivity method getSize.

private Options getSize(File file) {
    BitmapFactory.Options options = null;
    options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(file.getAbsolutePath(), options);
    return options;
}
Also used : Options(android.graphics.BitmapFactory.Options) BitmapFactory(android.graphics.BitmapFactory)

Example 14 with Options

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

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
	 * @param rotate auto rotate with exif data
	 * @return the resized image
	 */
public static Bitmap getResizedImage(String path, byte[] data, int target, boolean width, int round, boolean rotate) {
    if (path == null && data == null)
        return null;
    Options options = null;
    if (target > 0) {
        Options info = new Options();
        info.inJustDecodeBounds = true;
        decode(path, data, info, rotate);
        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, rotate);
    } 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 15 with Options

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

the class BitmapAjaxCallback method decodeFile.

private static Bitmap decodeFile(String path, BitmapFactory.Options options, boolean rotate) {
    Bitmap result = null;
    if (options == null) {
        options = new Options();
    }
    options.inInputShareable = isInputSharable();
    options.inPurgeable = true;
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(path);
        FileDescriptor fd = fis.getFD();
        result = BitmapFactory.decodeFileDescriptor(fd, null, options);
        if (result != null && rotate) {
            result = rotate(path, result);
        }
    } 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)

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