List of usage examples for java.awt MediaTracker addImage
public void addImage(Image image, int id)
From source file:SimpleBufferedImageDemo.java
DisplayCanvas() { displayImage = Toolkit.getDefaultToolkit().getImage("largeJava2sLogo.jpg"); MediaTracker mt = new MediaTracker(this); mt.addImage(displayImage, 1); try {//from www .j ava 2 s . c om mt.waitForAll(); } catch (Exception e) { System.out.println("Exception while loading."); } if (displayImage.getWidth(this) == -1) { System.out.println("No *.jpg file"); System.exit(0); } setBackground(Color.white); setSize(400, 225); }
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); }/* ww w .ja va2s. com*/ try { mt.waitForAll(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:ConvolveApp.java
public void loadImage() { displayImage = Toolkit.getDefaultToolkit().getImage("largeJava2sLogo.jpg"); MediaTracker mt = new MediaTracker(this); mt.addImage(displayImage, 1); try {//from w w w. ja v a 2s .co m mt.waitForAll(); } catch (Exception e) { System.out.println("Exception while loading."); } if (displayImage.getWidth(this) == -1) { System.out.println("No jpg file"); System.exit(0); } }
From source file:ImageOps.java
public void init() { setBackground(Color.white);/*from www .jav a2 s . c o m*/ bi = new BufferedImage[4]; String s[] = { "bld.jpg", "bld.jpg", "boat.gif", "boat.gif" }; for (int i = 0; i < bi.length; i++) { Image img = getImage(getURL("images/" + s[i])); try { MediaTracker tracker = new MediaTracker(this); tracker.addImage(img, 0); tracker.waitForID(0); } catch (Exception e) { } int iw = img.getWidth(this); int ih = img.getHeight(this); bi[i] = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB); Graphics2D big = bi[i].createGraphics(); big.drawImage(img, 0, 0, this); } }
From source file:SplashScreen.java
/** * Create a new splash screen object of the specified image. * The image file is located and referred to through the deployment, not * the local file system; A typical value might be "/com/company/splash.jpg". * // ww w. ja va 2 s . c o m * @param imageFileName Name of image file resource to act as splash screen. */ public SplashScreen(String imageFileName) { super(new Frame()); try { Toolkit toolkit = Toolkit.getDefaultToolkit(); URL imageUrl = getClass().getResource(imageFileName); image_ = toolkit.getImage(imageUrl); MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(image_, 0); mediaTracker.waitForID(0); width_ = image_.getWidth(this); height_ = image_.getHeight(this); Dimension screenSize = toolkit.getScreenSize(); x_ = (screenSize.width - width_) / 2; y_ = (screenSize.height - height_) / 2; } catch (Exception exception) { exception.printStackTrace(); image_ = null; } }
From source file:MainClass.java
public void init() { i = getImage(getDocumentBase(), "rosey.jpg"); MediaTracker mt = new MediaTracker(this); mt.addImage(i, 0); try {/*w w w . j a va2 s. c o m*/ mt.waitForAll(); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Loaded"); j = createImage(new FilteredImageSource(i.getSource(), new BlurFilter())); System.out.println("Created"); }
From source file:MainClass.java
public void init() { MediaTracker mt = new MediaTracker(this); i = getImage(getDocumentBase(), "ora-icon.gif"); mt.addImage(i, 0); try {// w w w. ja va2 s.c o m 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:AffineTransformApp.java
public void loadImage() { displayImage = Toolkit.getDefaultToolkit().getImage("largeJava2sLogo.jpg"); MediaTracker mt = new MediaTracker(this); mt.addImage(displayImage, 1); try {/*from w w w. j av a 2s .c o m*/ mt.waitForAll(); } catch (Exception e) { System.out.println("Exception while loading."); } if (displayImage.getWidth(this) == -1) { System.out.println(" Missing .jpg file"); System.exit(0); } }
From source file:CombineApp.java
public void loadImage() { displayImage = Toolkit.getDefaultToolkit().getImage("largeJava2sLogo.jpg"); MediaTracker mt = new MediaTracker(this); mt.addImage(displayImage, 1); try {// w w w. j a va2s . co m mt.waitForAll(); } catch (Exception e) { System.out.println("Exception while loading."); } if (displayImage.getWidth(this) == -1) { System.out.println("No jpg) file"); System.exit(0); } }
From source file:BufferedImageThread.java
AnimationCanvas() { setBackground(Color.green);/* w w w . j a va 2 s . c o m*/ setSize(450, 400); image = getToolkit().getImage("largeJava2sLogo.gif"); MediaTracker mt = new MediaTracker(this); mt.addImage(image, 1); try { mt.waitForAll(); } catch (Exception e) { System.out.println("Exception while loading image."); } if (image.getWidth(this) == -1) { System.out.println("No gif file"); System.exit(0); } rotate = (int) (Math.random() * 360); scale = Math.random() * 1.5; scaleDirection = DOWN; xi = 50.0; yi = 50.0; }