Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.media.ilbm
Class ColorCyclingMemoryImageSource

java.lang.Object
  extended by java.awt.image.MemoryImageSource
      extended by ch.randelshofer.media.ilbm.ColorCyclingMemoryImageSource
All Implemented Interfaces:
java.awt.image.ImageProducer

public class ColorCyclingMemoryImageSource
extends java.awt.image.MemoryImageSource

ColorCyclingMemoryImageSource.

Version:
1.1 2010-08-03 Added method putProperties. Added support for blended color cycles.
1.0.1 2010-11-08 Fixed color cycling rate.
1.0 2009-12-17 Created.
Author:
Werner Randelshofer

Constructor Summary
ColorCyclingMemoryImageSource(int w, int h, java.awt.image.ColorModel cm, byte[] pix, int off, int scan)
          Constructs an ImageProducer object which uses an array of bytes to produce data for an Image object.
ColorCyclingMemoryImageSource(int w, int h, java.awt.image.ColorModel cm, byte[] pix, int off, int scan, java.util.Hashtable<?,?> props)
          Constructs an ImageProducer object which uses an array of bytes to produce data for an Image object.
ColorCyclingMemoryImageSource(int w, int h, java.awt.image.ColorModel cm, int[] pix, int off, int scan)
          Constructs an ImageProducer object which uses an array of integers to produce data for an Image object.
ColorCyclingMemoryImageSource(int w, int h, java.awt.image.ColorModel cm, int[] pix, int off, int scan, java.util.Hashtable<?,?> props)
          Constructs an ImageProducer object which uses an array of integers to produce data for an Image object.
 
Method Summary
 void addColorCycle(ColorCycle cc)
           
 void addConsumer(java.awt.image.ImageConsumer ic)
           
 java.awt.image.ColorModel getColorModel()
           
 int getHeight()
           
 java.util.Hashtable getProperties()
           
 int getWidth()
           
 boolean isBlendedColorCycling()
           
 boolean isColorCyclingAvailable()
           
 boolean isColorCyclingStarted()
          Returns true if color cycling is on.
 boolean isStarted()
           
 void newPixels(byte[] newpix, java.awt.image.ColorModel newmodel, int offset, int scansize)
           
 void newPixels(int[] newpix, java.awt.image.ColorModel newmodel, int offset, int scansize)
          Changes to a new int array to hold the pixels for this image.
 void putProperties(java.util.Hashtable props)
           
 void removeConsumer(java.awt.image.ImageConsumer ic)
           
 void setAnimated(boolean b)
           
 void setBlendedColorCycling(boolean newValue)
           
 void setColorCyclingStarted(boolean b)
          Starts or stops color cycling.
 void start()
          Starts color cycling.
 void stop()
          Stops color cycling.
 java.awt.image.BufferedImage toBufferedImage()
          Creates a BufferedImage which shares its pixel data with this memory image source.
 
Methods inherited from class java.awt.image.MemoryImageSource
isConsumer, newPixels, newPixels, newPixels, requestTopDownLeftRightResend, setFullBufferUpdates, startProduction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorCyclingMemoryImageSource

public ColorCyclingMemoryImageSource(int w,
                                     int h,
                                     java.awt.image.ColorModel cm,
                                     byte[] pix,
                                     int off,
                                     int scan)
Constructs an ImageProducer object which uses an array of bytes to produce data for an Image object.

Parameters:
w - the width of the rectangle of pixels
h - the height of the rectangle of pixels
cm - the specified ColorModel
pix - an array of pixels
off - the offset into the array of where to store the first pixel
scan - the distance from one row of pixels to the next in the array
See Also:
Component.createImage(java.awt.image.ImageProducer)

ColorCyclingMemoryImageSource

public ColorCyclingMemoryImageSource(int w,
                                     int h,
                                     java.awt.image.ColorModel cm,
                                     byte[] pix,
                                     int off,
                                     int scan,
                                     java.util.Hashtable<?,?> props)
Constructs an ImageProducer object which uses an array of bytes to produce data for an Image object.

Parameters:
w - the width of the rectangle of pixels
h - the height of the rectangle of pixels
cm - the specified ColorModel
pix - an array of pixels
off - the offset into the array of where to store the first pixel
scan - the distance from one row of pixels to the next in the array
props - a list of properties that the ImageProducer uses to process an image
See Also:
Component.createImage(java.awt.image.ImageProducer)

ColorCyclingMemoryImageSource

public ColorCyclingMemoryImageSource(int w,
                                     int h,
                                     java.awt.image.ColorModel cm,
                                     int[] pix,
                                     int off,
                                     int scan)
Constructs an ImageProducer object which uses an array of integers to produce data for an Image object.

Parameters:
w - the width of the rectangle of pixels
h - the height of the rectangle of pixels
cm - the specified ColorModel
pix - an array of pixels
off - the offset into the array of where to store the first pixel
scan - the distance from one row of pixels to the next in the array
See Also:
Component.createImage(java.awt.image.ImageProducer)

ColorCyclingMemoryImageSource

public ColorCyclingMemoryImageSource(int w,
                                     int h,
                                     java.awt.image.ColorModel cm,
                                     int[] pix,
                                     int off,
                                     int scan,
                                     java.util.Hashtable<?,?> props)
Constructs an ImageProducer object which uses an array of integers to produce data for an Image object.

Parameters:
w - the width of the rectangle of pixels
h - the height of the rectangle of pixels
cm - the specified ColorModel
pix - an array of pixels
off - the offset into the array of where to store the first pixel
scan - the distance from one row of pixels to the next in the array
props - a list of properties that the ImageProducer uses to process an image
See Also:
Component.createImage(java.awt.image.ImageProducer)
Method Detail

getWidth

public int getWidth()

getHeight

public int getHeight()

getColorModel

public java.awt.image.ColorModel getColorModel()

getProperties

public java.util.Hashtable getProperties()

newPixels

public void newPixels(byte[] newpix,
                      java.awt.image.ColorModel newmodel,
                      int offset,
                      int scansize)
Overrides:
newPixels in class java.awt.image.MemoryImageSource

newPixels

public void newPixels(int[] newpix,
                      java.awt.image.ColorModel newmodel,
                      int offset,
                      int scansize)
Changes to a new int array to hold the pixels for this image. If the animation flag has been turned on through the setAnimated() method, then the new pixels will be immediately delivered to any ImageConsumers that are currently interested in the data for this image.

Overrides:
newPixels in class java.awt.image.MemoryImageSource
Parameters:
newpix - the new pixel array
newmodel - the specified ColorModel
offset - the offset into the array
scansize - the distance from one row of pixels to the next in the array
See Also:
MemoryImageSource.newPixels(int, int, int, int, boolean), setAnimated(boolean)

addColorCycle

public void addColorCycle(ColorCycle cc)

addConsumer

public void addConsumer(java.awt.image.ImageConsumer ic)
Specified by:
addConsumer in interface java.awt.image.ImageProducer
Overrides:
addConsumer in class java.awt.image.MemoryImageSource

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer ic)
Specified by:
removeConsumer in interface java.awt.image.ImageProducer
Overrides:
removeConsumer in class java.awt.image.MemoryImageSource

setAnimated

public void setAnimated(boolean b)
Overrides:
setAnimated in class java.awt.image.MemoryImageSource

setColorCyclingStarted

public void setColorCyclingStarted(boolean b)
Starts or stops color cycling.


isColorCyclingStarted

public boolean isColorCyclingStarted()
Returns true if color cycling is on.


start

public void start()
Starts color cycling.


stop

public void stop()
Stops color cycling.


isStarted

public boolean isStarted()

toBufferedImage

public java.awt.image.BufferedImage toBufferedImage()
Creates a BufferedImage which shares its pixel data with this memory image source.


isColorCyclingAvailable

public boolean isColorCyclingAvailable()

putProperties

public void putProperties(java.util.Hashtable props)

setBlendedColorCycling

public void setBlendedColorCycling(boolean newValue)

isBlendedColorCycling

public boolean isBlendedColorCycling()

Copyright 2011-01-06 Werner Randelshofer