当前位置 类层次(JDK) 所有类(JDK) 所有域和方法(JDK)

类 java.awt.image.MemoryImageSource

java.lang.Object
   |
   +----java.awt.image.MemoryImageSource

public class MemoryImageSource
extends Object
implements ImageProducer

该类是 ImageProducer 接口的一个实现,使用数组生成图象的象素值。 下面的例子计算一个 100x100 图象的颜色衰减,X 轴方向从黑到蓝衰减,Y 轴方向从黑到红衰减:

	int w = 100;
	int h = 100;
	int pix[] = new int[w * h];
	int index = 0;
	for (int y = 0; y 
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 

参见:
ImageProducer

构造子索引

MemoryImageSource(int, int, ColorModel, byte[], int, int)
构造一个 ImageProducer 对象,它使用一字节数组产生一 Image 对象的数据。
MemoryImageSource(int, int, ColorModel, byte[], int, int, Hashtable)
构造一个 ImageProducer 对象,它使用一字节数组产生一 Image 对象的数据。
MemoryImageSource(int, int, ColorModel, int[], int, int)
构造一个 ImageProducer对象,它使用一整数数组产生一 Image 对象的数据。
MemoryImageSource(int, int, ColorModel, int[], int, int, Hashtable)
构造一个 ImageProducer 对象,它使用一整数数组产生一 Image 对象的数据。
MemoryImageSource(int, int, int[], int, int)
构造一个 ImageProducer,它使用一缺省 RGB ColorModel 的整数数组产生一 Image 对象的数据。
MemoryImageSource(int, int, int[], int, int, Hashtable)
构造一个 ImageProducer 对象,它使用一缺省 RGB ColorModel 的整数数组产生一 Image 对象的数据。

方法索引

addConsumer(ImageConsumer)
在对该数据感兴趣的消费者列表中添加一个 ImageConsumer 对象。
isConsumer(ImageConsumer)
判断对当前图象数据感兴趣的消费者的列表中是否有一个 ImageConsumer。
newPixels()
向对当前图象数据感兴趣的所有 ImageConsumers 发送象素的完整新缓存,且通知它们动画框架是完备的。
newPixels(byte[], ColorModel, int, int)
改变新字节数组,使之记录当前图象的象素值。
newPixels(int, int, int, int)
向对当前图象数据感兴趣的所有 ImageConsumer 发送象素的矩形缓存区,并且通知它们动画框架是完整的。
newPixels(int, int, int, int, boolean)
向对当前图象数据感兴趣的 ImageConsumer 发送象素的矩形缓存区。
newPixels(int[], ColorModel, int, int)
改变新整数数组,使之记录当前图象的象素值。
removeConsumer(ImageConsumer)
从消费者列表中删除一个对当前图象数据感兴趣的 ImageConsumer。
requestTopDownLeftRightResend(ImageConsumer)
请求一个给定的 ImageConsumer,它拥有多次以上下、左右顺序传送的图象数据。
setAnimated(boolean)
根据给定的动态参数,将当前内存映象转换为多帧动态图象或单帧静态图象。
setFullBufferUpdates(boolean)
指明当前动态内存映象,不管图象何时发生改变,是否总应通过传送完整的象素缓冲区来实现更新。
startProduction(ImageConsumer)
向消费者列表中添加一个对当前图象数据感兴趣的 ImageConsumer,并立即开始通过 ImageConsumer 的接口传送该图象数据。

构造子

MemoryImageSource
 public MemoryImageSource(int w,
                     int h,
                          ColorModel cm,
                          byte pix[],
                   int off,
                          int scan)
构造一个 ImageProducer 对象,它使用一字节数组产生一 Image 对象的数据。

参见:
createImage
MemoryImageSource
 public MemoryImageSource(int w,
                     int h,
                          ColorModel cm,
                          byte pix[],
                   int off,
                          int scan,
                          Hashtable props)
构造一个 ImageProducer 对象,它使用一字节数组产生一 Image 对象的数据。

参见:
createImage
MemoryImageSource
 public MemoryImageSource(int w,
                     int h,
                          ColorModel cm,
                     int pix[],
                   int off,
                          int scan)
构造一个 ImageProducer 对象,它使用一整数数组产生一 Image 对象的数据。

参见:
createImage
MemoryImageSource
 public MemoryImageSource(int w,
                     int h,
                          ColorModel cm,
                     int pix[],
                   int off,
                          int scan,
                          Hashtable props)
构造一个 ImageProducer 对象,它使用一整数数组产生一 Image 对象的数据。

参见:
createImage
MemoryImageSource
 public MemoryImageSource(int w,
                     int h,
                     int pix[],
                   int off,
                          int scan)
构造一个 ImageProducer 对象,它使用一缺省 RGB ColorModel 的整数数组产生一 Image 对象的数据。

参见:
createImage, getRGBdefault
MemoryImageSource
 public MemoryImageSource(int w,
                     int h,
                     int pix[],
                   int off,
                          int scan,
                          Hashtable props)
构造一个 ImageProducer 对象,它使用一缺省 RGB ColorModel 的整数数组产生一 Image 对象的数据。

参见:
createImage, getRGBdefault

方法

addConsumer
 public synchronized void addConsumer(ImageConsumer ic)
在消费者列表中添加一个对当前图象数据感兴趣的 ImageConsumer。

参见:
ImageConsumer
isConsumer
 public synchronized boolean isConsumer(ImageConsumer ic)
判断消费者列表中是否有一个对当前图象数据感兴趣的 ImageConsumer。

返回值:
如果该 ImageConsumer 在列表中则为 true;否则为 false。
参见:
ImageConsumer
removeConsumer
 public synchronized void removeConsumer(ImageConsumer ic)
从消费者列表中删除一个对当前图象数据感兴趣的 ImageConsumer。

参见:
ImageConsumer
startProduction
 public void startProduction(ImageConsumer ic)
向消费者列表中添加一个对当前图象数据感兴趣的 ImageConsumer,并立即开始通过它的接口传送该图象数据。

参见:
ImageConsumer
requestTopDownLeftRightResend
 public void requestTopDownLeftRightResend(ImageConsumer ic)
请求一个给定的图象消费者,它拥有以上下、左右顺序多次传送的图象数据。

参见:
ImageConsumer
setAnimated
 public synchronized void setAnimated(boolean animated)
根据给定的动态参数,将当前内存映象转换为多帧动态图象或单帧静态图象。

在创建 MemoryImageSource 之后,且在使用它再创建一图象之前,立即调用此方法,以确保所有 ImageConsumers 对象将能接收正确的多帧数据。如果在此标志设置前,有一 ImageConsumer 添加到当前 ImageProducer, 那么 ImageConsumer 将仅能看见连接时可获得的象素数据的瞬象。

参数:
animated - 如果映像是多帧动画绘制的则为 true
setFullBufferUpdates
 public synchronized void setFullBufferUpdates(boolean fullbuffers)
设置当前动态内存映象,不管图象何时发生改变,是否总应通过传送完整的象素缓冲区来实现更新的标志。 如果没有通过 setAnimated() 方法设置动态标志,则忽略该标志。

在创建 MemoryImageSource 之后,且在使用它再创建一图象之前,立即调用此方法,以确保所有 ImageConsumers 对象将能接收正确的象素传送提示。

参数:
fullbuffers - 如果总设置为完整象素则为 true
参见:
setAnimated
newPixels
 public void newPixels()
向对当前图象数据感兴趣的图象消费者发送象素的完整新缓存,且通知它们动画框架是完备的。 如果通过 setAnimated() 方法设置了动态标志,那么此方法才有效。

参见:
ImageConsumer, setAnimated
newPixels
 public synchronized void newPixels(int x,
                       int y,
                     int w,
                     int h)
向对当前图象数据感兴趣的 ImageConsumer 发送象素的矩形区域缓存,且通知它们动画框架是完备的。 如果通过 setAnimated() 方法设置了动态标志,那么此方法才有效。 如果用 setFullBufferUpdates() 方法设置了完整缓冲更新,那么忽略矩形参数,且总设置为整个缓冲更新。

参数:
x - 将设置的象素矩形的左上顶点的 x 坐标
y - 将设置的象素矩形的左上顶点的 y 坐标
w - 将设置的象素矩形的宽度
h - 将设置的象素矩形的高度
参见:
ImageConsumer, setAnimated, setFullBufferUpdates
newPixels
 public synchronized void newPixels(int x,
                       int y,
                     int w,
                     int h,
                                    boolean framenotify)
向对当前图象数据相关的 ImageConsumer 发送象素的完整新缓存。 如果 framenotify 参数为 true,那么通知消费者动态帧是完毕的。如果通过 setAnimated() 方法设置了动态标志,那么此方法才有效。 如果用 setFullBufferUpdates() 方法设置了完整缓冲更新,那么忽略矩形参数,且总设置为整个缓冲更新。

参数:
x - 将设置的象素矩形的左上顶点的 x 坐标
y - 将设置的象素矩形的左上顶点的 y 坐标
w - 将设置的象素矩形的宽度
h - 将设置的象素矩形的高度
framenotify - 如果消费者应设置为 SINGLEFRAMEDONE 通知则为 true
参见:
ImageConsumer, setAnimated, setFullBufferUpdates
newPixels
 public synchronized void newPixels(byte newpix[],
                                    ColorModel newmodel,
                                   int offset,
                     int scansize)
改变新字节数组,使之记录当前图象的象素值。 如果通过 setAnimated() 方法设置了动态标志,那么将立即将新象素传送到当前对此图象数据感兴趣的 ImageConsumer。

参见:
setAnimated
newPixels
 public synchronized void newPixels(int newpix[],
                                    ColorModel newmodel,
                                   int offset,
                     int scansize)
改变新整数数组,使之记录当前图象的象素值。 如果通过 setAnimated() 方法设置了动态标志,那么将立即将新象素传送到当前对此图象数据感兴趣的 ImageConsumer。

参见:
setAnimated

当前位置 类层次(JDK) 所有类(JDK) 所有域和方法(JDK)