全パッケージ クラス階層 このパッケージ 前項目 次項目 インデックス
java.lang.Object | +----java.awt.image.MemoryImageSource
	int w = 100;
	int h = 100;
	int pix[] = new int[w * h];
	int index = 0;
	for (int y = 0; y < h; y++) {
	    int red = (y * 255) / (h - 1);
	    for (int x = 0; x < w; x++) {
		int blue = (x * 255) / (w - 1);
		pix[index++] = (255 << 24) | (red << 16) | blue;
	    }
	}
	Image img = createImage(new MemoryImageSource(w, h, pix, 0, w));
 
また、MemoryImageSource は、アニメーションやカスタムレンダリングが時間とともに変化するメモリイメージを管理できます。以下に示すのは、アニメーションソース、およびデータの信号変化 の設定方法です (Garth Dickie による MemoryAnimationSourceDemo から採用)。
 
	int pixels[];
	MemoryImageSource source;
	public void init() {
	    int width = 50;
	    int height = 50;
	    int size = width * height;
	    pixels = new int[size];
	    int value = getBackground().getRGB();
	    for (int i = 0; i < size; i++) {
		pixels[i] = value;
	    }
	    source = new MemoryImageSource(width, height, pixels, 0, width);
	    source.setAnimated(true);
	    image = createImage(source);
	}
	public void run() {
	    Thread me = Thread.currentThread( );
	    me.setPriority(Thread.MIN_PRIORITY);
	    while (true) {
		try {
		    thread.sleep(10);
		} catch( InterruptedException e ) {
		    return;
		}
		// Modify the values in the pixels array at (x, y, w, h)
		// Send the new data to the interested ImageConsumers
		source.newPixels(x, y, w, h);
	    }
	}
 
 
 MemoryImageSource(int, int, ColorModel, byte[], int, int)
	MemoryImageSource(int, int, ColorModel, byte[], int, int)
   MemoryImageSource(int, int, ColorModel, byte[], int, int, Hashtable)
	MemoryImageSource(int, int, ColorModel, byte[], int, int, Hashtable)
   MemoryImageSource(int, int, ColorModel, int[], int, int)
	MemoryImageSource(int, int, ColorModel, int[], int, int)
   MemoryImageSource(int, int, ColorModel, int[], int, int, Hashtable)
	MemoryImageSource(int, int, ColorModel, int[], int, int, Hashtable)
   MemoryImageSource(int, int, int[], int, int)
	MemoryImageSource(int, int, int[], int, int)
   MemoryImageSource(int, int, int[], int, int, Hashtable)
	MemoryImageSource(int, int, int[], int, int, Hashtable)
   
 addConsumer(ImageConsumer)
	addConsumer(ImageConsumer)
   isConsumer(ImageConsumer)
	isConsumer(ImageConsumer)
   newPixels()
	newPixels()
   newPixels(byte[], ColorModel, int, int)
	newPixels(byte[], ColorModel, int, int)
   newPixels(int, int, int, int)
	newPixels(int, int, int, int)
   newPixels(int, int, int, int, boolean)
	newPixels(int, int, int, int, boolean)
   newPixels(int[], ColorModel, int, int)
	newPixels(int[], ColorModel, int, int)
   removeConsumer(ImageConsumer)
	removeConsumer(ImageConsumer)
   requestTopDownLeftRightResend(ImageConsumer)
	requestTopDownLeftRightResend(ImageConsumer)
   setAnimated(boolean)
	setAnimated(boolean)
   setFullBufferUpdates(boolean)
	setFullBufferUpdates(boolean)
   startProduction(ImageConsumer)
	startProduction(ImageConsumer)
   
 MemoryImageSource
MemoryImageSource
  public MemoryImageSource(int w,
                           int h,
                           ColorModel cm,
                           byte pix[],
                           int off,
                           int scan)
 MemoryImageSource
MemoryImageSource
  public MemoryImageSource(int w,
                           int h,
                           ColorModel cm,
                           byte pix[],
                           int off,
                           int scan,
                           Hashtable props)
 MemoryImageSource
MemoryImageSource
  public MemoryImageSource(int w,
                           int h,
                           ColorModel cm,
                           int pix[],
                           int off,
                           int scan)
 MemoryImageSource
MemoryImageSource
  public MemoryImageSource(int w,
                           int h,
                           ColorModel cm,
                           int pix[],
                           int off,
                           int scan,
                           Hashtable props)
 MemoryImageSource
MemoryImageSource
  public MemoryImageSource(int w,
                           int h,
                           int pix[],
                           int off,
                           int scan)
 MemoryImageSource
MemoryImageSource
  public MemoryImageSource(int w,
                           int h,
                           int pix[],
                           int off,
                           int scan,
                           Hashtable props)
 
 addConsumer
addConsumer
public synchronized void addConsumer(ImageConsumer ic)
 isConsumer
isConsumer
public synchronized boolean isConsumer(ImageConsumer ic)
 removeConsumer
removeConsumer
public synchronized void removeConsumer(ImageConsumer ic)
 startProduction
startProduction
public void startProduction(ImageConsumer ic)
 requestTopDownLeftRightResend
requestTopDownLeftRightResend
public void requestTopDownLeftRightResend(ImageConsumer ic)
 setAnimated
setAnimated
public synchronized void setAnimated(boolean animated)
このメソッドは、すべての ImageConsumers が正常な複数フレームデータを受け取ることを保証するために、MemoryImageSource の構成後直ちに、またこのメソッドを使用してイメージが作成される前に呼び出されなければなりません。このフラグを設定する前に、ImageConsumer をこの ImageProducer に追加すると、接続した時に利用可能であったピクセルデータのスナップショットだけが ImageConsumer から参照されます。
 setFullBufferUpdates
setFullBufferUpdates
public synchronized void setFullBufferUpdates(boolean fullbuffers)
このメソッドは、MemoryImageSource の構成後直ちに、またイメージが作成される前に呼び出され、すべての ImageConsumers が正常なピクセル転送情報を受け取ることを保証します。
 newPixels
newPixels
public void newPixels()
 newPixels
newPixels
  public synchronized void newPixels(int x,
                                     int y,
                                     int w,
                                     int h)
 newPixels
newPixels
  public synchronized void newPixels(int x,
                                     int y,
                                     int w,
                                     int h,
                                     boolean framenotify)
 newPixels
newPixels
  public synchronized void newPixels(byte newpix[],
                                     ColorModel newmodel,
                                     int offset,
                                     int scansize)
 newPixels
newPixels
  public synchronized void newPixels(int newpix[],
                                     ColorModel newmodel,
                                     int offset,
                                     int scansize)
全パッケージ クラス階層 このパッケージ 前項目 次項目 インデックス