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