< prev index next >

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

Print this page




1141     }
1142 
1143     /**
1144      * Indicates whether image is animated.
1145      */
1146     boolean isAnimation() {
1147         return animation != null;
1148     }
1149 
1150     boolean pixelsReadable() {
1151         return (getProgress() >= 1.0 && !isAnimation() && !isError());
1152     }
1153 
1154     private PixelReader reader;
1155     /**
1156      * This method returns a {@code PixelReader} that provides access to
1157      * read the pixels of the image, if the image is readable.
1158      * If this method returns null then this image does not support reading
1159      * at this time.
1160      * This method will return null if the image is being loaded from a
1161      * source and is still incomplete {the progress is still < 1.0) or if
1162      * there was an error.
1163      * This method may also return null for some images in a format that
1164      * is not supported for reading and writing pixels to.
1165      *
1166      * @return the {@code PixelReader} for reading the pixel data of the image
1167      * @since JavaFX 2.2
1168      */
1169     public final PixelReader getPixelReader() {
1170         if (!pixelsReadable()) {
1171             return null;
1172         }
1173         if (reader == null) {
1174             reader = new PixelReader() {
1175                 @Override
1176                 public PixelFormat getPixelFormat() {
1177                     PlatformImage pimg = platformImage.get();
1178                     return pimg.getPlatformPixelFormat();
1179                 }
1180 
1181                 @Override




1141     }
1142 
1143     /**
1144      * Indicates whether image is animated.
1145      */
1146     boolean isAnimation() {
1147         return animation != null;
1148     }
1149 
1150     boolean pixelsReadable() {
1151         return (getProgress() >= 1.0 && !isAnimation() && !isError());
1152     }
1153 
1154     private PixelReader reader;
1155     /**
1156      * This method returns a {@code PixelReader} that provides access to
1157      * read the pixels of the image, if the image is readable.
1158      * If this method returns null then this image does not support reading
1159      * at this time.
1160      * This method will return null if the image is being loaded from a
1161      * source and is still incomplete {the progress is still &lt;1.0) or if
1162      * there was an error.
1163      * This method may also return null for some images in a format that
1164      * is not supported for reading and writing pixels to.
1165      *
1166      * @return the {@code PixelReader} for reading the pixel data of the image
1167      * @since JavaFX 2.2
1168      */
1169     public final PixelReader getPixelReader() {
1170         if (!pixelsReadable()) {
1171             return null;
1172         }
1173         if (reader == null) {
1174             reader = new PixelReader() {
1175                 @Override
1176                 public PixelFormat getPixelFormat() {
1177                     PlatformImage pimg = platformImage.get();
1178                     return pimg.getPlatformPixelFormat();
1179                 }
1180 
1181                 @Override


< prev index next >