modules/graphics/src/main/java/javafx/scene/image/Image.java

Print this page




  45 import javafx.beans.property.ReadOnlyDoublePropertyBase;
  46 import javafx.beans.property.ReadOnlyDoubleWrapper;
  47 import javafx.beans.property.ReadOnlyObjectProperty;
  48 import javafx.beans.property.ReadOnlyObjectPropertyBase;
  49 import javafx.beans.property.ReadOnlyObjectWrapper;
  50 import javafx.event.ActionEvent;
  51 import javafx.event.EventHandler;
  52 import javafx.scene.paint.Color;
  53 import javafx.util.Duration;
  54 import com.sun.javafx.runtime.async.AsyncOperation;
  55 import com.sun.javafx.runtime.async.AsyncOperationListener;
  56 import com.sun.javafx.tk.ImageLoader;
  57 import com.sun.javafx.tk.PlatformImage;
  58 import com.sun.javafx.tk.Toolkit;
  59 
  60 /**
  61  * The {@code Image} class represents graphical images and is used for loading
  62  * images from a specified URL.
  63  *
  64  * <p>







  65  * Images can be resized as they are loaded (for example to reduce the amount of
  66  * memory consumed by the image). The application can specify the quality of
  67  * filtering used when scaling, and whether or not to preserve the original
  68  * image's aspect ratio.
  69  * </p>
  70  *
  71  * <p>
  72  * All URLs supported by {@link URL} can be passed to the constructor.
  73  * If the passed string is not a valid URL, but a path instead, the Image is
  74  * searched on the classpath in that case.
  75  * </p>
  76  *
  77  * <p>Use {@link ImageView} for displaying images loaded with this
  78  * class. The same {@code Image} instance can be displayed by multiple
  79  * {@code ImageView}s.</p>
  80  *
  81  *<p>Example code for loading images.</p>
  82 
  83 <PRE>
  84 import javafx.scene.image.Image;




  45 import javafx.beans.property.ReadOnlyDoublePropertyBase;
  46 import javafx.beans.property.ReadOnlyDoubleWrapper;
  47 import javafx.beans.property.ReadOnlyObjectProperty;
  48 import javafx.beans.property.ReadOnlyObjectPropertyBase;
  49 import javafx.beans.property.ReadOnlyObjectWrapper;
  50 import javafx.event.ActionEvent;
  51 import javafx.event.EventHandler;
  52 import javafx.scene.paint.Color;
  53 import javafx.util.Duration;
  54 import com.sun.javafx.runtime.async.AsyncOperation;
  55 import com.sun.javafx.runtime.async.AsyncOperationListener;
  56 import com.sun.javafx.tk.ImageLoader;
  57 import com.sun.javafx.tk.PlatformImage;
  58 import com.sun.javafx.tk.Toolkit;
  59 
  60 /**
  61  * The {@code Image} class represents graphical images and is used for loading
  62  * images from a specified URL.
  63  *
  64  * <p>
  65  * Supported image formats are BMP, <a href="http://www.w3.org/Graphics/GIF/spec-gif89a.txt">GIF</a>, <a href="http://www.ijg.org">JPEG</a> and <a href="http://www.libpng.org/pub/png/spec/">PNG</a>.
  66  * BMP format support is limited to the <a href="http://msdn.microsoft.com/en-us/library/dd183376(v=vs.85).aspx">version 3</a>.
  67  * PNG and JPEG images embedded in the BMP files are not supported.<br>
  68  * On the iOS platform images are loaded using native Image I/O framework.
  69  * </p>
  70  *
  71  * <p>
  72  * Images can be resized as they are loaded (for example to reduce the amount of
  73  * memory consumed by the image). The application can specify the quality of
  74  * filtering used when scaling, and whether or not to preserve the original
  75  * image's aspect ratio.
  76  * </p>
  77  *
  78  * <p>
  79  * All URLs supported by {@link URL} can be passed to the constructor.
  80  * If the passed string is not a valid URL, but a path instead, the Image is
  81  * searched on the classpath in that case.
  82  * </p>
  83  *
  84  * <p>Use {@link ImageView} for displaying images loaded with this
  85  * class. The same {@code Image} instance can be displayed by multiple
  86  * {@code ImageView}s.</p>
  87  *
  88  *<p>Example code for loading images.</p>
  89 
  90 <PRE>
  91 import javafx.scene.image.Image;