com.realtime.crossfire.jxclient.faces
Class RawScale8d

java.lang.Object
  extended by com.realtime.crossfire.jxclient.faces.RawScale8d

public class RawScale8d
extends java.lang.Object

Scales down a raw image to an eighth in both dimensions.


Field Summary
private  int[] dstImage
          The destination image data.
private  int height
          The height of the source image.
private  java.util.Map<java.lang.Integer,java.lang.Integer> pixels
          Maps pixel value to number of pixels.
private  int[] srcImage
          The source image data.
private  int width
          The width of the source image.
 
Constructor Summary
RawScale8d(int[] imageData, int dataWidth, int dataHeight)
          Creates a new instance.
 
Method Summary
 int[] getScaledData()
          Returns the scale image data.
private  int getSourcePixel(int x, int y)
          Gets a pixel from the source image.
private  void process(int x, int y)
          Processes a specific destination pixel.
private  void setDestPixel(int x, int y, int p)
          Sets a pixel in the destination image data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dstImage

@NotNull
private final int[] dstImage
The destination image data.


height

private final int height
The height of the source image.


pixels

@NotNull
private final java.util.Map<java.lang.Integer,java.lang.Integer> pixels
Maps pixel value to number of pixels.


srcImage

@NotNull
private final int[] srcImage
The source image data.


width

private final int width
The width of the source image.

Constructor Detail

RawScale8d

public RawScale8d(@NotNull
                  int[] imageData,
                  int dataWidth,
                  int dataHeight)
Creates a new instance.

Parameters:
imageData - the source image data to process
dataWidth - the width of the source image
dataHeight - the height of the source image
Method Detail

getScaledData

@NotNull
public int[] getScaledData()
Returns the scale image data. Note this is the method that does the work so it might take some time to process.

Returns:
an array of pixels 64 times smaller than the input array containing the scaled down image

getSourcePixel

private int getSourcePixel(int x,
                           int y)
Gets a pixel from the source image.

Parameters:
x - the x location of the pixel to retrieve
y - the y location of the pixel to retrieve
Returns:
the pixel value at the specified location

process

private void process(int x,
                     int y)
Processes a specific destination pixel.

Parameters:
x - the x location in the source image of the pixel to process
y - the y location in the source image of the pixel to process

setDestPixel

private void setDestPixel(int x,
                          int y,
                          int p)
Sets a pixel in the destination image data.

Parameters:
x - the x location of the pixel to set
y - the y location of the pixel to set
p - the value of the pixel to set