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);
}
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");
}
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;
}
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;
}
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;
}
Aggregations