Class Bitmap
All Packages Class Hierarchy This Package Previous Next Index
Class Bitmap
public class netscape.application.Bitmap
extends netscape.application.Image
{
/* Constructors
*/
public Bitmap();
public Bitmap(int, int);
public Bitmap(int[], int, int);
public Bitmap(int[], int, int, int, int);
/* Methods
*/
public static Bitmap bitmapFromURL(URL);
public static synchronized Bitmap bitmapNamed(String, boolean, boolean);
public static Bitmap bitmapNamed(String, boolean);
public static Bitmap bitmapNamed(String);
public Graphics createGraphics();
public void decode(Decoder);
public void describeClassInfo(ClassInfo);
public void drawAt(Graphics, int, int);
public void drawScaled(Graphics, int, int, int, int);
public void encode(Encoder);
public void flush();
public boolean grabPixels(int[]);
public boolean grabPixels(int[], int, int, int, int, int, int);
public boolean hasLoadedData();
public int height();
public boolean isTransparent();
public boolean isValid();
public void loadData();
public boolean loadsIncrementally();
public String name();
public void setLoadsIncrementally(boolean);
public void setTransparent(boolean);
public synchronized void setUpdateCommand(String);
public synchronized void setUpdateTarget(Target);
public String toString();
public synchronized String updateCommand();
public synchronized Rect updateRect();
public synchronized Target updateTarget();
public int width();
}
Image subclass that draws bitmapped data. Typically, you retrieve a
Bitmap by name from a GIF file:
bitmap = Bitmap.bitmapNamed("ColorBackground.gif");
You can also use a Bitmap for offscreen drawing. You can construct a
Graphics object to draw into a Bitmap using the code:
bitmap = new Bitmap(width, height);
g = new Graphics(bitmap);
Constructors
.Bitmap
public Bitmap()
- Constructs a Bitmap with no name and no data. This method is only
useful when decoding.
.Bitmap
public Bitmap(int width,
int height)
- Constructs a Bitmap of size (width, height) with blank
contents. Typically, you use Bitmaps with no contents for offscreen
composition.
.Bitmap
public Bitmap(int pixels[],
int width,
int height)
- Constructs a Bitmap of size (width, height) with
contents derived from the integer array pixels. Equivalent to
the code:
Bitmap(pixels, width, height, 0, width)
- See Also:
- Bitmap
.Bitmap
public Bitmap(int pixels[],
int width,
int height,
int offset,
int scanSize)
- Constructs a Bitmap of size (width, height) with
contents derived from the integer array pixels. offset
indicates the position of the first pixel in the array. scanSize
indicates the number of pixels in the array per line.
The format follows the default Java color model, where each pixel is a
32-bit integer. Bits 24-31 are the alpha transparency, bits 16-23 are
the red value, bits 8-15 are the green value, and bits 0-7 are the blue
value.
Methods
public static synchronized Bitmap bitmapNamed(String bitmapName,
boolean startLoading,
boolean cache)
- Returns the Bitmap named bitmapName. The application maintains
a cache of named Bitmaps that it checks first. If not located in
the cache, this method looks for the specified bitmap in the "images"
directory in the same directory as the Application's index.html
file. In other words, it constructs the URL
"codebase"/images/bitmapName
and attempts to load this image. bitmapName can specify a
file name or path, such as "newImages/ColorBackground.gif".
This method starts loading the bitmap's data if startLoading is
true. Otherwise, the IFC retrieves the data when needed.
If cache is true the bitmap will be added to an Application
cache for faster future lookups. Images placed in the cache are not
released for the lifetime of the Application object. If cache
is false, the image will not be placed in the application cache, and
it will be released in the normal manner.
public static Bitmap bitmapNamed(String bitmapName,
boolean startLoading)
- Returns the Bitmap named bitmapName. The application maintains
a cache of named Bitmaps that it checks first. If not located in
the cache, this method looks for the specified bitmap in the "images"
directory in the same directory as the Application's index.html
file. In other words, it constructs the URL
"codebase"/images/bitmapName
and attempts to load this image. bitmapName can specify a
file name or path, such as "newImages/ColorBackground.gif".
This method starts loading the bitmap's data if startLoading is
true. Otherwise, the IFC retrieves the data when needed.
This call is equivelent to:
Bitmap.bitmapNamed(bitmapName, startLoading, true);
- See Also:
- bitmapNamed
public static Bitmap bitmapNamed(String bitmapName)
- Convenience method for retrieving the bitmap bitmapName.
Immediately begins loading its data. Equivalent to the code:
Bitmap.bitmapNamed(bitmapName, true, true);
- See Also:
- bitmapNamed
public static Bitmap bitmapFromURL(java.net.URL url)
- Returns a Bitmap initialized with data from the URL url.
public Graphics createGraphics()
- Returns a graphics object that can be used to draw into the Bitmap.
The dispose() method should be called on this object when no
longer needed, to immediately free its
resources. Bitmap subclasses can override this method to
provide callers a Graphics subclass instance.
public boolean grabPixels(int pixels[])
- Fills the integer array pixels with 32-bit pixel values
for the entire Bitmap. The array should be large enough to hold
(width() * height()) values. Equivalent to the code:
grabPixels(pixels, 0, 0, width(), height(), 0, width());
Returns true on success, false on failure.
- See Also:
- Bitmap, grabPixels
public boolean grabPixels(int pixels[],
int x,
int y,
int width,
int height,
int offset,
int scanSize)
- Fills the integer array pixels with 32-bit pixel values
for the Bitmap. The array should be large enough to hold (width
height) values. x and y determine the origin of
the rectangle of pixels to retrieve from the Bitmap, relative to the
default (unscaled) size of the Bitmap. width and height
indicate the size of the rectangle. offset indicates how far
into the array the first pixel should be stored. scanSize is the
distance from the start of one row of pixels to the start of the next
row in the array. The pixel format follows the default Java RGB color
model.
Returns true on success, false on failure.
- See Also:
- Bitmap
public String name()
- Returns the name used to load the Bitmap. Returns null
if the Bitmap was not obtained via Bitmap.bitmapNamed().
- Overrides:
- name in class Image
- See Also:
- bitmapNamed
public int width()
- Returns the Bitmap's width. Begins loading the Bitmap's data, if
necessary, returning once the Bitmap's size information becomes
available.
- Overrides:
- width in class Image
public int height()
- Returns the Bitmap's height. Begins loading the Bitmap's data, if
necessary, returning once the Bitmap's size information becomes
available.
- Overrides:
- height in class Image
public void setTransparent(boolean transparent)
- Sets whether the Bitmap is transparent.
- See Also:
- isTransparent
public boolean isTransparent()
- Returns true if the Bitmap is transparent. This method does
not check the Bitmap's data. A Bitmap assumes itself
transparent unless modified using the setTransparent() method.
Returning true is always safe, but an Image user may
be able to avoid drawing the region under the Image if this method
returns false.
- Overrides:
- isTransparent in class Image
- See Also:
- setTransparent
public void drawAt(Graphics g,
int x,
int y)
- Draws the Bitmap at (x, y).
- Overrides:
- drawAt in class Image
public void drawScaled(Graphics g,
int x,
int y,
int width,
int height)
- Draws the Bitmap scaled to fit the supplied rectangle.
- Overrides:
- drawScaled in class Image
public void loadData()
- Begins the loading of the Bitmap's data. This method does not return
until the data has been loaded, unless the Bitmap is set to be loaded
incrementally. In general, you never call this method.
Any methods requiring the Bitmap's data will automatically call
loadData().
public boolean hasLoadedData()
- Returns true if the Bitmap attempted to load its data and
succeeded.
- See Also:
- loadData
public void setLoadsIncrementally(boolean flag)
- Configures the Bitmap to load and display its data incrementally.
An incrementally-loaded Bitmap notifies its update Target when
additional data becomes available, and when drawn, draws all available
data rather than waiting until all data is present.
- See Also:
- setUpdateTarget
public boolean loadsIncrementally()
- Returns true if the Bitmap's data will load incrementally.
- See Also:
- setLoadsIncrementally
public synchronized Rect updateRect()
- Returns the Rect defining the newly-available portion of an
incrementally-loaded Bitmap. Returns an empty Rect if the Bitmap
is not loading incrementally, or no additional data has become
available since this method was most recently called.
- See Also:
- setLoadsIncrementally
public synchronized void setUpdateTarget(Target aTarget)
- Sets the Target that should receive a command when the
incrementally-loaded Bitmap receives additional data.
- See Also:
- setLoadsIncrementally, setUpdateCommand
public synchronized Target updateTarget()
- Returns the Bitmap's update target.
- See Also:
- setUpdateTarget
public synchronized void setUpdateCommand(String command)
- Sets the command sent to an incrementally-loaded Bitmap's update Target
when additional data becomes available.
- See Also:
- setUpdateTarget
public synchronized String updateCommand()
- Returns the Bitmap's update command.
- See Also:
- setUpdateCommand
public boolean isValid()
- Returns true if the Bitmap's data was successfully loaded
and is valid.
- See Also:
- loadData
public void flush()
- Flushes all resources allocated to the Bitmap, including cached
pixel data and system resources.
public String toString()
- Returns the Bitmap's String representation.
- Overrides:
- toString in class Object
public void describeClassInfo(ClassInfo info)
- Describes the Bitmap class' coding information.
- Overrides:
- describeClassInfo in class Image
- See Also:
- describeClassInfo
public void encode(Encoder encoder) throws CodingException
- Encodes the Bitmap. For now, Bitmaps are only encodable by name.
- Overrides:
- encode in class Image
- See Also:
- encode
public void decode(Decoder decoder) throws CodingException
- Decodes the Bitmap. For now, this simply decodes the name
and calls Bitmap.bitmapNamed().
- Overrides:
- decode in class Image
- See Also:
- decode
All Packages Class Hierarchy This Package Previous Next Index
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Oct 1997