public class GImage extends GObject implements GResizable, GScalable
GImage class is a graphical object whose appearance is
defined by an image.| Constructor and Description |
|---|
GImage(Bitmap image)
Creates a new GImage object at the origin.
|
GImage(Bitmap image,
float x,
float y)
Creates a new GImage object at the specified coordinates.
|
GImage(Context context,
int imageID)
Creates a new GImage object at the origin inside the given context.
|
GImage(Context context,
int imageID,
float x,
float y)
Creates a new GImage object at the given x/y location inside the given context.
|
GImage(View view,
Bitmap image)
Creates a new GImage object at the origin inside the given view.
|
GImage(View view,
Bitmap image,
float x,
float y)
Creates a new GImage object at the given x/y location inside the given view.
|
GImage(View view,
int imageID)
Creates a new GImage object at the origin inside the given view.
|
GImage(View view,
int imageID,
float x,
float y)
Creates a new GImage object at the given x/y location inside the given view.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
createRGBPixel(int red,
int green,
int blue)
Creates an opaque pixel value with the color components given by
red, green, and blue. |
static int |
createRGBPixel(int red,
int green,
int blue,
int alpha)
Creates a pixel value with the color components given by
red, green, and blue
and the transparency value alpha. |
static int |
getAlpha(int pixel)
Returns the alpha component from an RGB value.
|
static int |
getBlue(int pixel)
Returns the blue component from an RGB value.
|
GRectangle |
getBounds()
Returns the bounding box of this object.
|
static int |
getGreen(int pixel)
Returns the green component from an RGB value.
|
Bitmap |
getImage()
Returns the image stored inside this
GImage. |
int[][] |
getPixelArray()
Returns a two-dimensional array of pixel values from the stored image.
|
static int |
getRed(int pixel)
Returns the red component from an RGB value.
|
GDimension |
getSize()
Returns the size of this object as a
GDimension. |
void |
paint(Canvas canvas)
Implements the
paint operation for this graphical object. |
void |
scale(float sf)
Scales the object on the screen by the scale factor
sf, which applies
in both dimensions. |
void |
scale(float sx,
float sy)
Scales the object on the screen by the scale factors
sx and sy. |
void |
setBounds(float x,
float y,
float width,
float height)
Changes the bounds of this object to the specified values.
|
void |
setBounds(GRectangle bounds)
Changes the bounds of this object to the values from the specified
GRectangle. |
void |
setContext(Context context) |
void |
setImage(Bitmap image)
Resets the image used by this
GImage object to the new image
specified as an argument. |
void |
setImage(int imageID)
Resets the image used by this
GImage object to the one identified
by the argument name, which is processed exactly as described
in the constructors. |
void |
setSize(float width,
float height)
Changes the size of this object to the specified width and height.
|
void |
setSize(GDimension size)
Changes the size of this object to the specified
GDimension. |
contains, contains, getBottomY, getCenterX, getCenterY, getColor, getGCanvas, getHeight, getLocation, getPaint, getRightX, getWidth, getX, getY, intersects, isVisible, moveBy, moveByPolar, moveTo, moveTo, moveToPolar, repaint, sendBackward, sendForward, sendToBack, sendToFront, setBottomY, setCanvas, setColor, setGCanvas, setLocation, setLocation, setPaint, setRightX, setVisible, setX, setY, toString, translatepublic GImage(Bitmap image)
public GImage(Bitmap image, float x, float y)
public GImage(View view, Bitmap image)
public GImage(View view, Bitmap image, float x, float y)
public GImage(Context context, @DrawableRes int imageID)
public GImage(View view, @DrawableRes int imageID)
public GImage(View view, @DrawableRes int imageID, float x, float y)
public GImage(Context context, @DrawableRes int imageID, float x, float y)
public void setImage(Bitmap image)
GImage object to the new image
specified as an argument. Calling setImage automatically changes
the size of the image to be equal to that of the image data.image - The image to use as the contents of this GImagepublic void setImage(@DrawableRes int imageID)
GImage object to the one identified
by the argument name, which is processed exactly as described
in the constructors. Calling setImage automatically changes
the size of the image to be equal to that of the image data.public Bitmap getImage()
GImage.Image object stored inside this GImagepublic void paint(Canvas canvas)
paint operation for this graphical object. This method
is not called directly by clients.public void setSize(float width,
float height)
setSize in interface GResizablewidth - The new width of the objectheight - The new height of the objectpublic final void setSize(GDimension size)
GDimension.setSize in interface GResizablesize - A GDimension object specifying the sizepublic GDimension getSize()
GDimension.public void setBounds(float x,
float y,
float width,
float height)
setBounds in interface GResizablex - The new x-coordinate for the objecty - The new y-coordinate for the objectwidth - The new width of the objectheight - The new height of the objectpublic final void setBounds(GRectangle bounds)
GRectangle.setBounds in interface GResizablebounds - A GRectangle specifying the new boundspublic GRectangle getBounds()
public void scale(float sx,
float sy)
sx and sy.public final void scale(float sf)
sf, which applies
in both dimensions.public void setContext(Context context)
public int[][] getPixelArray()
public static int getAlpha(int pixel)
pixel - An int containing a pixel value as alpha/red/green/blue.public static int getRed(int pixel)
pixel - An int containing a pixel value as alpha/red/green/blue.public static int getGreen(int pixel)
pixel - An int containing a pixel value as alpha/red/green/blue.public static int getBlue(int pixel)
pixel - An int containing a pixel value as alpha/red/green/blue.public static int createRGBPixel(int red,
int green,
int blue)
red, green, and blue.red - The red component of the pixel (0 to 255)green - The green component of the pixel (0 to 255)blue - The blue component of the pixel (0 to 255)public static int createRGBPixel(int red,
int green,
int blue,
int alpha)
red, green, and blue
and the transparency value alpha.red - The red component of the pixel (0 to 255)green - The green component of the pixel (0 to 255)blue - The blue component of the pixel (0 to 255)alpha - The transparency value of the pixel (0 to 255)