[3302] in java-interest

home help back first fref pref prev next nref lref last post

Re: ImageProducer/Consumer classes

daemon@ATHENA.MIT.EDU (Jim Graham)
Mon Nov 6 22:13:33 1995

Date: Sun, 5 Nov 1995 19:18:08 -0800
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: dgourley@CS.Berkeley.EDU
Cc: java-interest@java.Eng.Sun.COM



Hi David,

> > When you create an image from an ImageProducer using
> > 
> > 	Component.createImage(ImageProducer)
> > 
> > you get back a handle to something that will take care of managing the
> > ImageConsumers needed to get the bits to the screen on its own.  These
> > ImageConsumers will also take care of notifying applets that are drawing
> > the image that a new frame is available using the ImageObserver notification
> > mechanism.
> > 
> 
> You get back an Image Object from the above call, I am unclear on how you
> can go about using an ImageProducer to set the pixels of this Image. The
> ImageConsumer interface has a call to explicitly set the pixel vals and
> convert them with a given color model, but as I dont see how to get a
> reference to the ImageConsumer for this Image I am at a loss. Any help
> would be appreciated.

Read the ImageProducer interface.  ImageProducer objects don't actively
set pixels in an image, instead they are contacted by ImageConsumers that
are interested in their information.  When an ImageConsumer is interested
it will use either the addConsumer or startProduction methods on your
ImageProducer object to indicate this interest and register itself as
a Consumer of the image information.  Your ImageProducer object then needs
to make the appropriate callbacks on the ImageConsumer object as defined
by the ImageConsumer interface.  You "deliver" the information by making
method calls on the registered ImageConsumer objects (until you either
reach the end of the image and call imageComplete, or until the Consumer
unregisters itself using removeConsumer).

It is often adviseable to deliver the image information in a separate
lower priority thread by having the startProduction method call notify
a separate image generation thread to start sending data to the
consumer.  The reason for this is that it may take some time to
actually dither or scale, or in some cases filter the image data and
generate the complete image.

				...jim
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post