public class PsImage
extends java.lang.Object
Constructor and Description |
---|
PsImage(java.awt.Image image,
java.lang.String alternateText)
Create an PsImage using the image specified.
|
PsImage(java.lang.String imageName)
Create an PsImage using the image at relative path specified by the string.
|
PsImage(java.net.URL url)
Create an PsImage using the image at an absolute URL specified by the string.
|
Modifier and Type | Method and Description |
---|---|
static java.awt.Image |
createImageFromPixels(java.awt.Component comp,
int[] pixels,
int width,
int height,
int offset,
int scan)
Load image with a media tracker and return when image is loaded or failure occurred.
|
int |
getHeight()
Get height of loaded image.
|
java.awt.Image |
getImage()
Get the image after loading it if not done yet.
|
static java.awt.Image |
getImage(java.lang.String imageName)
Get image relative to codeBase of applet, or from file system.
|
static java.awt.Image |
getImage(java.net.URL url)
Get image from absolute URL.
|
static java.awt.Image |
getImageResource(java.lang.String s)
Get an image from a resource including the current jar archives.
|
static int[] |
getPixels(java.awt.Image image)
Convert an image to an array of pixels.
|
static int[] |
getPixels(java.awt.Image image,
int x,
int y,
int width,
int height,
int[] pixels,
int off,
int scan) |
int |
getWidth()
Get width of loaded image.
|
void |
init()
Create MediaTracker.
|
boolean |
loadImage()
Makes sure that the Image is loaded before returning from this method.
|
static boolean |
loadImage(java.awt.Component comp,
java.awt.Image image)
Load image with a media tracker and return when image is loaded or failure occurred.
|
void |
setParentComponent(java.awt.Component comp)
Set component used for MediaTracker in
init() method |
void |
setSize(int width,
int height)
Resizes the image after loading it if not done yet.
|
public PsImage(java.net.URL url)
url
- A String specifying the absolute URL of the image.public PsImage(java.lang.String imageName)
imageName
- name of image file including a relative path.public PsImage(java.awt.Image image, java.lang.String alternateText)
image
- The imagealternateText
- Alternate text used if image cannot be retrievedpublic void init()
public void setParentComponent(java.awt.Component comp)
init()
methodpublic boolean loadImage()
public int getWidth()
public int getHeight()
public java.awt.Image getImage()
public void setSize(int width, int height)
public static int[] getPixels(java.awt.Image image, int x, int y, int width, int height, int[] pixels, int off, int scan)
image
- the image to retrieve pixels fromx
- the x coordinate of the upper left corner of the rectangle of pixels to retrieve from the image, relative to the default (unscaled) size of the imagey
- the y coordinate of the upper left corner of the rectangle of pixels to retrieve from the imagewidth
- the width of the rectangle of pixels to retrieveheight
- the height of the rectangle of pixels to retrievepixels
- the array of integers which are to be used to hold the RGB pixels retrieved from the imageoff
- the offset into the array of where to store the first pixelscan
- the distance from one row of pixels to the next in the arraypublic static int[] getPixels(java.awt.Image image)
image
- the image to retrieve pixels fromnull
on failure.public static java.awt.Image getImage(java.lang.String imageName)
imageName
- name of image file with relative url or absolute path.public static java.awt.Image getImage(java.net.URL url)
public static boolean loadImage(java.awt.Component comp, java.awt.Image image)
comp
- the component on which the images will eventually be drawn.image
- the image to be loaded and tracked by the media tracker.true
on success.public static java.awt.Image createImageFromPixels(java.awt.Component comp, int[] pixels, int width, int height, int offset, int scan)
comp
- the component on which the images will eventually be drawn.pixels
- array of pixels of the image.width
- width of the imageheight
- height of the imageoffset
- starting pixel in pixel arrayscan
- length of a scan line in pixel arraynull
public static java.awt.Image getImageResource(java.lang.String s)
"