Java 类java.awt.image.ImageObserver 实例源码

项目:incubator-netbeans    文件:ImageUtilities.java   
private static void ensureLoaded(Image image) {
    if (
        (Toolkit.getDefaultToolkit().checkImage(image, -1, -1, null) &
            (ImageObserver.ALLBITS | ImageObserver.FRAMEBITS)) != 0
    ) {
        return;
    }

    synchronized (tracker) {
        int id = ++mediaTrackerID;
        tracker.addImage(image, id);

        try {
            tracker.waitForID(id, 0);
        } catch (InterruptedException e) {
            System.out.println("INTERRUPTED while loading Image");
        }

        // #262804 assertation disabled because of error, when using ImageFilter
        // assert (tracker.statusID(id, false) == MediaTracker.COMPLETE) : "Image loaded";
        tracker.removeImage(image, id);
    }
}
项目:openjdk-jdk10    文件:ImageRepresentation.java   
public synchronized void reconstruct(int flags) {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    int missinginfo = flags & ~availinfo;
    if ((availinfo & ImageObserver.ERROR) == 0 && missinginfo != 0) {
        numWaiters++;
        try {
            startProduction();
            missinginfo = flags & ~availinfo;
            while ((availinfo & ImageObserver.ERROR) == 0 &&
                   missinginfo != 0)
            {
                try {
                    wait();
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    return;
                }
                missinginfo = flags & ~availinfo;
            }
        } finally {
            decrementWaiters();
        }
    }
}
项目:VASSAL-src    文件:ScaledImagePainter.java   
public void draw(Graphics g, int x, int y, double scale, ImageObserver obs) {
  if (srcOp == null || scale <= 0) return;

  final BufferedImage img;
  if (scale == 1.0) {
    img = srcOp.getImage();
  }
  else {
    if (scaleOp == null || scaleOp.getScale() != scale) {
      scaleOp = Op.scale(srcOp, scale);
    }
    img = scaleOp.getImage();
  }

  if (img == null) return;

  g.drawImage(img, x, y, obs);
}
项目:openjdk-jdk10    文件:DrawImage.java   
public boolean scaleImage(SunGraphics2D sg, Image img,
                          int dx1, int dy1, int dx2, int dy2,
                          int sx1, int sy1, int sx2, int sy2,
                          Color bgColor,
                          ImageObserver observer) {
    if (!(img instanceof ToolkitImage)) {
        return scaleImage(sg, img, dx1, dy1, dx2, dy2,
                          sx1, sy1, sx2, sy2, bgColor);
    } else {
        ToolkitImage sunimg = (ToolkitImage)img;
        if (!imageReady(sunimg, observer)) {
            return false;
        }
        ImageRepresentation ir = sunimg.getImageRep();
        return ir.drawToBufImage(sg, sunimg, dx1, dy1, dx2, dy2,
                                 sx1, sy1, sx2, sy2, bgColor, observer);
    }
}
项目:openjdk-jdk10    文件:LUTCompareTest.java   
public boolean imageUpdate(Image image, int info,
                           int x, int y, int w, int h) {
    if (image == this.image) {
        System.out.println("Image status: " + dump(info));
        synchronized(this) {
            isReady = (info & ImageObserver.ALLBITS) != 0;
                if (isReady) {
                    synchronized(lock) {
                        lock.notifyAll();
                    }
                }
        }
        return !isReady;
    } else {
        return true;
    }
}
项目:myster    文件:TabUtilities.java   
public static int[] getPixels(Image img, int x, int y, int w, int h) {
    int[] pixels = new int[w * h]; // PixelGrabber does the work of getting
                                   // actual RGB pixel values for // us from
                                   // the image.
    PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
        System.err.println("interrupted waiting for pixels!");
    }

    if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
        System.err.println("image fetch aborted or errored");
    }
    return pixels;
}
项目:OpenJSharp    文件:PathGraphics.java   
public boolean drawImage(Image img, int x, int y,
                         Color bgcolor,
                         ImageObserver observer) {

    if (img == null) {
        return true;
    }

    boolean result;
    int srcWidth = img.getWidth(null);
    int srcHeight = img.getHeight(null);

    if (srcWidth < 0 || srcHeight < 0) {
        result = false;
    } else {
        result = drawImage(img, x, y, srcWidth, srcHeight, bgcolor, observer);
    }

    return result;
}
项目:jdk8u-jdk    文件:ImageRepresentation.java   
synchronized void abort() {
    image.getSource().removeConsumer(this);
    consuming = false;
    newbits = null;
    bimage = null;
    biRaster = null;
    cmodel = null;
    srcLUT = null;
    isDefaultBI = false;
    isSameCM = false;

    newInfo(image, ImageObserver.ABORT, -1, -1, -1, -1);
    availinfo &= ~(ImageObserver.SOMEBITS
                   | ImageObserver.FRAMEBITS
                   | ImageObserver.ALLBITS
                   | ImageObserver.ERROR);
}
项目:openjdk-jdk10    文件:DrawImage.java   
public boolean copyImage(SunGraphics2D sg, Image img,
                         int dx, int dy, int sx, int sy, int w, int h,
                         Color bgColor,
                         ImageObserver observer) {
    if (!(img instanceof ToolkitImage)) {
        return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
    } else {
        ToolkitImage sunimg = (ToolkitImage)img;
        if (!imageReady(sunimg, observer)) {
            return false;
        }
        ImageRepresentation ir = sunimg.getImageRep();
        return ir.drawToBufImage(sg, sunimg,
                                 dx, dy, (dx + w), (dy + h),
                                 sx, sy, (sx + w), (sy + h),
                                 bgColor, observer);
    }
}
项目:OpenJSharp    文件:ImageRepresentation.java   
public boolean prepare(ImageObserver iw) {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    if ((availinfo & ImageObserver.ERROR) != 0) {
        if (iw != null) {
            iw.imageUpdate(image, ImageObserver.ERROR|ImageObserver.ABORT,
                           -1, -1, -1, -1);
        }
        return false;
    }
    boolean done = ((availinfo & ImageObserver.ALLBITS) != 0);
    if (!done) {
        addWatcher(iw);
        startProduction();
        // Some producers deliver image data synchronously
        done = ((availinfo & ImageObserver.ALLBITS) != 0);
    }
    return done;
}
项目:OpenJSharp    文件:DrawImage.java   
public boolean copyImage(SunGraphics2D sg, Image img,
                         int dx, int dy, int sx, int sy, int w, int h,
                         Color bgColor,
                         ImageObserver observer) {
    if (!(img instanceof ToolkitImage)) {
        return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
    } else {
        ToolkitImage sunimg = (ToolkitImage)img;
        if (!imageReady(sunimg, observer)) {
            return false;
        }
        ImageRepresentation ir = sunimg.getImageRep();
        return ir.drawToBufImage(sg, sunimg,
                                 dx, dy, (dx + w), (dy + h),
                                 sx, sy, (sx + w), (sy + h),
                                 bgColor, observer);
    }
}
项目:OpenJSharp    文件:ToolkitImage.java   
private synchronized void reconstruct(int flags) {
    if ((flags & ~availinfo) != 0) {
        if ((availinfo & ImageObserver.ERROR) != 0) {
            return;
        }
        ImageRepresentation ir = getImageRep();
        ir.startProduction();
        while ((flags & ~availinfo) != 0) {
            try {
                wait();
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                return;
            }
            if ((availinfo & ImageObserver.ERROR) != 0) {
                return;
            }
        }
    }
}
项目:openjdk-jdk10    文件:ComponentOperator.java   
/**
 * Maps {@code Component.prepareImage(Image, int, int, ImageObserver)}
 * through queue
 */
public boolean prepareImage(final Image image, final int i, final int i1, final ImageObserver imageObserver) {
    return (runMapping(new MapBooleanAction("prepareImage") {
        @Override
        public boolean map() {
            return getSource().prepareImage(image, i, i1, imageObserver);
        }
    }));
}
项目:openjdk-jdk10    文件:ImageRepresentation.java   
public boolean drawToBufImage(Graphics g, ToolkitImage img,
                              AffineTransform xform,
                              ImageObserver iw)
{
    Graphics2D g2 = (Graphics2D) g;

    if (src != null) {
        src.checkSecurity(null, false);
    }
    if ((availinfo & ImageObserver.ERROR) != 0) {
        if (iw != null) {
            iw.imageUpdate(image, ImageObserver.ERROR|ImageObserver.ABORT,
                           -1, -1, -1, -1);
        }
        return false;
    }
    boolean done  = ((availinfo & ImageObserver.ALLBITS) != 0);
    boolean abort = ((availinfo & ImageObserver.ABORT) != 0);

    if (!done && !abort) {
        addWatcher(iw);
        startProduction();
        // Some producers deliver image data synchronously
        done = ((availinfo & ImageObserver.ALLBITS) != 0);
    }

    if (done || (0 != (availinfo & ImageObserver.FRAMEBITS))) {
        g2.drawImage (bimage, xform, null);
    }

    return done;
}
项目:openjdk-jdk10    文件:ToolkitImage.java   
public void preload(ImageObserver iw) {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    if ((availinfo & ImageObserver.ALLBITS) == 0) {
        addWatcher(iw, true);
    }
}
项目:OpenJSharp    文件:SunGraphics2D.java   
/**
 * Draws an image at x,y in nonblocking mode with a solid background
 * color and a callback object.
 */
public boolean drawImage(Image img, int x, int y, Color bg,
                         ImageObserver observer) {

    if (img == null) {
        return true;
    }

    if (isHiDPIImage(img)) {
        final int imgW = img.getWidth(null);
        final int imgH = img.getHeight(null);
        return drawHiDPIImage(img, x, y, x + imgW, y + imgH, 0, 0, imgW,
                              imgH, bg, observer);
    }

    try {
        return imagepipe.copyImage(this, img, x, y, bg, observer);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            return imagepipe.copyImage(this, img, x, y, bg, observer);
        } catch (InvalidPipeException e2) {
            // Still catching the exception; we are not yet ready to
            // validate the surfaceData correctly.  Fail for now and
            // try again next time around.
            return false;
        }
    } finally {
        surfaceData.markDirty();
    }
}
项目:openjdk-jdk10    文件:NullPipe.java   
public boolean scaleImage(SunGraphics2D sg, Image img,
                          int dx1, int dy1, int dx2, int dy2,
                          int sx1, int sy1, int sx2, int sy2,
                          Color bgColor,
                          ImageObserver observer) {
    return false;
}
项目:openjdk-jdk10    文件:ToolkitImage.java   
synchronized void infoDone(int status) {
    if (status == ImageConsumer.IMAGEERROR ||
        ((~availinfo) & (ImageObserver.WIDTH |
                         ImageObserver.HEIGHT)) != 0) {
        addInfo(ImageObserver.ERROR);
    } else if ((availinfo & ImageObserver.PROPERTIES) == 0) {
        setProperties(null);
    }
}
项目:qupath-tracking-extension    文件:HeatmapOverlay.java   
@Override
public void paintOverlay(Graphics2D g2d, ImageRegion imageRegion, double downsampleFactor, ImageObserver observer, boolean paintCompletely) {
    if (trackerFeatures != null) {
        if (doPaintBoundsHeatmap.get()) {
            paintBoundsHeatmap(g2d);
        }
        if (doPaintCursorHeatmap.get()) {
            paintCursorHeatmap(g2d);
        }
        if (doPaintEyeHeatmap.get()) {
            paintEyeHeatmap(g2d);
        }
    }
}
项目:jdk8u-jdk    文件:SunGraphics2D.java   
/**
 * Draws an image at x,y in nonblocking mode with a solid background
 * color and a callback object.
 */
public boolean drawImage(Image img, int x, int y, Color bg,
                         ImageObserver observer) {

    if (img == null) {
        return true;
    }

    if (isHiDPIImage(img)) {
        final int imgW = img.getWidth(null);
        final int imgH = img.getHeight(null);
        return drawHiDPIImage(img, x, y, x + imgW, y + imgH, 0, 0, imgW,
                              imgH, bg, observer);
    }

    try {
        return imagepipe.copyImage(this, img, x, y, bg, observer);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            return imagepipe.copyImage(this, img, x, y, bg, observer);
        } catch (InvalidPipeException e2) {
            // Still catching the exception; we are not yet ready to
            // validate the surfaceData correctly.  Fail for now and
            // try again next time around.
            return false;
        }
    } finally {
        surfaceData.markDirty();
    }
}
项目:openjdk-jdk10    文件:SunGraphics2D.java   
/**
 * Draws a subrectangle of an image scaled to a destination rectangle
 * in nonblocking mode with a callback object.
 */
public boolean drawImage(Image img,
                         int dx1, int dy1, int dx2, int dy2,
                         int sx1, int sy1, int sx2, int sy2,
                         ImageObserver observer) {
    return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null,
                     observer);
}
项目:OpenJSharp    文件:ToolkitImage.java   
private synchronized void addWatcher(ImageObserver iw, boolean load) {
    if ((availinfo & ImageObserver.ERROR) != 0) {
        if (iw != null) {
            iw.imageUpdate(this, ImageObserver.ERROR|ImageObserver.ABORT,
                           -1, -1, -1, -1);
        }
        return;
    }
    ImageRepresentation ir = getImageRep();
    ir.addWatcher(iw);
    if (load) {
        ir.startProduction();
    }
}
项目:OpenJSharp    文件:ImageRepresentation.java   
synchronized void dispose() {
    image.getSource().removeConsumer(this);
    consuming = false;
    newbits = null;
    availinfo &= ~(ImageObserver.SOMEBITS
                   | ImageObserver.FRAMEBITS
                   | ImageObserver.ALLBITS);
}
项目:OpenJSharp    文件:ImageWatched.java   
public void removeWatcher(ImageObserver iw) {
    synchronized (this) {
        watcherList = watcherList.removeWatcher(iw);
    }
    if (watcherList == endlink) {
        notifyWatcherListEmpty();
    }
}
项目:jdk8u-jdk    文件:ImageRepresentation.java   
public boolean drawToBufImage(Graphics g, ToolkitImage img,
                              int x, int y, Color bg,
                              ImageObserver iw) {

    if (src != null) {
        src.checkSecurity(null, false);
    }
    if ((availinfo & ImageObserver.ERROR) != 0) {
        if (iw != null) {
            iw.imageUpdate(image, ImageObserver.ERROR|ImageObserver.ABORT,
                           -1, -1, -1, -1);
        }
        return false;
    }
    boolean done  = ((availinfo & ImageObserver.ALLBITS) != 0);
    boolean abort = ((availinfo & ImageObserver.ABORT) != 0);

    if (!done && !abort) {
        addWatcher(iw);
        startProduction();
        // Some producers deliver image data synchronously
        done = ((availinfo & ImageObserver.ALLBITS) != 0);
    }

    if (done || (0 != (availinfo & ImageObserver.FRAMEBITS))) {
        g.drawImage (bimage, x, y, bg, null);
    }

    return done;
}
项目:OpenJSharp    文件:ImageRepresentation.java   
private synchronized void checkConsumption() {
    if (isWatcherListEmpty() && numWaiters == 0 &&
        ((availinfo & ImageObserver.ALLBITS) == 0))
    {
        dispose();
    }
}
项目:BaseClient    文件:TextureAnimations.java   
public static BufferedImage scaleBufferedImage(BufferedImage p_scaleBufferedImage_0_, int p_scaleBufferedImage_1_, int p_scaleBufferedImage_2_)
{
    BufferedImage bufferedimage = new BufferedImage(p_scaleBufferedImage_1_, p_scaleBufferedImage_2_, 2);
    Graphics2D graphics2d = bufferedimage.createGraphics();
    graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    graphics2d.drawImage(p_scaleBufferedImage_0_, 0, 0, p_scaleBufferedImage_1_, p_scaleBufferedImage_2_, (ImageObserver)null);
    return bufferedimage;
}
项目:OpenJSharp    文件:ToolkitImage.java   
/**
 * Return the width of the original image source.
 * If the width isn't known, then the ImageObserver object will be
 * notified when the data is available.
 */
public synchronized int getWidth(ImageObserver iw) {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    if ((availinfo & ImageObserver.WIDTH) == 0) {
        addWatcher(iw, true);
        if ((availinfo & ImageObserver.WIDTH) == 0) {
            return -1;
        }
    }
    return width;
}
项目:BaseClient    文件:TextureUtils.java   
public static BufferedImage scaleToPowerOfTwo(BufferedImage p_scaleToPowerOfTwo_0_, int p_scaleToPowerOfTwo_1_)
{
    if (p_scaleToPowerOfTwo_0_ == null)
    {
        return p_scaleToPowerOfTwo_0_;
    }
    else
    {
        int i = p_scaleToPowerOfTwo_0_.getWidth();
        int j = p_scaleToPowerOfTwo_0_.getHeight();
        int k = Math.max(i, p_scaleToPowerOfTwo_1_);
        k = MathHelper.roundUpToPowerOfTwo(k);

        if (k == i)
        {
            return p_scaleToPowerOfTwo_0_;
        }
        else
        {
            int l = j * k / i;
            BufferedImage bufferedimage = new BufferedImage(k, l, 2);
            Graphics2D graphics2d = bufferedimage.createGraphics();
            Object object = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;

            if (k % i != 0)
            {
                object = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
            }

            graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, object);
            graphics2d.drawImage(p_scaleToPowerOfTwo_0_, 0, 0, k, l, (ImageObserver)null);
            return bufferedimage;
        }
    }
}
项目:openjdk-jdk10    文件:ImageRepresentation.java   
public int check(ImageObserver iw) {

        if (src != null) {
            src.checkSecurity(null, false);
        }
        if ((availinfo & (ImageObserver.ERROR | ImageObserver.ALLBITS)) == 0) {
            addWatcher(iw);
        }

        return availinfo;
    }
项目:openjdk-jdk10    文件:DrawImage.java   
public boolean transformImage(SunGraphics2D sg, Image img,
                              AffineTransform atfm,
                              ImageObserver observer) {
    if (!(img instanceof ToolkitImage)) {
        transformImage(sg, img, 0, 0, atfm, sg.interpolationType);
        return true;
    } else {
        ToolkitImage sunimg = (ToolkitImage)img;
        if (!imageReady(sunimg, observer)) {
            return false;
        }
        ImageRepresentation ir = sunimg.getImageRep();
        return ir.drawToBufImage(sg, sunimg, atfm, observer);
    }
}
项目:jdk8u-jdk    文件:ValidatePipe.java   
public boolean transformImage(SunGraphics2D sg, Image img,
                              AffineTransform atfm,
                              ImageObserver observer) {
    if (validate(sg)) {
        return sg.imagepipe.transformImage(sg, img, atfm, observer);
    } else {
        return false;
    }
}
项目:openjdk-jdk10    文件:MultiResolutionImageTest.java   
static void testToolkitImageObserver(final Image image) {

        ImageObserver observer = new ImageObserver() {

            @Override
            public boolean imageUpdate(Image img, int infoflags, int x, int y,
                int width, int height) {

                if (img != image) {
                    throw new RuntimeException("Wrong image in observer");
                }

                if ((infoflags & (ImageObserver.ERROR | ImageObserver.ABORT))
                    != 0) {
                    throw new RuntimeException("Error during image loading");
                }

                return (infoflags & ImageObserver.ALLBITS) == 0;

            }
        };

        final BufferedImage bufferedImage2x = new BufferedImage(2 * IMAGE_WIDTH,
            2 * IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2x = (Graphics2D) bufferedImage2x.getGraphics();
        setImageScalingHint(g2x, true);

        g2x.drawImage(image, 0, 0, 2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT, 0, 0,
            IMAGE_WIDTH, IMAGE_HEIGHT, observer);

    }
项目:OpenJSharp    文件:ImageRepresentation.java   
synchronized void abort() {
    image.getSource().removeConsumer(this);
    consuming = false;
    bimage = null;
    bitmap = null;

    newInfo(image, ImageObserver.ABORT, -1, -1, -1, -1);
    availinfo &= ~(ImageObserver.SOMEBITS
                   | ImageObserver.FRAMEBITS
                   | ImageObserver.ALLBITS
                   | ImageObserver.ERROR);
}
项目:openjdk-jdk10    文件:ToolkitImage.java   
/**
 * Return the height of the original image source.
 * If the height isn't known, then the image is reconstructed.
 */
public int getHeight() {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    if ((availinfo & ImageObserver.HEIGHT) == 0) {
        reconstruct(ImageObserver.HEIGHT);
    }
    return height;
}
项目:openjdk-jdk10    文件:ValidatePipe.java   
public boolean transformImage(SunGraphics2D sg, Image img,
                              AffineTransform atfm,
                              ImageObserver observer) {
    if (validate(sg)) {
        return sg.imagepipe.transformImage(sg, img, atfm, observer);
    } else {
        return false;
    }
}
项目:OpenJSharp    文件:ValidatePipe.java   
public boolean scaleImage(SunGraphics2D sg, Image img,
                          int dx1, int dy1, int dx2, int dy2,
                          int sx1, int sy1, int sx2, int sy2,
                          Color bgColor,
                          ImageObserver observer) {
    if (validate(sg)) {
        return sg.imagepipe.scaleImage(sg, img, dx1, dy1, dx2, dy2,
                                       sx1, sy1, sx2, sy2, bgColor,
                                       observer);
    } else {
        return false;
    }
}
项目:openjdk-jdk10    文件:ImageRepresentation.java   
public void setProperties(Hashtable<?,?> props) {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    image.setProperties(props);
    newInfo(image, ImageObserver.PROPERTIES, 0, 0, 0, 0);
}
项目:OpenJSharp    文件:DrawImage.java   
protected static boolean imageReady(ToolkitImage sunimg,
                                    ImageObserver observer)
{
    if (sunimg.hasError()) {
        if (observer != null) {
            observer.imageUpdate(sunimg,
                                 ImageObserver.ERROR|ImageObserver.ABORT,
                                 -1, -1, -1, -1);
        }
        return false;
    }
    return true;
}
项目:openjdk-jdk10    文件:ValidatePipe.java   
public boolean scaleImage(SunGraphics2D sg, Image img, int x, int y,
                          int w, int h,
                          Color bgColor,
                          ImageObserver observer) {
    if (validate(sg)) {
        return sg.imagepipe.scaleImage(sg, img, x, y, w, h, bgColor,
                                       observer);
    } else {
        return false;
    }
}