|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--waba.fx.Image
Image is a rectangular image.
You can draw into an image and copy an image to a surface using a Graphics object. Before a image is drawed, its palette is set.
Graphics
Field Summary | |
protected int |
height
|
protected int[] |
palRGBs
|
protected int[][] |
pixels
On desktop, contains the pixels of this image. |
protected Palette |
savingPal
Used on desktop only to match the colors that are being saved with the colors that are being getted when saving a bitmap |
Color |
transparentColor
Sets the transparent color of this image. |
protected int |
width
|
Constructor Summary | |
protected |
Image()
|
|
Image(byte[] fullBmpDescription)
Parses an image from the given byte array. |
|
Image(int width,
int height)
Creates an image of the specified width and height. |
|
Image(String path)
Loads and constructs an image from a file. |
Method Summary | |
void |
applyPalette()
apply the palette used by this bitmap to the display |
void |
changeColors(Color from,
Color to)
Changes all the pixels of the image from one color to the other. |
int |
createBmp(DataStream ds)
saves this image as a Windows .bmp file format, with the same bpp of the screen using the current palette of this image, to the given DataStream. |
void |
free()
Sets the image width and height to 0 and frees any systems resources associated with the image. |
Graphics |
getGraphics()
Returns a new Graphics instance that can be used to drawing in this image. |
int |
getHeight()
Returns the height of the image. |
Palette |
getPalette()
returns the palette associated with this image. |
Image |
getScaledInstance(int newWidth,
int newHeight)
Returns the scaled instance for this picture. |
Color |
getTransparentColor()
Deprecated. Access the public member transparentColor directly |
int |
getWidth()
Returns the width of the image. |
int |
saveTo(Catalog cat,
String name)
saves this image as a Windows .bmp file format to the given Catalog. |
void |
setPalette(Palette pal)
substitutes the original palette that came with this image with the given one. |
void |
setTransparentColor(Color c)
Deprecated. Access the public member transparentColor directly |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
Field Detail |
protected int width
protected int height
public Color transparentColor
myImage.applyPalette
before calling
setTransparentColor (or before the first time the image is drawn),
otherwise the color may not be found in the active palette.protected int[] palRGBs
protected int[][] pixels
protected Palette savingPal
Constructor Detail |
protected Image()
public Image(int width, int height)
Image img = new Image(100,100); Graphics g = img.getGraphics(); g.setBackColor(Color.WHITE); g.fillRect(25,25,50,50); ... Graphics screenG = createGraphics(); screenG.drawImage(img,CENTER,CENTER);
public Image(String path)
public Image(byte[] fullBmpDescription)
// create the image and fill it with something Image img = new Image(160,160); Graphics g = img.getGraphics(); for (int i =0; i < 16; i++) { g.setBackColor(new Color(10*i,10*i,10*i)); g.fillRect(i*10,0,10,160); } // save the bmp in a byte stream ByteArrayStream bas = new ByteArrayStream(4096); DataStream ds = new DataStream(bas); int totalBytesWritten = img.createBmp(ds); // parse the saved bmp Image im = new Image(bas.getBuffer()); // Caution! the buffer may be greater than totalBytesWritten, but when parsing theres no problem. if (im.getWidth() > 0) // successfully parsed? { createGraphics().drawImage(im,CENTER,CENTER); Vm.sleep(2000); }
Method Detail |
public void free()
public int getHeight()
public int getWidth()
public Graphics getGraphics()
public void setTransparentColor(Color c)
myImage.applyPalette
before calling
setTransparentColor (or before the first time the image is drawn),
otherwise the color may not be found in the active palette.public Color getTransparentColor()
public void changeColors(Color from, Color to)
public Palette getPalette()
public void setPalette(Palette pal)
public int saveTo(Catalog cat, String name)
Here is an usage example:
// create the image and paint over it Image img = new Image(100,100); Graphics g = img.getGraphics(); g.setBackColor(new Color(100,150,200)); g.fillRect(25,25,50,50); g.setForeColor(new Color(255,255,255)); g.drawCircle(50,50,20); // create the catalog to save the image. You must change CRTR to match your apps creator ID Catalog cat = new Catalog("images.CRTR.SWAX", Catalog.CREATE); img.saveTo(cat, "boxcircle.bmp"); cat.close(); // load the previously created image if (Vm.attachLibrary("images.CRTR")) // must add the creator so it can be used in desktop. The type is always SWAX { Image im = new Image("boxcircle.bmp"); if (im.getWidth() > 0) // successfully loaded? createGraphics().drawImage(im,CENTER,CENTER); }
createBmp(waba.io.DataStream)
public int createBmp(DataStream ds)
saveTo(waba.io.Catalog, java.lang.String)
public void applyPalette()
public Image getScaledInstance(int newWidth, int newHeight)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |