Example usage for java.awt MediaTracker MediaTracker

List of usage examples for java.awt MediaTracker MediaTracker

Introduction

In this page you can find the example usage for java.awt MediaTracker MediaTracker.

Prototype

public MediaTracker(Component comp) 

Source Link

Document

Creates a media tracker to track images for a given component.

Usage

From source file:BufferedImageConverter.java

static public BufferedImage createBufferedImage(Image imageIn, int imageType, Component comp) {
    MediaTracker mt = new MediaTracker(comp);
    mt.addImage(imageIn, 0);//from  w w  w  .  jav  a2  s .c om
    try {
        mt.waitForID(0);
    } catch (InterruptedException ie) {
    }
    BufferedImage bufferedImageOut = new BufferedImage(imageIn.getWidth(null), imageIn.getHeight(null),
            imageType);
    Graphics g = bufferedImageOut.getGraphics();
    g.drawImage(imageIn, 0, 0, null);

    return bufferedImageOut;
}

From source file:MainClass.java

public void load() throws MalformedURLException {
    URL url = new URL("image address");
    Image im = Toolkit.getDefaultToolkit().getImage(url);

    MediaTracker mt = new MediaTracker(this);
    mt.addImage(im, 0);/*from ww  w . ja va 2  s .c  o m*/
    try {
        mt.waitForID(0);
    } catch (InterruptedException e) {
        System.err.println("Unexpected interrupt in waitForID!");
        return;
    }
    if (mt.isErrorID(0)) {
        System.err.println("Couldn't load image file " + url);
        return;
    }
}

From source file:MainClass.java

public void load() throws MalformedURLException {
    URL url = new URL("image address");
    Toolkit t = Toolkit.getDefaultToolkit();
    Image im = t.getImage(url);//from  ww w . j a  v  a  2 s  .c om

    MediaTracker mt = new MediaTracker(this);
    mt.addImage(im, 0);
    try {
        mt.waitForID(0);
    } catch (InterruptedException e) {
        System.err.println("Unexpected interrupt in waitForID!");
        return;
    }
    if (mt.isErrorID(0)) {
        System.err.println("Couldn't load image file " + url);
        return;
    }
}

From source file:Main.java

ContentPanel() {
    MediaTracker mt = new MediaTracker(this);
    bgimage = Toolkit.getDefaultToolkit().getImage("a.jpg");
    mt.addImage(bgimage, 0);/*  w w  w .  ja v  a2 s  . co  m*/
    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

ImagePanel() {
    MediaTracker mt = new MediaTracker(this);
    for (int i = 0; i < images.length; i++) {
        imgs[i] = Toolkit.getDefaultToolkit().getImage(images[i]);
        mt.addImage(imgs[i], i);/*  w  ww  .  jav  a  2  s.  com*/
    }
    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:MainClass.java

public void init() {
    MediaTracker mt = new MediaTracker(this);
    i = getImage(getDocumentBase(), "rosey.jpg");
    mt.addImage(i, 0);//  w w w . j  a  va  2s  .co  m
    try {
        mt.waitForAll();
        int width = i.getWidth(this);
        int height = i.getHeight(this);
        j = createImage(new FilteredImageSource(i.getSource(),
                new CropImageFilter(width / 3, height / 3, width / 3, height / 3)));
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:MainClass.java

public void init() {
    MediaTracker mt = new MediaTracker(this);
    i = getImage(getDocumentBase(), "ora-icon.gif");
    mt.addImage(i, 0);/*w w w  .jav  a 2 s  .  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:FilterLab.java

public void init() {
    originalImage = getImage(getDocumentBase(), "e.gif");
    MediaTracker tracker = new MediaTracker(this);
    tracker.addImage(originalImage, 0);//  w w  w .j av  a2s  .  c o m
    try {
        tracker.waitForAll();
    } catch (Exception e) {
    }
    filteredImage = originalImage;
    btn.addActionListener(this);
    add(btn);
}

From source file:FilterLab.java

public void init() {
    originalImage = getImage(getDocumentBase(), "emily.gif");
    MediaTracker tracker = new MediaTracker(this);
    tracker.addImage(originalImage, 0);/*from w  w w. j  a  v  a2  s . c o  m*/
    try {
        tracker.waitForAll();
    } catch (Exception e) {
    }
    filteredImage = originalImage;
    btn.addActionListener(this);
    add(btn);
}

From source file:MainClass.java

public void init() {
    i = getImage(getDocumentBase(), "rosey.jpg");
    MediaTracker mt = new MediaTracker(this);
    mt.addImage(i, 0);//www.  j  av  a2 s . c  o  m
    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("Loaded");
    j = createImage(new FilteredImageSource(i.getSource(), new BlurFilter()));
    System.out.println("Created");
}