readColorModelOnly = pColorModelOnly; producer.startProduction(consumer); // Note: If single-thread (synchronous), this call will block
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction(this); while (encoding) try { wait(); } catch (InterruptedException e) {} if (iox != null) throw iox; }
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction(this); while (encoding) try { wait(); } catch (InterruptedException e) { } if (iox != null) throw iox; }
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction(this); while (encoding) try { wait(); } catch (InterruptedException e) { } if (iox != null) throw iox; }
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction(this); while (encoding) try { wait(); } catch (InterruptedException e) { } if (iox != null) throw iox; }
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction(this); while (encoding) try { wait(); } catch (InterruptedException e) { } if (iox != null) throw iox; }
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction(this); while (encoding) try { wait(); } catch (InterruptedException e) { } if (iox != null) throw iox; }
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction(this); while (encoding) try { wait(); } catch (InterruptedException e) { } if (iox != null) throw iox; }
public synchronized void encode() throws IOException { encoding = true; iox = null; producer.startProduction( this ); while ( encoding ) try { wait(); } catch ( InterruptedException e ) {} if ( iox != null ) throw iox; }
public BufferGatherer(Image image, boolean flipVertical) { myFlipVerticalFlag = flipVertical; image.getSource().startProduction(this); } /* Unused
/** * Loads an image and returns when a frame is done, the image is done, an error occurs, or the image is aborted. */ public void loadImage() throws InterruptedException { synchronized(this) { status=0; image.getSource().startProduction(this); while((status&(IMAGEABORTED|IMAGEERROR|SINGLEFRAMEDONE|STATICIMAGEDONE))==0) { wait(); } } }
public BufferGatherer(Image image, boolean flipVertical) { myFlipVerticalFlag = flipVertical; image.getSource().startProduction(this); } /* Unused
AreaAveragingScaleFilter scaleFilter = new AreaAveragingScaleFilter( Math.round(originalWidth / factorX), Math.round(originalHeight / factorY)); ImageProducer producer = new FilteredImageSource(original.getSource(), scaleFilter); ImageGenerator generator = new ImageGenerator(); producer.startProduction(generator); BufferedImage scaled = generator.getImage(); for(int x = 0; x < scaled.getWidth(); x++) { for(int y = 0; y < scaled.getHeight(); y++) { int rgb = scaled.getRGB(x, y); int alpha = (rgb >> 24) & 0xff; if(alpha != 255) { scaled.setRGB(x, y,-1); //set white } } } JPEGImageWriteParam param = new JPEGImageWriteParam(null); param.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); param.setCompressionQuality((float) 0.85); java.util.Iterator<ImageWriter> it = ImageIO.getImageWritersBySuffix("jpg"); ImageWriter writer = it.next(); dest.getParentFile().mkdirs(); writer.setOutput(new FileImageOutputStream(dest)); writer.write(null, new IIOImage(scaled, null, null), param); writer.dispose();
AreaAveragingScaleFilter scaleFilter = new AreaAveragingScaleFilter( Math.round(originalWidth / factorX), Math.round(originalHeight / factorY)); ImageProducer producer = new FilteredImageSource(original.getSource(), scaleFilter); ImageGenerator generator = new ImageGenerator(); producer.startProduction(generator); BufferedImage scaled = generator.getImage(); for(int x = 0; x < scaled.getWidth(); x++) { for(int y = 0; y < scaled.getHeight(); y++) { int rgb = scaled.getRGB(x, y); int alpha = (rgb >> 24) & 0xff; if(alpha != 255) { scaled.setRGB(x, y,-1); //set white } } } JPEGImageWriteParam param = new JPEGImageWriteParam(null); param.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT); param.setCompressionQuality((float) 0.85); java.util.Iterator<ImageWriter> it = ImageIO.getImageWritersBySuffix("jpg"); ImageWriter writer = it.next(); dest.getParentFile().mkdirs(); writer.setOutput(new FileImageOutputStream(dest)); writer.write(null, new IIOImage(scaled, null, null), param); writer.dispose();
/** * This constructs an ImageLoader. As soon as an ImageLoader is constructed the <code>ImageProducer</code> is asked to start producing data. * (However constructing this object will not block waiting on the image data.) * * @param p * the source of this image * @param changeListener * an optional <code>ChangeListener</code>. This will be notified when a change occurs. It can be added here in the constructor because * loading the image begins immediately; depending on how <code>ImageProducer.startProduction</code> is implemented this <i>may</i> be a * blocking call so the <code>ChangeListener</code> needs to be added before the loading begins * @param description * an optional description that may be useful for debugging */ public ImageLoader(ImageProducer p, ChangeListener changeListener, String description) { producer = p; addChangeListener(changeListener); consumer = new InnerImageConsumer(); p.startProduction(consumer); this.description = description; }
/** * Create a {@link java.awt.image.BufferedImage} from the given source * image producer. If the source is an animated GIF, it will only return * the first frame. * * @param prod The source imageproducer to create buffered image from * @return A complete buffered image representation of this image */ public static BufferedImage createBufferedImage(ImageProducer prod) { ImageGenerator gen = new ImageGenerator(); prod.startProduction(gen); BufferedImage img = gen.getImage(); // Remove the consumer to stop the animated GIF code going in to // an endless production loop. prod.removeConsumer(gen); return img; } }
producer.startProduction(generator); BufferedImage scaled = generator.getImage();
public void initialize(RandomAccessInputStream in, int y, int h, int imageWidth) { this.in = in; tiles = new TileCache(y, h); preprocess(this.in); try { Toolkit toolkit = Toolkit.getDefaultToolkit(); byte[] data = new byte[this.in.available()]; this.in.readFully(data); Image image = toolkit.createImage(data); ImageProducer producer = image.getSource(); consumer = new TileConsumer(producer, y, h); producer.startProduction(consumer); while (producer.isConsumer(consumer)); } catch (IOException e) { } }
/** * Create a {@link java.awt.image.BufferedImage} from the given source * image. If the source image is already a buffered image it will * immediately return with the parameter as the return value. * * @param img The source image to create buffered image from * @return A complete buffered image representation of this image */ public static BufferedImage createBufferedImage(Image img) { if(img instanceof BufferedImage) return (BufferedImage)img; ImageProducer prod = img.getSource(); ImageGenerator gen = new ImageGenerator(); prod.startProduction(gen); BufferedImage ret_val = gen.getImage(); // Remove the consumer to stop the animated GIF code going in to // an endless production loop. prod.removeConsumer(gen); return ret_val; }
readColorModelOnly = pColorModelOnly; producer.startProduction(consumer); // Note: If single-thread (synchronous), this call will block