Java Reference
In-Depth Information
While the image is loading, the Image has a property, progress , that holds the
percentage progress of the loading operation. This number is expressed as a num-
ber from 0.0 to 100.0. You can use this, for example, to bind to a ProgressBar
node to display the progress.
var progressBar= ProgressBar {
height: 20
width: bind scene.width
percent: bind image.progress
}
Supported image formats vary by platform; however, on a desktop, the minimum
supported formats are listed in Table 8.1 as defined in the javax.imageio package.
Ta b l e 8 . 1
Java Desktop Standard Image Formats
Format
Mime Type
File Extension
JPEG
image/jpeg
.jpg, .jpeg
PNG
image/png
.png
BMP
image/bmp
.bmp
WBMP
image/vnd.wap.wbmp
.wbmp
GIF
image/gif
.gif
Developer Tip: With Java 1.6, the javax.image.ImageIO class has three methods
that list the supported image types on a given platform. ImageIO.getReaderFormat-
Names() returns the list of supported format names, ImageIO.getReaderFileSuf-
fixes() returns the registered image file extensions, and ImageIO.getReaderMIME-
Types() returns the mime types.
If an error is detected during the image loading process, the error variable will
be set to true. This lets you know that an error has occurred, but it does not let
you know why the error happened. From personal experience, the most common
error is an invalid url , so the runtime system cannot locate the image data.
Developer Warning: One common error is inserting a spurious slash ( / ) char-
acter after the __DIR__ built-in variable. For example, instead of the correct
url: "{__DIR__}figures/myImage.gif" // CORRECT
 
Search WWH ::




Custom Search