|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.minueto.image.MinuetoImage
public class MinuetoImage
The MinuetoImage class describes an image that can be drawn on a
MinuetoWindow. All other types of images used by Minueto are subclasses
of MinuetoImage.
Basic 2D image transformations (such as crop, scale, rotate) can be executed
on any MinuetoImage. These transformation produce new MinuetoImage that can
be manipulated independently from their original image.Please note that these
transformations are slow and should not be used in realtime. Results from
these operations should be preferably cached in advanced.
Images are created at the same colordepth as MinuetoWindow. When created, a
MinuetoImage is transparent. Other MinuetoImage can be draw over it, thus
allowing you to build more complexe composite images.
| Constructor Summary | |
|---|---|
MinuetoImage(java.awt.image.BufferedImage image)
Create an image using an existing buffered image. |
|
MinuetoImage(int x,
int y)
Create a blank (transparent) image of the specified width and height. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears the contents of the Drawing Surface. |
void |
clear(MinuetoColor color)
Erases the contents from the Drawing Surface. |
java.lang.Object |
clone()
Creates and returns a copy of this MinuetoImage. |
MinuetoImage |
crop(int cornerX,
int cornerY,
int sizeX,
int sizeY)
Return a cropped copy of this MinuetoImage. |
void |
draw(MinuetoImage image,
int x,
int y)
Draw another MinuetoImage on this MinuetoDrawingSurface (thus compositing them). |
void |
drawCircle(MinuetoColor color,
int x,
int y,
int diameter)
Draw a circle of the specified color at the start point and of the desired diameter. |
void |
drawLine(MinuetoColor color,
int xStart,
int yStart,
int xStop,
int yStop)
Draw a line of the specified color from the start point to the end point. |
void |
drawPolygon(MinuetoColor color,
int[] points)
Draw a polygon of the specified color from the specified points. |
void |
drawRectangle(MinuetoColor color,
int x,
int y,
int width,
int height)
Draw a rectangle of the specified color from the start point and of the desired size. |
MinuetoImage |
flip(boolean horizontal,
boolean vertical)
Returns a flipped copy of this MinuetoImage. |
int |
getHeight()
Return the height of the image. |
MinuetoColor |
getPixel(int x,
int y)
Get the color of the pxel at location x,y. |
int |
getWidth()
Return the width of the image. |
MinuetoImage |
mask(MinuetoColor color)
The mask method creates a new MinuetoImage where
all the non-transparent pxels of this image are replaced
with the provided color. |
MinuetoImage |
rotate(double dAngle)
Return a rotated copy of this MinuetoImage. |
void |
save(java.lang.String filename)
Saves the content of the MinuetoDrawingSurface to a PNG file. |
MinuetoImage |
scale(double factorX,
double factorY)
Return a scaled copy of this MinuetoImage. |
void |
setPixel(int x,
int y,
MinuetoColor color)
Change the color of pxel at location X,y. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MinuetoImage(int x,
int y)
x - int int denoting the width of the blank image.y - intThrows:
MinuetoZeroNegativeException - if the image size is invalid.public MinuetoImage(java.awt.image.BufferedImage image)
image - BufferedImage witht he content of the image.| Method Detail |
|---|
public MinuetoImage crop(int cornerX,
int cornerY,
int sizeX,
int sizeY)
MinuetoImage. The action of cropping an
image can be described as copying a portion of an image to a new image.
cornerX - int denoting the X coordinate of the upper left corner
of the old image to be used as the upper left corner of the new image..cornerY - int denoting the Y coordinate of the upper left corner.
of the old image to be used as the upper left corner of the new image.sizeX - int denoting the width of the portion of the old image to
copy in the new image.sizeY - int denoting the height of the portion of the old image to
copy in the new image.
MinuetoImage of the cropped image.
MinuetoZeroNegativeException - if an invalid position or size is used.
MinuetoOutOfBoundException - if apublic MinuetoImage rotate(double dAngle)
MinuetoImage. The angle must be supplied
in radian.
dAngle - double denoting the rotation angle in radian.
MinuetoImage of the rotated image.
public MinuetoImage scale(double factorX,
double factorY)
MinuetoImage. The parameters are described as
scale factors. Thus, calling the scale function with the 2,2 parameters
would create a image of double width and height.
factorX - double denoting how the image should be scaled on the X axis.factorY - double denoting how the image should be scaled on the Y axis.
MinuetoImage of the scaled image.
MinuetoZeroNegativeException - if a wrong scale factor is used.public MinuetoImage mask(MinuetoColor color)
MinuetoImage where
all the non-transparent pxels of this image are replaced
with the provided color.
color - MinuetoColor denoting the color of the mask.
MinuetoImage of the mask
public MinuetoImage flip(boolean horizontal,
boolean vertical)
MinuetoImage. The image can be
flipped vertically, horizontally, or both. For example, flip(true,
false) would flip the image horizontally.
horizontal - boolean if the image should be flipped on the X axis.vertical - boolean if the image should be flipped on the Y axis.
MinuetoImage of the flipped image.
public void setPixel(int x,
int y,
MinuetoColor color)
MinuetoDrawingSurfaceThis uses the drawLine function to be faster than a direct raw data setPxel, though it should be used with caution as it is still slower than drawing a completed image to the drawing surface.
setPixel in interface MinuetoDrawingSurfacex - int denoting which pxel on the X axis should be colored.y - int denoting which pxel on the y axis should be colored.color - MinuetoColor denoting the new color for pxel x,y.
public MinuetoColor getPixel(int x,
int y)
Note: Pxel manipulation of a MinuetoImage is a very slow operation. It should
not be used in realtime.
x - int denoting which pxel on the X axis we are targeting.y - int denoting which pxel on the y axis we are targeting.
MinuetoColor denoting the color of the specified pxel.public void clear()
MinuetoDrawingSurface
clear in interface MinuetoDrawingSurfacepublic void clear(MinuetoColor color)
MinuetoDrawingSurface
clear in interface MinuetoDrawingSurfacecolor - MinuetoColor of the cleared buffer.
public void draw(MinuetoImage image,
int x,
int y)
MinuetoDrawingSurfaceMinuetoImage on this MinuetoDrawingSurface (thus compositing them).
draw in interface MinuetoDrawingSurfaceimage - MinuetoImage that we will draw on our image.x - int denoting where we should start drawing on the x axis.y - int denothing where we should start drawing on the y axis.
public void drawLine(MinuetoColor color,
int xStart,
int yStart,
int xStop,
int yStop)
MinuetoDrawingSurface
drawLine in interface MinuetoDrawingSurfacecolor - MinuetoColor denoting the color of the line.xStart - int denoting the X value of the start point.yStart - int denoting the Y value of the start point.xStop - int denoting the X value of the end point.yStop - int denoting the Y value of the end point.public int getWidth()
MinuetoDrawingSurface
getWidth in interface MinuetoDrawingSurfaceint denoting the width of the image.public int getHeight()
MinuetoDrawingSurface
getHeight in interface MinuetoDrawingSurfaceint denoting the height of the image.
public void drawRectangle(MinuetoColor color,
int x,
int y,
int width,
int height)
color - MinuetoColor denoting the color of the rectangle.x - int denoting the x value of the start point.y - int denoting the y value of the start point.width - int denoting the width of the rectangle.height - int denoting the height of the rectangle.
MinuetoOutOfBoundException - if the target coordinates are not
valid.
public void drawPolygon(MinuetoColor color,
int[] points)
color - MinuetoColor denoting the color of the rectangle.points - int[] denoting the points of the polygon.
public void drawCircle(MinuetoColor color,
int x,
int y,
int diameter)
color - MinuetoColor denoting the color of the circle.x - int denoting the x value of the start point.y - int denoting the y value of the start point.diameter - int denoting the diameter of the circle.
MinuetoOutOfBoundException - if the target coordinates are not
valid.
public void save(java.lang.String filename)
throws MinuetoFileException
MinuetoDrawingSurface
save in interface MinuetoDrawingSurfacefilename - String indicating the name of the PNG file.
MinuetoFileExceptionpublic java.lang.Object clone()
clone in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||