All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qozix.tileview.graphics.BitmapDecoderAssets Maven / Gradle / Ivy

Go to download

The TileView widget is a subclass of ViewGroup that provides a mechanism to asynchronously display tile-based images, with additional functionality for 2D dragging, flinging, pinch or double-tap to zoom, adding overlaying Views (markers), built-in Hot Spot support, dynamic path drawing, multiple levels of detail, and support for any relative positioning or coordinate system.

The newest version!
package com.qozix.tileview.graphics;

import java.io.IOException;
import java.io.InputStream;


import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class BitmapDecoderAssets implements BitmapDecoder {

	private static final BitmapFactory.Options OPTIONS = new BitmapFactory.Options();
	static {
		OPTIONS.inPreferredConfig = Bitmap.Config.RGB_565;
	}
	
	@Override
	public Bitmap decode( String fileName, Context context ) {
		AssetManager assets = context.getAssets();
		try {
			InputStream input = assets.open( fileName );
			if ( input != null ) {
				try {
					return BitmapFactory.decodeStream( input, null, OPTIONS );										
				} catch ( OutOfMemoryError oom ) {
					// oom - you can try sleeping (this method won't be called in the UI thread) or try again (or give up)
				} catch ( Exception e ) {
					// unknown error decoding bitmap
				}
			}
		} catch ( IOException io ) {
			// io error - probably can't find the file
		} catch ( Exception e ) {
			// unknown error opening the asset
		}
		return null;
	}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy