List of usage examples for java.awt.image ImageObserver ALLBITS
int ALLBITS
To view the source code for java.awt.image ImageObserver ALLBITS.
Click Source Link
From source file:Main.java
/** * Decodes the bits of a java.awt.image.ImageObserver infoflag into a human * readable string.//w w w.j a v a 2s . c o m * * @param infoflag * the flag to decode * @return a string describing the flag */ public static String imageObserverInfoflagToString(int infoflag) { String out = ""; if ((infoflag & ImageObserver.ABORT) == ImageObserver.ABORT) out += "ABORT "; if ((infoflag & ImageObserver.ALLBITS) == ImageObserver.ALLBITS) out += "ALLBITS "; if ((infoflag & ImageObserver.ERROR) == ImageObserver.ERROR) out += "ERROR "; if ((infoflag & ImageObserver.FRAMEBITS) == ImageObserver.FRAMEBITS) out += "FRAMEBITS "; if ((infoflag & ImageObserver.HEIGHT) == ImageObserver.HEIGHT) out += "HEIGHT "; if ((infoflag & ImageObserver.PROPERTIES) == ImageObserver.PROPERTIES) out += "PROPERTIES "; if ((infoflag & ImageObserver.SOMEBITS) == ImageObserver.SOMEBITS) out += "SOMEBITS "; if ((infoflag & ImageObserver.WIDTH) == ImageObserver.WIDTH) out += "WIDTH "; return out; }
From source file:MainClass.java
public void init() { MediaTracker mt = new MediaTracker(this); i = getImage(getDocumentBase(), "ora-icon.gif"); mt.addImage(i, 0);/*from www . j a va 2s . co m*/ try { mt.waitForAll(); int width = i.getWidth(this); int height = i.getHeight(this); int pixels[] = new int[width * height]; PixelGrabber pg = new PixelGrabber(i, 0, 0, width, height, pixels, 0, width); if (pg.grabPixels() && ((pg.status() & ImageObserver.ALLBITS) != 0)) { j = createImage( new MemoryImageSource(width, height, rowFlipPixels(pixels, width, height), 0, width)); k = createImage( new MemoryImageSource(width, height, colFlipPixels(pixels, width, height), 0, width)); l = createImage( new MemoryImageSource(height, width, rot90Pixels(pixels, width, height), 0, height)); } } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:ImageSize.java
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { if ((infoflags & ImageObserver.ERROR) != 0) { System.out.println("Error loading image!"); System.exit(-1);//w w w . j a va 2 s . c o m } if ((infoflags & ImageObserver.WIDTH) != 0 && (infoflags & ImageObserver.HEIGHT) != 0) rightSize(); if ((infoflags & ImageObserver.SOMEBITS) != 0) repaint(); if ((infoflags & ImageObserver.ALLBITS) != 0) { rightSize(); repaint(); return false; } return true; }
From source file:ImageUtilities.java
/** * Starts loading the given image, returns only when it's done loading. * Note that it's much more efficient to preload a lot of images at once using * the preload(Image []) method instead of this one. * * @return The result of the image loading, either {@link #COMPLETE}, * {@link #ERRORED}, {@link #ABORTED} or {@link #INTERRUPTED}. * * @see #preload(java.awt.Image [], int []) *///from ww w.j av a 2 s . c o m public static int preload(Image image) { Toolkit toolkit = Toolkit.getDefaultToolkit(); // Check if already loaded if ((toolkit.checkImage(image, -1, -1, null) & ImageObserver.ALLBITS) != 0) return COMPLETE; Object lock = new Object(); synchronized (lock) { while (true) { ImageLoadObserver observer = new ImageLoadObserver(lock); toolkit.prepareImage(image, -1, -1, observer); int result = toolkit.checkImage(image, -1, -1, null); if ((result & ImageObserver.ALLBITS) != 0) return COMPLETE; if ((result & ImageObserver.ERROR) != 0) return ERRORED; if ((result & ImageObserver.ABORT) != 0) return ABORTED; try { lock.wait(); return observer.getResult(); } catch (InterruptedException e) { return INTERRUPTED; } } } }
From source file:ImageLoaderApplet.java
/** * Verbose version of ImageConsumer's imageUpdate method */// www. java2s.c o m public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) { System.out.print("Flag(s): "); if ((flags & ImageObserver.WIDTH) != 0) { System.out.print("WIDTH:(" + width + ") "); } if ((flags & ImageObserver.HEIGHT) != 0) { System.out.print("HEIGHT:(" + height + ") "); } if ((flags & ImageObserver.PROPERTIES) != 0) { System.out.print("PROPERTIES "); } if ((flags & ImageObserver.SOMEBITS) != 0) { System.out.print("SOMEBITS(" + x + "," + y + ")->("); System.out.print(width + "," + height + ") "); repaint(); } if ((flags & ImageObserver.FRAMEBITS) != 0) { System.out.print("FRAMEBITS(" + x + "," + y + ")->("); System.out.print(width + "," + height + ") "); repaint(); } if ((flags & ImageObserver.ALLBITS) != 0) { System.out.print("ALLBITS(" + x + "," + y + ")->("); System.out.println(width + "," + height + ") "); repaint(); return false; } if ((flags & ImageObserver.ABORT) != 0) { System.out.println("ABORT \n"); return false; } if ((flags & ImageObserver.ERROR) != 0) { System.out.println("ERROR "); return false; } System.out.println(); return true; }
From source file:ImageUtilities.java
/** * Starts loading the given images, returns only when all the images are done * loading. If you just need to preload one Image, use the preload(Image) method * instead./*w w w . j ava 2s . c om*/ * * @return An array specifying the loading result of each image. Possible values * are {@link #COMPLETE}, {@link #ERRORED} and {@link #ABORTED}. * * @see #preload(Image) */ public static int[] preload(Image[] images, int[] results) { Object[] locks = new Object[images.length]; ImageLoadObserver[] loadObservers = new ImageLoadObserver[images.length]; if ((results == null) || (results.length < images.length)) results = new int[images.length]; Toolkit toolkit = Toolkit.getDefaultToolkit(); for (int i = 0; i < images.length; i++) { locks[i] = new Object(); loadObservers[i] = new ImageLoadObserver(locks[i]); toolkit.prepareImage(images[i], -1, -1, loadObservers[i]); } for (int i = 0; i < images.length; i++) { synchronized (locks[i]) { int result = toolkit.checkImage(images[i], -1, -1, null); if ((result & ImageObserver.ALLBITS) != 0) { results[i] = COMPLETE; continue; } if ((result & ImageObserver.ERROR) != 0) { results[i] = ERRORED; continue; } if ((result & ImageObserver.ABORT) != 0) { results[i] = ABORTED; continue; } try { locks[i].wait(); results[i] = loadObservers[i].getResult(); } catch (InterruptedException e) { results[i] = INTERRUPTED; } } } return results; }
From source file:ImageUtilities.java
/** * Returns whether the specified image is already fully loaded. */// www . ja v a2 s .c om public static boolean isLoaded(Image image) { return (Toolkit.getDefaultToolkit().checkImage(image, -1, -1, null) & ImageObserver.ALLBITS) != 0; }
From source file:WaitingImageObserver.java
/** * Callback function used by AWT to inform that more data is available. The * observer waits until either all data is loaded or AWT signals that the * image cannot be loaded.//from w w w . j a v a 2 s .com * * @param img the image being observed. * @param infoflags the bitwise inclusive OR of the following * flags: <code>WIDTH</code>, <code>HEIGHT</code>, * <code>PROPERTIES</code>, <code>SOMEBITS</code>, * <code>FRAMEBITS</code>, <code>ALLBITS</code>, * <code>ERROR</code>, <code>ABORT</code>. * @param x the <i>x</i> coordinate. * @param y the <i>y</i> coordinate. * @param width the width. * @param height the height. * * @return <code>false</code> if the infoflags indicate that the * image is completely loaded; <code>true</code> otherwise. */ public synchronized boolean imageUpdate(final Image img, final int infoflags, final int x, final int y, final int width, final int height) { if ((infoflags & ImageObserver.ALLBITS) == ImageObserver.ALLBITS) { this.lock = false; this.error = false; notifyAll(); return false; } else if ((infoflags & ImageObserver.ABORT) == ImageObserver.ABORT || (infoflags & ImageObserver.ERROR) == ImageObserver.ERROR) { this.lock = false; this.error = true; notifyAll(); return false; } //notifyAll(); return true; }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_//from ww w . j a v a 2 s .c o m * * @param img _more_ * @param flags _more_ * @param x _more_ * @param y _more_ * @param width _more_ * @param height _more_ * * @return _more_ */ public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) { if ((flags & ImageObserver.ERROR) != 0) { return false; } updateDashboard(); if ((flags & ImageObserver.ALLBITS) != 0) { return false; } return true; }
From source file:ucar.unidata.idv.control.chart.ChartManager.java
/** * Handle the image update// w w w . j av a 2s . c o m * * @param img img * @param flags flags * @param x x * @param y y * @param width width * @param height height * * @return keep going */ public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) { boolean all = (flags & ImageObserver.ALLBITS) != 0; if (all) { getContents().repaint(); return false; } return true; }