marvin.image
Class MarvinImage

java.lang.Object
  extended by marvin.image.MarvinImage
All Implemented Interfaces:
java.lang.Cloneable

public class MarvinImage
extends java.lang.Object
implements java.lang.Cloneable

Image object with many operations. This class is the image representation used for the other classes in the framework.


Field Summary
protected  int[] arrColor
           
protected  int b
           
protected  java.awt.Color color
           
protected  java.lang.String filePath
           
protected  java.lang.String formatName
           
protected  int g
           
protected  java.awt.image.BufferedImage image
           
protected  int numComponents
           
static int PROPORTIONAL
           
protected  int r
           
protected  int rgb
           
static int TYPE_INT_RGB
           
 
Constructor Summary
MarvinImage(java.awt.image.BufferedImage img)
          Constructor using a image in memory
MarvinImage(java.awt.image.BufferedImage img, java.lang.String fmtName)
          Constructor using a image in memory
MarvinImage(int w, int h)
          Constructor to blank image, passing the size of image
 
Method Summary
 int boundRGB(int rgb)
           
 void clearImage(int color)
           
 MarvinImage clone()
          Clones the MarvinImage
static void copyIntColorArray(MarvinImage imgSource, MarvinImage imgDestine)
           
 MarvinImage crop(int x, int y, int w, int h)
           
 void drawLine(int x0, int y0, int x1, int y1, java.awt.Color c)
          Bresenham´s Line Drawing implementation
 void drawRect(int x, int y, int w, int h, java.awt.Color c)
          Draws a rectangle in the image.
 boolean equals(java.lang.Object obj)
          Compare two MarvinImage objects
 void fillRect(int x, int y, int w, int h, java.awt.Color c)
          Fills a rectangle in the image.
 java.awt.image.BufferedImage getBufferedImage()
           
 java.awt.image.BufferedImage getBufferedImage(int width, int height)
          Resize and return the image passing the new height and width
 java.awt.image.BufferedImage getBufferedImage(int width, int height, int type)
          Resize and return the image passing the new height and width, but maintains width/height factor
 int getComponents()
           
 java.lang.String getFilePath()
           
 java.lang.String getFormatName()
           
 int getHeight()
          Returns the height
 int getIntColor(int x, int y)
          Gets the integer color composition for x, y position
 int[] getIntColorArray()
           
 int getIntComponent0(int x, int y)
          Gets the integer color component 0 in the x and y position
 int getIntComponent1(int x, int y)
          Gets the integer color component 1 in the x and y position
 int getIntComponent2(int x, int y)
          Gets the integer color component 2 in the x and y position
 java.awt.image.BufferedImage getNewImageInstance()
          Return a new instance of the BufferedImage
 int getType()
          Gets the type
 int getWidth()
          Returns the width
 int limit8bitsColor(int color)
          Limits the color value between 0 and 255.
 double multi8p(int x, int y, double masc)
          Multiple of gradient windwos per masc relation of x y
 int[] Multi8p(int x, int y, int[][] masc)
          Convolution operator
 void resize(int w, int h)
          Resize the image passing the new height and width
 void setBufferedImage(java.awt.image.BufferedImage img)
          Sets a new image
 void setDimension(int w, int h)
           
 void setFilePath(java.lang.String fp)
           
 void setIntColor(int x, int y, int color)
          Sets the integer color composition in X an Y position
 void setIntColor(int x, int y, int c0, int c1, int c2)
          Sets the integer color in X an Y position
 void setIntColorArray(int[] arr)
          Set the integer color array for the entire image.
 void update()
           
 void updateColorArray()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_INT_RGB

public static final int TYPE_INT_RGB
See Also:
Constant Field Values

PROPORTIONAL

public static final int PROPORTIONAL
See Also:
Constant Field Values

image

protected java.awt.image.BufferedImage image

filePath

protected java.lang.String filePath

arrColor

protected int[] arrColor

rgb

protected int rgb

r

protected int r

b

protected int b

g

protected int g

color

protected java.awt.Color color

formatName

protected java.lang.String formatName

numComponents

protected int numComponents
Constructor Detail

MarvinImage

public MarvinImage(java.awt.image.BufferedImage img)
Constructor using a image in memory

Parameters:
img - Image

MarvinImage

public MarvinImage(java.awt.image.BufferedImage img,
                   java.lang.String fmtName)
Constructor using a image in memory

Parameters:
img - Image
fmtName - Image format name

MarvinImage

public MarvinImage(int w,
                   int h)
Constructor to blank image, passing the size of image

Parameters:
int - width
int - height
Method Detail

getComponents

public int getComponents()

crop

public MarvinImage crop(int x,
                        int y,
                        int w,
                        int h)

updateColorArray

public void updateColorArray()

update

public void update()

clearImage

public void clearImage(int color)

getType

public int getType()
Gets the type


getFormatName

public java.lang.String getFormatName()

setFilePath

public void setFilePath(java.lang.String fp)
Parameters:
fp - : file path to this MarvinImage

getFilePath

public java.lang.String getFilePath()
Returns:
file path associated to this MarvinImage, if exists.

setDimension

public void setDimension(int w,
                         int h)

getIntColorArray

public int[] getIntColorArray()
Returns:
integer color array for the entire image.

setIntColorArray

public void setIntColorArray(int[] arr)
Set the integer color array for the entire image.


copyIntColorArray

public static void copyIntColorArray(MarvinImage imgSource,
                                     MarvinImage imgDestine)

getIntColor

public int getIntColor(int x,
                       int y)
Gets the integer color composition for x, y position

Parameters:
int - x
int - y
Returns:
int color

getIntComponent0

public int getIntComponent0(int x,
                            int y)
Gets the integer color component 0 in the x and y position

Parameters:
int - x
int - y
Returns:
int color component 0

getIntComponent1

public int getIntComponent1(int x,
                            int y)
Gets the integer color component 1 in the x and y position

Parameters:
int - x
int - y
Returns:
int color component 1

getIntComponent2

public int getIntComponent2(int x,
                            int y)
Gets the integer color component 2 in the x and y position

Parameters:
int - x
int - y
Returns:
int blue color

getWidth

public int getWidth()
Returns the width

Returns:
int width

getHeight

public int getHeight()
Returns the height

Returns:
int height

setIntColor

public void setIntColor(int x,
                        int y,
                        int color)
Sets the integer color composition in X an Y position

Parameters:
x - position
y - position
color - color value

setIntColor

public void setIntColor(int x,
                        int y,
                        int c0,
                        int c1,
                        int c2)
Sets the integer color in X an Y position

Parameters:
x - position
y - position
c0 - component 0
c1 - component 1
c2 - component 2

setBufferedImage

public void setBufferedImage(java.awt.image.BufferedImage img)
Sets a new image

Parameters:
BufferedImage - imagem

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()

limit8bitsColor

public int limit8bitsColor(int color)
Limits the color value between 0 and 255.

Returns:
int - the color value

Multi8p

public int[] Multi8p(int x,
                     int y,
                     int[][] masc)
Convolution operator

Returns:
int[]

getNewImageInstance

public java.awt.image.BufferedImage getNewImageInstance()
Return a new instance of the BufferedImage

Returns:
BufferedImage

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage(int width,
                                                     int height)
Resize and return the image passing the new height and width

Parameters:
height -
width -
Returns:

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage(int width,
                                                     int height,
                                                     int type)
Resize and return the image passing the new height and width, but maintains width/height factor

Parameters:
height -
width -
Returns:

resize

public void resize(int w,
                   int h)
Resize the image passing the new height and width

Parameters:
height -
width -

clone

public MarvinImage clone()
Clones the MarvinImage

Overrides:
clone in class java.lang.Object

multi8p

public double multi8p(int x,
                      int y,
                      double masc)
Multiple of gradient windwos per masc relation of x y

Returns:
int[]

boundRGB

public int boundRGB(int rgb)

drawLine

public void drawLine(int x0,
                     int y0,
                     int x1,
                     int y1,
                     java.awt.Color c)
Bresenham´s Line Drawing implementation


drawRect

public void drawRect(int x,
                     int y,
                     int w,
                     int h,
                     java.awt.Color c)
Draws a rectangle in the image. It´s useful for debugging purposes.

Parameters:
x - rect´s start position in x-axis
y - rect´s start positioj in y-axis
w - rect´s width
h - rect´s height
c - rect´s color

fillRect

public void fillRect(int x,
                     int y,
                     int w,
                     int h,
                     java.awt.Color c)
Fills a rectangle in the image.

Parameters:
x - rect´s start position in x-axis
y - rect´s start positioj in y-axis
w - rect´s width
h - rect´s height
c - rect´s color

equals

public boolean equals(java.lang.Object obj)
Compare two MarvinImage objects

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to be compared. MarvinImage object is expected.