Example usage for java.awt.image MemoryImageSource MemoryImageSource

List of usage examples for java.awt.image MemoryImageSource MemoryImageSource

Introduction

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

Prototype

public MemoryImageSource(int w, int h, int[] pix, int off, int scan, Hashtable<?, ?> props) 

Source Link

Document

Constructs an ImageProducer object which uses an array of integers in the default RGB ColorModel to produce data for an Image object.

Usage

From source file:com.jcraft.weirdx.XPixmap.java

void mkMIS() {
    mis = new MemoryImageSource(width, height, colormap.cm, data, 0, width);
    mis.setAnimated(true);
}

From source file:BMPLoader.java

public MemoryImageSource getImageSource() {
    ColorModel cm;//from  w  ww. j a  va  2 s  .  c o  m
    MemoryImageSource mis;
    if (noOfEntries > 0) {
        // There is a color palette; create an IndexColorModel
        cm = new IndexColorModel(bitsPerPixel, noOfEntries, r, g, b);
    } else {
        // There is no palette; use the default RGB color model
        cm = ColorModel.getRGBdefault();
    }
    // Create MemoryImageSource
    if (bitsPerPixel > 8) {
        // use one int per pixel
        mis = new MemoryImageSource(width, height, cm, intData, 0, width);
    } else {
        // use one byte per pixel
        mis = new MemoryImageSource(width, height, cm, byteData, 0, width);
    }
    return mis; // this can be used by JComponent.createImage()
}

From source file:SampleAWTRenderer.java

private void newImage(Buffer buffer) {

    if (!(buffer.getData() instanceof int[]))
        return;/*from   w  w  w  .j  ava2s  .  c o m*/

    int[] data = (int[]) buffer.getData();
    RGBFormat format = (RGBFormat) buffer.getFormat();

    //data = processImage(buffer);
    data = (int[]) buffer.getData();

    DirectColorModel dcm = new DirectColorModel(format.getBitsPerPixel(), format.getRedMask(),
            format.getGreenMask(), format.getBlueMask());

    sourceImage = new MemoryImageSource(format.getLineStride(), format.getSize().height, dcm, (int[]) data, 0,
            format.getLineStride());
    sourceImage.setAnimated(true);
    sourceImage.setFullBufferUpdates(true);
    if (component != null) {
        destImage = component.createImage(sourceImage);
        component.prepareImage(destImage, component);
    }
}

From source file:com.jcraft.weirdx.XPixmap.java

void mkMIS() {
    mis = new MemoryImageSource(width, height, XColormap.bwicm, data, 0, width);
    mis.setAnimated(true);
}

From source file:com.jcraft.weirdx.XPixmap.java

public void setSize(int w, int h) {
    if (w <= real_width && h <= real_height) {
        if (2 * w < real_width && 2 * h < real_height) {
            real_width /= 2;/*from  w ww  . j  ava2 s. c o m*/
            real_height /= 2;
            data = new byte[real_width * real_height];
            mis = new MemoryImageSource(real_width, real_height, colormap.cm, data, 0, real_width);
            mis.setAnimated(true);
        }
    } else {
        if (real_width < w)
            real_width = w;
        if (real_height < h)
            real_height = h;
        data = new byte[real_width * real_height];
        mis = new MemoryImageSource(real_width, real_height, colormap.cm, data, 0, real_width);
        mis.setAnimated(true);
    }
    this.width = w;
    this.height = h;
}

From source file:com.jcraft.weirdx.XPixmap.java

public void setSize(int w, int h) {
    if (w <= real_width && h <= real_height) {
        if (2 * w < real_width && 2 * h < real_height) {
            real_width /= 2;//w ww .j a v a 2  s .c o  m
            real_height /= 2;
            data = new byte[real_width * real_height];
            mis = new MemoryImageSource(real_width, real_height, XColormap.bwicm, data, 0, real_width);
            mis.setAnimated(true);
        }
    } else {
        if (real_width < w)
            real_width = w;
        if (real_height < h)
            real_height = h;
        data = new byte[real_width * real_height];
        mis = new MemoryImageSource(real_width, real_height, XColormap.bwicm, data, 0, real_width);
        mis.setAnimated(true);
    }
    this.width = w;
    this.height = h;
}