com.threed.jpct.util
Class BitmapHelper

java.lang.Object
  extended by com.threed.jpct.util.BitmapHelper

public class BitmapHelper
extends java.lang.Object

Simple class that offers helper methods related to Bitmaps. Currently, there's not much in it...


Constructor Summary
BitmapHelper()
           
 
Method Summary
static Bitmap convert(Drawable dable)
          Creates a Bitmap from a Drawable.
static Bitmap loadImage(java.io.InputStream is)
          Creates a Bitmap from an Inputstream by using Android's BitmapFactory.
static Bitmap rescale(Bitmap bitmap, int width, int height)
          Rescales a Bitmap.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmapHelper

public BitmapHelper()
Method Detail

loadImage

public static Bitmap loadImage(java.io.InputStream is)
                        throws java.lang.Exception
Creates a Bitmap from an Inputstream by using Android's BitmapFactory.

Parameters:
is - the stream
Returns:
the bitmap
Throws:
java.lang.Exception

convert

public static Bitmap convert(Drawable dable)
Creates a Bitmap from a Drawable. This bypasses Android's BitmapFactory. However, Android is free to scale these resources on loading, so you might have to rescale them to fit. Prefer to put your images for textures into /raw if possible.

Parameters:
dable - the Drawable
Returns:
the bitmap

rescale

public static Bitmap rescale(Bitmap bitmap,
                             int width,
                             int height)
Rescales a Bitmap.

Parameters:
bitmap - the bitmap
width - the new width
height - the new height
Returns:
the rescaled bitmap