|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jv.objectGui.PsImage
A class for loading and handling images.
| Constructor Summary | |
PsImage(java.awt.Image anImage,
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. |
|
| Method Summary | |
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 PsImage |
getImageFromArchive(java.lang.String imageName,
java.lang.String jarArchive)
Get an image from a jar archive. |
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. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
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 anImage,
java.lang.String alternateText)
image - The imagealternateText - Alternate text used if image cannot be retrievedcomp - Component necessay for media tracker| Method Detail |
public 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)
img - 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 imagew - the width of the rectangle of pixels to retrieveh - the height of the rectangle of pixels to retrievepix - 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 pixelscansize - the distance from one row of pixels to the next in the arraypublic static int[] getPixels(java.awt.Image image)
img - the image to retrieve pixels fromnull on failure.
public static PsImage getImageFromArchive(java.lang.String imageName,
java.lang.String jarArchive)
Note, the cab-archive built with the automatic tool of VisualJ++ does not have the -p switch enabled which keeps relative path names. Therefore, I call the cabarc tool in the Custom section of this project. Then everything works fine with MS.
Netscape somehow neither reads the image nor the audio from its jar files. I expect that I did something wrong .... At least I kept the current state in which I have added the images and audio to the jar file which requires all to lie in the class/release tree.
imageName - name of image relative to root directory within the archive.jarArchive - name of jar archive including relative path.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
|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||