Java Image Height Get getHeight(java.awt.Image image)

Here you can find the source of getHeight(java.awt.Image image)

Description

get Height

License

Open Source License

Declaration

public static int getHeight(java.awt.Image image) throws InterruptedException 

Method Source Code

//package com.java2s;

public class Main {
    private static java.awt.MediaTracker s_mediaTracker = new java.awt.MediaTracker(new java.awt.Panel());
    private static java.awt.image.ImageObserver s_imageObserver = new java.awt.image.ImageObserver() {
        public boolean imageUpdate(java.awt.Image image, int infoflags, int x, int y, int width, int height) {
            return true;
        }//from w w  w . j a  v a  2 s. co  m
    };

    public static int getHeight(java.awt.Image image) throws InterruptedException {
        waitForImage(image);
        return image.getHeight(s_imageObserver);
    }

    private static void waitForImage(java.awt.Image image) throws InterruptedException {
        s_mediaTracker.addImage(image, 0);
        try {
            s_mediaTracker.waitForID(0);
        } finally {
            s_mediaTracker.removeImage(image);
        }
    }
}

Related

  1. getHeight(final File image)
  2. getHeight(final Image image)
  3. getHeight(Image pImage)