BitmapFactory decodeFileDescriptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for BitmapFactory decodeFileDescriptor method.

This code example shows how to use the following methods:decodeFileDescriptor
     * @param imagePath 
     * @param sampleSize 
     * @return bitmap or null if read fails 
     */ 
    public static Bitmap getBitmap(final String imagePath, int sampleSize) {
        final Options options = new Options();
        options.inDither = false;
        options.inSampleSize = sampleSize;
 
        RandomAccessFile file = null;
        try { 
            file = new RandomAccessFile(imagePath, "r");
            return BitmapFactory.decodeFileDescriptor(file.getFD(), null,
                    options);
        } catch (IOException e) {
            Log.d(TAG, e.getMessage(), e);
            return null; 
        } finally { 
            if (file != null)
                try { 
8
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
        return ensureGLCompatibleBitmap( 
                BitmapFactory.decodeFile(filePath, options));
    } 
 
    public static Bitmap requestDecode(JobContext jc, FileDescriptor fd, Options options) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
        return ensureGLCompatibleBitmap( 
                BitmapFactory.decodeFileDescriptor(fd, null, options));
    } 
 
    public static Bitmap requestDecode(JobContext jc, byte[] bytes,
            Options options) {
        return requestDecode(jc, bytes, 0, bytes.length, options);
    } 
 
    public static Bitmap requestDecode(JobContext jc, byte[] bytes, int offset,
            int length, Options options) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
7
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
     * @param imagePath 
     * @param sampleSize 
     * @return bitmap or null if read fails 
     */ 
    public static Bitmap getBitmap(final String imagePath, int sampleSize) {
        final Options options = new Options();
        options.inDither = false;
        options.inSampleSize = sampleSize;
 
        RandomAccessFile file = null;
        try { 
            file = new RandomAccessFile(imagePath, "r");
            return BitmapFactory.decodeFileDescriptor(file.getFD(), null,
                    options);
        } catch (IOException e) {
            Log.d(TAG, e.getMessage(), e);
            return null; 
        } finally { 
            if (file != null)
                try { 
7
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
	} 
 
	public static Bitmap requestDecode(final JobContext jc, final FileDescriptor fd, Options options,
			final int targetSize) {
		if (options == null) {
			options = new Options();
		} 
		jc.setCancelListener(new DecodeCanceller(options));
 
		options.inJustDecodeBounds = true;
		BitmapFactory.decodeFileDescriptor(fd, null, options);
		if (jc.isCancelled()) return null;
 
		options.inSampleSize = BitmapUtils.computeSampleSizeLarger(options.outWidth, options.outHeight, targetSize);
		options.inJustDecodeBounds = false;
 
		Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options);
		// We need to resize down if the decoder does not support inSampleSize. 
		// (For example, GIF images.) 
		result = BitmapUtils.resizeDownIfTooBig(result, targetSize, true);

5
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
	 * 
	 * @param imagePath 
	 * @return bitmap or null if read fails 
	 */ 
	public static Bitmap getBitmap(final String imagePath) {
		final Options options = new Options();
		options.inDither = false;
		options.inPurgeable = true;
		options.inInputShareable = true;
 
		RandomAccessFile file = null;
		try { 
			file = new RandomAccessFile(imagePath, "r");
			return BitmapFactory.decodeFileDescriptor(file.getFD(), null,
					options);
		} catch (IOException e) {
			Log.d(TAG, e.getMessage(), e);
			return null; 
		} finally { 
			if (file != null)
5
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
        return ensureGLCompatibleBitmap( 
                BitmapFactory.decodeFile(filePath, options));
    } 
 
    public static Bitmap requestDecode(JobContext jc, FileDescriptor fd, Options options) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
        return ensureGLCompatibleBitmap( 
                BitmapFactory.decodeFileDescriptor(fd, null, options));
    } 
 
    public static Bitmap requestDecode(JobContext jc, byte[] bytes,
            Options options) {
        return requestDecode(jc, bytes, 0, bytes.length, options);
    } 
 
    public static Bitmap requestDecode(JobContext jc, byte[] bytes, int offset,
            int length, Options options) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
5
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
        } 
    } 
 
    public static Bitmap requestDecode(JobContext jc, FileDescriptor fd,
            Options options, int targetSize) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
 
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFileDescriptor(fd, null, options);
        if (jc.isCancelled()) return null;
 
        options.inSampleSize = BitmapUtils.computeSampleSizeLarger(
                options.outWidth, options.outHeight, targetSize);
        options.inJustDecodeBounds = false;
 
        Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options);
        // We need to resize down if the decoder does not support inSampleSize. 
        // (For example, GIF images.) 
        //result = BitmapUtils.resizeDownIfTooBig(result, targetSize, true); 

5
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
        return ensureGLCompatibleBitmap( 
                BitmapFactory.decodeFile(filePath, options));
    } 
 
    public static Bitmap requestDecode(JobContext jc, FileDescriptor fd, Options options) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
        return ensureGLCompatibleBitmap( 
                BitmapFactory.decodeFileDescriptor(fd, null, options));
    } 
 
    public static Bitmap requestDecode(JobContext jc, byte[] bytes,
            Options options) {
        return requestDecode(jc, bytes, 0, bytes.length, options);
    } 
 
    public static Bitmap requestDecode(JobContext jc, byte[] bytes, int offset,
            int length, Options options) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
5
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
        } 
    } 
 
    public static Bitmap requestDecode(JobContext jc, FileDescriptor fd,
            Options options, int targetSize) {
        if (options == null) options = new Options();
        jc.setCancelListener(new DecodeCanceller(options));
 
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFileDescriptor(fd, null, options);
        if (jc.isCancelled()) return null;
 
        options.inSampleSize = BitmapUtils.computeSampleSizeLarger(
                options.outWidth, options.outHeight, targetSize);
        options.inJustDecodeBounds = false;
 
        Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options);
        // We need to resize down if the decoder does not support inSampleSize. 
        // (For example, GIF images.) 
        result = BitmapUtils.resizeDownIfTooBig(result, targetSize, true);

5
CodeRank
This code example shows how to use the following methods:decodeFileDescriptor
     * @param imagePath 
     * @param sampleSize 
     * @return bitmap or null if read fails 
     */ 
    public static Bitmap getBitmap(final String imagePath, int sampleSize) {
        final Options options = new Options();
        options.inDither = false;
        options.inSampleSize = sampleSize;
 
        RandomAccessFile file = null;
        try { 
            file = new RandomAccessFile(imagePath, "r");
            return BitmapFactory.decodeFileDescriptor(file.getFD(), null,
                    options);
        } catch (IOException e) {
            Log.d(TAG, e.getMessage(), e);
            return null; 
        } finally { 
            if (file != null)
                try { 
4
CodeRank

Related BitmapFactory decodeFileDescriptor Questions & Answers:

decodeFileDescriptor Method Overview
Decode a bitmap from the file descriptor.
See Code Examples for other Android BitmapFactory Methods: