|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsofia.graphics.Image
public class Image
Represents a single bitmapped image, such as one loaded from a file.
Images retrieved by name or class are searched for using a robust and flexible search scheme.
This class cannot be a subclass of Bitmap
, since Bitmap is
a final class.
Constructor Summary | |
---|---|
Image(android.graphics.Bitmap bitmap)
Create an image from a bitmap. |
|
Image(java.lang.Class<?> klass)
Create an image from a class. |
|
Image(Image other)
Create an image that is a duplicate of another image (a copy constructor). |
|
Image(java.lang.String fileName)
Create an image from a file. |
Method Summary | |
---|---|
android.graphics.Bitmap |
asBitmap()
Access the contents of this image in the form of an Android Bitmap . |
static Image |
getDefault()
Get a new Image object that renders as the default Sofia image. |
int |
getHeight()
Return the height of this bitmap. |
sofia.graphics.Color |
getPixel(int x,
int y)
Returns the Color at the specified location. |
sofia.graphics.Color[] |
getPixels()
Returns an array containing all of the Color of each pixel in the image, arranged in row-major order. |
boolean |
getScaleForDpi()
Get whether this image will be automatically scaled up or down based on the current device's pixel density when it is loaded. |
int |
getWidth()
Return the width of this bitmap. |
void |
resolveAgainstContext(android.content.Context context)
Provide an Android resource context to use for loading this image (this must be called before any class/id/file name image will be available). |
void |
setPixel(int x,
int y,
sofia.graphics.Color color)
Write the specified Color into the bitmap at the x,y coordinate. |
void |
setPixels(sofia.graphics.Color[] pixels)
Replace pixels in the bitmap with the colors in the array. |
void |
setScaleForDpi(boolean willScaleForDpi)
Determine whether this image will be automatically scaled up or down based on the current device's pixel density when it is loaded. |
void |
setUseDefaultIfNotFound(boolean useDefault)
Determine whether this image should use the default Sofia image/icon, if no image corresponding to the search criteria (e.g., a class name, or a file name) is found. |
boolean |
useDefaultIfNotFound()
Says whether this object will use the default Sofia image/icon, if no image corresponding to the search criteria specified in its constructor call (e.g., a class name, or a file name) is found. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Image(android.graphics.Bitmap bitmap)
bitmap
- The bitmap forming this image's contents.public Image(java.lang.Class<?> klass)
klass
- The Java class after which the file is named.public Image(java.lang.String fileName)
fileName
- The name of the image file, optionally including
an extension.public Image(Image other)
other
- The image to copy.Method Detail |
---|
public static Image getDefault()
public android.graphics.Bitmap asBitmap()
Bitmap
.
public void setUseDefaultIfNotFound(boolean useDefault)
useDefault
- True if this image should render as the
Sofia default image if no corresponding resource
is found. If false, and no image is found,
then asBitmap() will return null.public boolean useDefaultIfNotFound()
asBitmap()
will return null. The default
is true.
public void setScaleForDpi(boolean willScaleForDpi)
willScaleForDpi
- True if this image should be scaled for
the current device's pixel density.resolveAgainstContext(Context)
public boolean getScaleForDpi()
resolveAgainstContext(Context)
public void resolveAgainstContext(android.content.Context context)
context
- The context to resolve this image against.public int getWidth()
Before calling this method, the bitmap must be resolved (that is, loaded from a resource).
java.lang.IllegalStateException
- If the bitmap has not yet been resolved.public int getHeight()
Before calling this method, the bitmap must be resolved (that is, loaded from a resource).
java.lang.IllegalStateException
- If the bitmap has not yet been resolved.public sofia.graphics.Color getPixel(int x, int y)
x
- The x coordinate (0...width-1) of the pixel to return.y
- The y coordinate (0...height-1) of the pixel to return.
java.lang.IllegalArgumentException
- If x or y exceed the bitmap's bounds.
java.lang.IllegalStateException
- If the bitmap has not yet been resolved.public sofia.graphics.Color[] getPixels()
java.lang.IllegalStateException
- If the bitmap has not yet been resolved.public void setPixel(int x, int y, sofia.graphics.Color color)
x
- The x coordinate of the pixel to replace (0...width-1).y
- The y coordinate of the pixel to replace (0...height-1).color
- The Color to write into the bitmap.
java.lang.IllegalArgumentException
- If x, y are outside of the bitmap's
bounds.
java.lang.IllegalStateException
- If the bitmap has not yet been resolved.public void setPixels(sofia.graphics.Color[] pixels)
pixels
- The colors to write to the bitmap.
java.lang.IllegalStateException
- If the bitmap has not yet been resolved.
java.lang.IllegalArgumentException
- If the pixels array is the wrong size,
or null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |