quicktime.app.image
Class QTImageProducer

java.lang.Object
  |
  +--quicktime.app.image.QTImageProducer
All Implemented Interfaces:
java.awt.image.ImageProducer, Redrawable

public class QTImageProducer
extends java.lang.Object
implements java.awt.image.ImageProducer, Redrawable

The QTImageProducer implements the java.awt.image.ImageProducer interface for a single source QuickTime object. The QuickTime source can be a single frame (ie. still image) or a mutliple frame source such as a movie, sprite world animation, effect, etc. The QTImageProducer can produce images for multiple ImageConsumers.

The isRedrawing() method returns true if the source QT object is an object that requires redrawing. In this case the ImageObserver of this Producer should explicitly call the redraw() method and repaint the resultant Image to see any changes in the source of the pixel data. For instance a typical movie will be a sequence of images over time, and for consequent frames to be seen the producer must be redraw. The act of redrawing the producer will also result in the registered consumers being notified and given the changed pixels. Redrawing can also be optimised to only redraw those pixels within a specified region.

When the source is originally added to the Producer it is drawn. If the source is not or does not require redrawing then consequent calls to redraw will have no effect as the source pixels have not changed. If the redrawing characteristics of the QTDrawable source change then you must call setRedrawing(true) to tell the producer that it should redraw the source's pixel data before the redraw method is called. By default an QTImageProduce is seen as potentially presenting dynamic or changing image data.


Fields inherited from interface quicktime.app.image.Redrawable
kMultiFrame, kSingleFrame
 
Constructor Summary
QTImageProducer(QTDrawable qtSource, java.awt.Dimension initSize)
          Creates an ImageProducer from the specified qtSource.
 
Method Summary
 void addConsumer(java.awt.image.ImageConsumer ic)
          This method is used to register an ImageConsumer with the ImageProducer for access to the image data during a later reconstruction of the Image.
 java.awt.Dimension getSize()
          This returns the rendered size of the qtSource pixel data as specified in the constructor.
 boolean isConsumer(java.awt.image.ImageConsumer ic)
          This method determines if a given ImageConsumer object is currently registered with this ImageProducer as one of its consumers.
 boolean isRedrawing()
          Returns true if the image data may be altered or different upon different calls of the redraw method of the QTDrawable interface
 boolean isSingleFrame()
          Returns true if the Redrawable only has a single frame to render and thus will never need to re-acquire or redraw its image.
 void redraw(Region invalidRgn)
          This method is called to redraw the QuickTime image source and update any of the current ImageConsumers with the new pixels that have been generated.
 void removeConsumer(java.awt.image.ImageConsumer ic)
          This method removes the given ImageConsumer object from the list of consumers currently registered to receive image data.
 void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
          This method is used by an ImageConsumer to request that the ImageProducer attempt to resend the image data one more time in TOPDOWNLEFTRIGHT order so that higher quality conversion algorithms which depend on receiving pixels in order can be used to produce a better output version of the image.
 void setRedrawing(boolean redrawFlag)
          If true then the redraw method of the object will fetch new image data from its image source.
 void startProduction(java.awt.image.ImageConsumer ic)
          This method both registers the given ImageConsumer object as a consumer and starts an immediate reconstruction of the image data which will then be delivered to this consumer and any other consumer which may have already been registered with the producer.
 void updateConsumers(Region invalidRgn)
          This method can be called by an application to have the QTImageProducer to update the pixel data for each of the registered ImageConsumers when the source QTDrawable object has drawn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QTImageProducer

public QTImageProducer(QTDrawable qtSource,
                       java.awt.Dimension initSize)
                throws QTException
Creates an ImageProducer from the specified qtSource. The initialSize of the qtSource should be specified to get the best pixel resolution of the source material.
Parameters:
qtSource - the source of pixel data for the ImageProducer.
initSize - the intial size of the source data
Method Detail

isSingleFrame

public boolean isSingleFrame()
Returns true if the Redrawable only has a single frame to render and thus will never need to re-acquire or redraw its image. Certain Redrawable objects are able to optimise their resources knowing this constraint.
Specified by:
isSingleFrame in interface Redrawable
Following copied from interface: quicktime.app.image.Redrawable
Returns:
a boolean

addConsumer

public void addConsumer(java.awt.image.ImageConsumer ic)
This method is used to register an ImageConsumer with the ImageProducer for access to the image data during a later reconstruction of the Image. The ImageProducer may, at its discretion, start delivering the image data to the consumer using the ImageConsumer interface immediately, or when the next available image reconstruction is triggered by a call to the startProduction method.
Specified by:
addConsumer in interface java.awt.image.ImageProducer
See Also:
startProduction(java.awt.image.ImageConsumer)

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer ic)
This method determines if a given ImageConsumer object is currently registered with this ImageProducer as one of its consumers.
Specified by:
isConsumer in interface java.awt.image.ImageProducer

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer ic)
This method removes the given ImageConsumer object from the list of consumers currently registered to receive image data. It is not considered an error to remove a consumer that is not currently registered. The ImageProducer should stop sending data to this consumer as soon as is feasible.
Specified by:
removeConsumer in interface java.awt.image.ImageProducer

startProduction

public void startProduction(java.awt.image.ImageConsumer ic)
This method both registers the given ImageConsumer object as a consumer and starts an immediate reconstruction of the image data which will then be delivered to this consumer and any other consumer which may have already been registered with the producer. This method differs from the addConsumer method in that a reproduction of the image data should be triggered as soon as possible.
Specified by:
startProduction in interface java.awt.image.ImageProducer
See Also:
addConsumer(java.awt.image.ImageConsumer)

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
This method is used by an ImageConsumer to request that the ImageProducer attempt to resend the image data one more time in TOPDOWNLEFTRIGHT order so that higher quality conversion algorithms which depend on receiving pixels in order can be used to produce a better output version of the image. The ImageProducer is free to ignore this call if it cannot resend the data in that order. If the data can be resent, then the ImageProducer should respond by executing the following minimum set of ImageConsumer method calls:
	ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >);
	ic.setPixels(...);	// As many times as needed
	ic.imageComplete();
 
Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer
See Also:
ImageConsumer.setHints(int)

redraw

public void redraw(Region invalidRgn)
            throws QTException
This method is called to redraw the QuickTime image source and update any of the current ImageConsumers with the new pixels that have been generated. This update will only be done if the redrawing flag is true.
Parameters:
invalidRgn - if null the whole image is redrawn and all of the pixels are grabbed and sent to the consumers. If not null then the qtSource invalidates the region specified, which can result in a faster draw. Also only those pixels that are within the bounds of the region are sent to the consumers.

updateConsumers

public void updateConsumers(Region invalidRgn)
                     throws QTException
This method can be called by an application to have the QTImageProducer to update the pixel data for each of the registered ImageConsumers when the source QTDrawable object has drawn. Thus an application can either explicitly draw the QTDrawable source itself then call this method or can receive notification by the QTDrawable source when it has drawn, and use this method to update the registered ImageConsumers.
Parameters:
invalidRgn - enter null to copy all pixels, or specify a region that specifies the changed pixel data, which can econimize the copying of the pixel data to only those areas that have changed.

setRedrawing

public void setRedrawing(boolean redrawFlag)
If true then the redraw method of the object will fetch new image data from its image source.
Specified by:
setRedrawing in interface Redrawable
Parameters:
redrawFlag - boolean determining whether the current image is redrawn (false) of fresh or updated image data is first retrieved (true).

isRedrawing

public boolean isRedrawing()
Returns true if the image data may be altered or different upon different calls of the redraw method of the QTDrawable interface
Specified by:
isRedrawing in interface Redrawable

getSize

public java.awt.Dimension getSize()
This returns the rendered size of the qtSource pixel data as specified in the constructor.