com.realtime.crossfire.jxclient.faces
Class RawScale2x

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

public class RawScale2x
extends java.lang.Object

A simple implementation of the Scale2x algorithm for scaling raw image data.


Field Summary
private  int[] dstImage
          The destination image data.
private  int height
          The height of the source image.
private  int[] srcImage
          The source image data.
private  int width
          The width of the source image.
 
Constructor Summary
RawScale2x(int[] imageData, int dataWidth, int dataHeight)
          Creates a new scaler based on some raw data.
 
Method Summary
private static boolean different(int a, int b)
          Checks if two pixels are different.
 int[] getScaledData()
          Gets 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 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.


srcImage

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


width

private final int width
The width of the source image.

Constructor Detail

RawScale2x

public RawScale2x(@NotNull
                  int[] imageData,
                  int dataWidth,
                  int dataHeight)
Creates a new scaler based on some raw data. Right now it doesn't matter what order the channels in, just that its an int per pixel

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

different

private static boolean different(int a,
                                 int b)
Checks if two pixels are different. Place holder for maybe some clever code about tolerance checking.

Parameters:
a - the first pixel value
b - the second pixel value
Returns:
true if the pixels are different

getScaledData

@NotNull
public int[] getScaledData()
Gets 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 4 times the size of the input array containing the smoothly scaled image

getSourcePixel

private int getSourcePixel(int x,
                           int y)
Gets a pixel from the source image. This handles bonds checks and resolves to edge pixels.

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 pixel. This will generate 4 pixels in the destination image based on the scale2x algorithm.

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