net.jot.image
Class JOTAbstractImage

java.lang.Object
  extended by net.jot.image.JOTAbstractImage
Direct Known Subclasses:
JOTCaptchaImage

public class JOTAbstractImage
extends java.lang.Object

Represent an image data in a plain format, decoupled from storage format and AWT. Data is stored in simple byteArray, RGBA(4 ints per pixel) ~ potentially a memory hog.

Author:
thibautc

Field Summary
static int ALPHA_SUPPORT_NONE
          Default: Alpha values are ignored, but much faster perfomance
static int ALPHA_SUPPORT_SIMPLE_BLEND
          If a pixel is set a new color, we will mix the new color with the old one.
 
Constructor Summary
JOTAbstractImage(int width, int height)
           
JOTAbstractImage(int width, int height, int alphaSupport)
           
 
Method Summary
 void drawFilledRectangle(int x, int y, int x2, int y2, JOTAbstractPixel pixel)
           
protected  void drawHorizontalLine(int lineThickness, int x, int x2, int y, JOTAbstractPixel pixel)
           
 void drawLine(int lineThickness, int x, int y, int x2, int y2, JOTAbstractPixel pixel)
           
 void drawRectangle(int lineThickness, int x, int y, int x2, int y2, JOTAbstractPixel pixel)
           
protected  void drawVerticalLine(int lineThickness, int x, int y, int y2, JOTAbstractPixel pixel)
           
 void fillImage(JOTAbstractPixel pixel)
          fill the whole image with the same pixel ie: set a background
 int getColorDepth(long maxColors)
          return the color depth in bits (ie: how big the palette needs to be) ie: 1: 2 colors or less 4: 16 colors or less 8: 256 colors or less 16: 65536 colors or less 24: 16 777 216 colors or less 32: > 16 777 216 colors resource intensive Note: maxColors, is the maximum you want to look for, if more that "maxColor" colors are found, an exception will be thrown.
 int[] getData()
           
 int getHeight()
           
 JOTAbstractPixel getPixel(int x, int y)
           
 int getWidth()
           
 void setPixel(int x, int y, JOTAbstractPixel pixel)
           
 int writeToStream(JOTAbstractImageWriterInterface imageWriter, java.io.OutputStream stream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALPHA_SUPPORT_NONE

public static final int ALPHA_SUPPORT_NONE
Default: Alpha values are ignored, but much faster perfomance

See Also:
Constant Field Values

ALPHA_SUPPORT_SIMPLE_BLEND

public static final int ALPHA_SUPPORT_SIMPLE_BLEND
If a pixel is set a new color, we will mix the new color with the old one. ie: if ALPHA is 25% for the new color we will do: TODO: revise formula R(G,B)=(oldR*75/100 + newR*25/100)/2 A=newA TODO:

See Also:
Constant Field Values
Constructor Detail

JOTAbstractImage

public JOTAbstractImage(int width,
                        int height,
                        int alphaSupport)
Parameters:
width -
height -
alphaSupport: - default is alpha support disabled(faster)

JOTAbstractImage

public JOTAbstractImage(int width,
                        int height)
Method Detail

setPixel

public void setPixel(int x,
                     int y,
                     JOTAbstractPixel pixel)

getPixel

public JOTAbstractPixel getPixel(int x,
                                 int y)

getData

public int[] getData()

getHeight

public int getHeight()

getWidth

public int getWidth()

getColorDepth

public int getColorDepth(long maxColors)
                  throws java.lang.Exception
return the color depth in bits (ie: how big the palette needs to be) ie: 1: 2 colors or less 4: 16 colors or less 8: 256 colors or less 16: 65536 colors or less 24: 16 777 216 colors or less 32: > 16 777 216 colors resource intensive Note: maxColors, is the maximum you want to look for, if more that "maxColor" colors are found, an exception will be thrown.

Returns:
Throws:
java.lang.Exception

drawRectangle

public void drawRectangle(int lineThickness,
                          int x,
                          int y,
                          int x2,
                          int y2,
                          JOTAbstractPixel pixel)

drawFilledRectangle

public void drawFilledRectangle(int x,
                                int y,
                                int x2,
                                int y2,
                                JOTAbstractPixel pixel)

fillImage

public void fillImage(JOTAbstractPixel pixel)
fill the whole image with the same pixel ie: set a background

Parameters:
pixel -

drawLine

public void drawLine(int lineThickness,
                     int x,
                     int y,
                     int x2,
                     int y2,
                     JOTAbstractPixel pixel)

drawHorizontalLine

protected void drawHorizontalLine(int lineThickness,
                                  int x,
                                  int x2,
                                  int y,
                                  JOTAbstractPixel pixel)

drawVerticalLine

protected void drawVerticalLine(int lineThickness,
                                int x,
                                int y,
                                int y2,
                                JOTAbstractPixel pixel)

writeToStream

public int writeToStream(JOTAbstractImageWriterInterface imageWriter,
                         java.io.OutputStream stream)
                  throws java.lang.Exception
Throws:
java.lang.Exception