|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pulpcore.image.CoreImage
public class CoreImage
The CoreImage class contains raster data and provides methods for creating transformed copies of the image.
Methods like
crop(int, int, int, int)
, scale(double)
, and tint(int)
return new
CoreImages. The image's raster data can be manipulated using the
createGraphics()
method.
Constructor Summary | |
---|---|
CoreImage(CoreImage image)
Creates a CoreImage with the same properties as the specified CoreImage. |
|
CoreImage(int width,
int height)
Creates an opaque image, initially black. |
|
CoreImage(int width,
int height,
boolean isOpaque)
Creates a blank image. |
|
CoreImage(int width,
int height,
boolean isOpaque,
int[] data)
Creates a new image using the specified pixel data. |
Method Summary | |
---|---|
CoreImage |
background(int argbColor)
|
CoreGraphics |
createGraphics()
Creates a new CoreGaphics context for drawing onto this image. |
CoreImage |
crop(int x,
int y,
int w,
int h)
Creates a cropped version of this image. |
CoreImage |
expandCanvas(int borderSize,
int argbColor)
Create a new image with an expanded canvas size. |
CoreImage |
expandCanvas(int top,
int right,
int bottom,
int left,
int argbColor)
Create a new image with an expanded canvas size. |
CoreImage |
fade(int alpha)
|
CoreImage |
flip()
Returns a new CoreImage whose raster data represents a flipped version of this image. |
int |
getARGB(int x,
int y)
Gets the ARGB color at the specified location. |
static CoreImage |
getBrokenImage()
Gets the "broken" image, which is the image the system may use when a specified image could not be loaded. |
int[] |
getData()
Gets the underlying raster data array. |
int |
getHeight()
Gets the height of the image. |
int |
getHotspotX()
Gets the x component of the hotspot. |
int |
getHotspotY()
Gets the y component of the hotspot. |
int |
getWidth()
Gets the width of the image. |
CoreImage |
halfSize()
Returns a new CoreImage whose raster data represents a 50% scaled version of this image. |
boolean |
isOpaque()
Returns true if the image is opaque. |
boolean |
isTransparent(int x,
int y)
Checks if the pixel at the specified location is transparent. |
static CoreImage |
load(String imageAsset)
Loads a PNG or JPEG image from the asset catalog. |
CoreImage |
mirror()
Returns a new CoreImage whose raster data represents a mirrored version of this image. |
CoreImage |
rotate(double angle)
Creates a rotated version of this image. |
CoreImage |
rotate(double angle,
boolean sizeAsNeeded)
Creates a rotated version of this image. |
CoreImage |
rotate(int angle)
Creates a rotated version of this image. |
CoreImage |
rotate(int angle,
boolean sizeAsNeeded)
Creates a rotated version of this image. |
CoreImage |
rotate180()
Returns a new CoreImage whose raster data represents this image rotated 180 degrees. |
CoreImage |
rotateLeft()
Returns a new CoreImage whose raster data represents this image rotated to the left (counter-clockwise 90 degrees). |
CoreImage |
rotateRight()
Returns a new CoreImage whose raster data represents this image rotated to the right (clockwise 90 degrees). |
CoreImage |
scale(double scale)
Returns a new CoreImage whose raster data represents a scaled version of this image. |
CoreImage |
scale(int scaledWidth,
int scaledHeight)
Returns a new CoreImage whose raster data represents a scaled version of this image. |
void |
setHotspot(int x,
int y)
Sets the hotspot of the image. |
CoreImage |
setTransparentColor(int rgbColor)
Returns a new CoreImage with all the opaque pixels of the specified color set to transparent. |
CoreImage[] |
split(int framesAcross)
Splits the image into several tiles. |
CoreImage[] |
split(int framesAcross,
int framesDown)
Splits the image into several tiles. |
CoreImage |
tint(int rgbColor)
Returns a new CoreImage with every color set to the specified color, without changing the alpha of each color. |
boolean |
update(int elapsedTime)
Does nothing by default. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CoreImage(int width, int height)
public CoreImage(int width, int height, boolean isOpaque)
public CoreImage(int width, int height, boolean isOpaque, int[] data)
The raster format is premultiplied ARGB (the same as
BufferedImage.TYPE_INT_ARGB_PRE
).
The raster data array is assumed to be unique to this CoreImage, and not used
in any other CoreImages.
public CoreImage(CoreImage image)
Method Detail |
---|
public CoreGraphics createGraphics()
public final boolean isOpaque()
public final int getWidth()
public final int getHeight()
public final int[] getData()
BufferedImage.TYPE_INT_ARGB_PRE
).
public final boolean isTransparent(int x, int y)
public final int getARGB(int x, int y)
IllegalArgumentException
- if the specified location is out of bounds.public final void setHotspot(int x, int y)
ImageSprite
also uses the hotspot as the
point around which rotation occurs.
getHotspotX()
,
getHotspotY()
public final int getHotspotX()
getHotspotY()
,
setHotspot(int, int)
public final int getHotspotY()
getHotspotX()
,
setHotspot(int, int)
public boolean update(int elapsedTime)
public static CoreImage getBrokenImage()
public static CoreImage load(String imageAsset)
AnimatedImage
is returned.
This method never returns null
.
If the image is not found, an error is printed to the log
and a "broken" image is returned. The broken image is similar to a red X image found in
a web browser.
Images are internally cached (using a WeakReference), and if the image was previously loaded, this method may return an image with the same internal raster data.
imageAsset
- The name of a PNG or JPEG image file.
public CoreImage[] split(int framesAcross)
public CoreImage[] split(int framesAcross, int framesDown)
public CoreImage expandCanvas(int borderSize, int argbColor)
public CoreImage expandCanvas(int top, int right, int bottom, int left, int argbColor)
public CoreImage crop(int x, int y, int w, int h)
public CoreImage rotate(double angle)
angle
- an angle, typically in the range from 0 to Math.PI * 2public CoreImage rotate(double angle, boolean sizeAsNeeded)
sizeAsNeeded
- if true, the resulting image is sized to contain
the entire rotated image. If false, the resulting image is the same
size as this image. The hotspot is rotated accordingly.angle
- an angle, typically in the range from 0 to Math.PI * 2public CoreImage rotate(int angle)
angle
- a fixed-point angle, typically in the range from 0 to
CoreMath.TWO_PI.public CoreImage rotate(int angle, boolean sizeAsNeeded)
sizeAsNeeded
- if true, the resulting image is sized to contain
the entire rotated image. If false, the resulting image is the same
size as this image. The hotspot is rotated accordingly.angle
- a fixed-point angle, typically in the range from 0 to
CoreMath.TWO_PI.public CoreImage scale(double scale)
public CoreImage scale(int scaledWidth, int scaledHeight)
public CoreImage halfSize()
public CoreImage mirror()
public CoreImage flip()
public CoreImage rotateLeft()
public CoreImage rotateRight()
public CoreImage rotate180()
public CoreImage setTransparentColor(int rgbColor)
rgbColor
- The color to convert to transparent. The alpha component is ignored.
public CoreImage tint(int rgbColor)
public CoreImage background(int argbColor)
public CoreImage fade(int alpha)
|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |