PulpCore

pulpcore.image.filter
Class Superimpose

java.lang.Object
  extended by pulpcore.image.filter.Filter
      extended by pulpcore.image.filter.Superimpose

public final class Superimpose
extends Filter

The Superimpose filter allows to superimpose an image over a sprite. This filter uses 3 parameters: - An image that will be superimposed over the filtered sprite. This image can be a different size of the Sprite. - the position (through x and y attributes) of the image. Coordinate are relative to the upper-left pixel position of the filtered sprite. Default values are 0,0 - an alpha value applied on the superimposed image. Default value is 255 (no fading). Each of this value can move from -255 to 255. Higher values will be clamped. The alpha channel of the original image is not affected by the filter.

Author:
Florent Dupont

Field Summary
 Int alpha
          Fading applied to the superimposed image, from 0 to 255.
 Int x
          The x offset of the superimposed image.
 Int y
          The y offset of the superimposed image.
 
Constructor Summary
Superimpose()
          Creates the Superimpose filter with no image.
Superimpose(CoreImage image)
          Creates the superimpose filter with the specified image.
Superimpose(CoreImage image, int x, int y)
          Creates a Superimpose filter with the specified parameters.
Superimpose(CoreImage image, int x, int y, int alpha)
          Creates a Superimpose filter with the specified parameters.
 
Method Summary
 Filter copy()
          Creates a copy of the Filter for another Sprite to use.
protected  void filter(CoreImage src, CoreImage dst)
          Performs this filter on the input image onto the specified output image.
 int getHeight()
          Gets the height of the output of this filter.
 CoreImage getImage()
          Image accessors.
 int getWidth()
          Gets the width of the output of this filter.
 int getX()
          Gets the x offset the output image should display relative to the input.
 int getY()
          Gets the y offset the output image should display relative to the input.
 void setImage(CoreImage image)
          Image accessors
 void update(int elapsedTime)
          Updates the filter.
 
Methods inherited from class pulpcore.image.filter.Filter
filter, getInput, getOutput, isDirty, isOpaque, setDirty, setInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alpha

public final Int alpha
Fading applied to the superimposed image, from 0 to 255. The default value is 255.


x

public final Int x
The x offset of the superimposed image. This coordinates are relative to the left pixel position of the filtered sprite.


y

public final Int y
The y offset of the superimposed image. This coordinates are relative to the upper pixel position of the filtered sprite.

Constructor Detail

Superimpose

public Superimpose()
Creates the Superimpose filter with no image.


Superimpose

public Superimpose(CoreImage image)
Creates the superimpose filter with the specified image.

Parameters:
image - Image to superimpose to the filtered Sprite.

Superimpose

public Superimpose(CoreImage image,
                   int x,
                   int y)
Creates a Superimpose filter with the specified parameters.

Parameters:
image - Image to superimpose to the filtered Sprite.
x - position X relative to the sprite.
y - position Y relative to the sprite.

Superimpose

public Superimpose(CoreImage image,
                   int x,
                   int y,
                   int alpha)
Creates a Superimpose filter with the specified parameters.

Parameters:
image - Image to superimpose to the filtered Sprite.
x - X offset (relative to the upper-left point of the filtered sprite).
y - Y offset (relative to the upper-left point of the filtered sprite).
alpha - amount of fading applied to the superimposed image, from 0 to 255.
Method Detail

getImage

public CoreImage getImage()
Image accessors.

Returns:
the superimposed image

setImage

public void setImage(CoreImage image)
Image accessors

Parameters:
image - The superimposed image to apply to this filter.

copy

public Filter copy()
Description copied from class: Filter
Creates a copy of the Filter for another Sprite to use. The input filter is also copied. The properties of the copy, if any, will be bound to the original filter's properties.

This method is used by the Sprite class. Most apps will not need to call this method.

Subclasses should bind all properties of the cloned object using bindWithInverse(). For example, for the HSBAdjust filter:

        public Filter copy() {
            HSBAdjust copy = new HSBAdjust();
            copy.hue.bindWithInverse(hue);
            copy.brightness.bindWithInverse(brightness);
            copy.saturation.bindWithInverse(saturation);
            return copy;
        }
        

Specified by:
copy in class Filter

update

public void update(int elapsedTime)
Description copied from class: Filter
Updates the filter. The default method does nothing.

Overrides:
update in class Filter

getHeight

public int getHeight()
Description copied from class: Filter
Gets the height of the output of this filter. By default, the height is the same as the input's height.

Overrides:
getHeight in class Filter

getWidth

public int getWidth()
Description copied from class: Filter
Gets the width of the output of this filter. By default, the width is the same as the input's width.

Overrides:
getWidth in class Filter

getX

public int getX()
Description copied from class: Filter
Gets the x offset the output image should display relative to the input.

Overrides:
getX in class Filter

getY

public int getY()
Description copied from class: Filter
Gets the y offset the output image should display relative to the input.

Overrides:
getY in class Filter

filter

protected void filter(CoreImage src,
                      CoreImage dst)
Description copied from class: Filter
Performs this filter on the input image onto the specified output image.

This method is called from Filter.getOutput() if Filter.isDirty() returns true. The output image will be the same dimensions as (Filter.getWidth() x Filter.getHeight(). Implementors must ensure that every pixel in output is drawn.

Specified by:
filter in class Filter

PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.