org.java_lcw.jil
public class Image extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Image.Color
This class is how colors are passed around to/from the Image Object
|
static class |
Image.ImageException |
static class |
Image.ImageType
Image Types for Image Object to use (open/save)
|
static class |
Image.ScaleType
ScaleTypes that can be used when resizing an Image.
|
Modifier and Type | Field and Description |
---|---|
static byte |
MODE_L
MODE_L is grey scaled image (8 bits per pixel, 1 channel)
|
static byte |
MODE_RGB
MODE_RGB is an RGB (Red Green Blue) image Each color is its own Channel (24 bits per pixel, 3 channels)
|
static byte |
MODE_RGBA
MODE_RGBA is an RGBA (Red Green Blue Alpha) image Each color and alpha has its own Channel (32 bits per pixel, 4 channels)
|
Modifier and Type | Method and Description |
---|---|
Image |
changeMode(byte MODE)
Change the MODE of the current Image.
|
Image |
copy() |
static Image |
create(byte mode,
int width,
int height)
Main Method for creating a new Image
|
Image |
cut(int x,
int y,
int width,
int height) |
void |
fillColor(Image.Color c)
Fill current Image with this color
|
static Image |
fromBufferedImage(java.awt.image.BufferedImage BI)
Create an Image from a BufferedImage from AWT - The new Image will always be RGBA type
|
static Image |
fromByteArray(byte mode,
int width,
int height,
byte[] data)
Create an Image object from a byte Array.
|
static Image |
fromImageData(org.eclipse.swt.graphics.ImageData data)
This takes ImageData from SWT and makes an Image Object.
|
byte |
getBPP()
Get the number of bitsPerPixel, this is the same as the Image.MODE_ of the Image
|
byte |
getChannels()
Returns the number channels in this Image (BPP/8)
|
int |
getHeight()
Returns the height of this Image
|
Image.Color |
getPixel(int x,
int y)
The a color for a given pixel
|
byte |
getPixelInChannel(int x,
int y,
byte c) |
int |
getWidth()
Returns the width of this Image
|
void |
mkRandom()
Sets this Image to random Data
|
static Image |
open(java.lang.String filename)
Static Method that allows you to open a file, just pass in the path/filename.
|
static Image |
open(java.lang.String filename,
Image.ImageType type)
Static Method that allows you to open a file, just pass in the path/filename.
|
void |
paste(int x,
int y,
Image img)
Paste the given Image object onto this Image
If the given Image is taller or wider then this Image we only merge the visible bits onto this Image
|
Image |
resize(int width,
int height)
This resizes the Image, uses the Nearest Neighbor scaler, and keeps aspect ratio
|
Image |
resize(int width,
int height,
boolean keepAspect)
This resizes the Image, uses the Nearest Neighbor scaler, and keeps aspect ratio
|
Image |
resize(int width,
int height,
boolean keepAspect,
Image.ScaleType st)
This resizes the Image
|
void |
save(java.lang.String filename)
Save the image to the given file name.
|
void |
save(java.lang.String filename,
Image.ImageType type)
Save the image to the given file name.
|
protected void |
setChannel(byte channel,
byte[] array) |
void |
setPixel(int x,
int y,
Image.Color c)
Set a pixel in this image to a given Color
|
void |
setPixelInChannel(int x,
int y,
byte c,
byte p) |
byte[] |
toArray()
Outputs this image to a ByteArray.
|
java.awt.image.BufferedImage |
toBufferedImage()
Take the current Image object and make a BufferedImage out of it.
|
org.eclipse.swt.graphics.ImageData |
toImageData()
Create an SWT ImageData object based from the current Image object
|
public static final byte MODE_L
public static final byte MODE_RGB
public static final byte MODE_RGBA
public static Image create(byte mode, int width, int height)
mode
- Image mode, uses the static bytes Image.MODE_(L, RGB, RGBA)width
- How wide the image should be in pixelsheight
- How high the Image should be in pixelspublic static Image fromByteArray(byte mode, int width, int height, byte[] data) throws Image.ImageException
mode
- Image mode, uses the static bytes Image.MODE_(L, RGB, RGBA)width
- How wide the image should be in pixelsheight
- How high the Image should be in pixelsdata
- byte[] to use to loading the dataImage.ImageException
- This happens if the data provided is to large or to small for the (mode/8)*width*heightpublic static Image open(java.lang.String filename) throws Image.ImageException, java.io.IOException
filename
- Filename to attempt to open.Image.ImageException
- This can happen if we do not know the type of file we where asked to open.java.io.IOException
- This happens when we can not access the file.public static Image open(java.lang.String filename, Image.ImageType type) throws java.io.IOException, Image.ImageException
filename
- Filename to attempt to open.type
- Type of file to open used Image.ImageType.(TIFF, PNG, JPEG)Image.ImageException
- This can happen if we do not know the type of file we where asked to open.java.io.IOException
- This happens when we can not access the file.public void save(java.lang.String filename) throws java.io.IOException, Image.ImageException
filename
- Path/Name of the file to savejava.io.IOException
- This happens if we can not save/open that fileImage.ImageException
- This happens if we can not figure out the type you want use to save aspublic void save(java.lang.String filename, Image.ImageType type) throws java.io.IOException, Image.ImageException
filename
- Path/Name of the file to savetype
- Type of file to open used Image.ImageType.(TIFF, PNG, JPEG)java.io.IOException
- This happens if we can not save/open that fileImage.ImageException
- This happens if we can not figure out the type you want use to save aspublic static Image fromBufferedImage(java.awt.image.BufferedImage BI) throws Image.ImageException
BI
- BufferedImage to use to make the Image objectImage.ImageException
- This happens if there is something wrong with the BufferedImagepublic java.awt.image.BufferedImage toBufferedImage() throws Image.ImageException
Image.ImageException
public static Image fromImageData(org.eclipse.swt.graphics.ImageData data) throws Image.ImageException
data
- ImageData object to create an Image object from.Image.ImageException
public org.eclipse.swt.graphics.ImageData toImageData()
public Image changeMode(byte MODE) throws Image.ImageException
MODE
- Sets the Image.MODE_ to change toImage.ImageException
public Image resize(int width, int height)
width
- new Widthheight
- new Heightpublic Image resize(int width, int height, boolean keepAspect)
width
- new Widthheight
- new HeightkeepAspect
- boolean, true means keep aspect, false means dont keep the aspectpublic Image resize(int width, int height, boolean keepAspect, Image.ScaleType st)
width
- new Widthheight
- new HeightkeepAspect
- boolean, true means keep aspect, false means dont keep the aspectst
- ScaleType to use (see Image.ScaleTypes)public void fillColor(Image.Color c)
c
- public void setPixel(int x, int y, Image.Color c)
x
- X position of the pixely
- Y position of the pixelc
- Color to set the pixel to (see Image.Color)public void setPixelInChannel(int x, int y, byte c, byte p)
public Image.Color getPixel(int x, int y)
x
- X position of the pixely
- Y position of the pixelpublic byte getPixelInChannel(int x, int y, byte c)
public void paste(int x, int y, Image img) throws Image.ImageException
x
- X position to start the mergey
- Y position to start the mergeimg
- Image object to mergeImage.ImageException
public Image copy() throws Image.ImageException
Image.ImageException
public Image cut(int x, int y, int width, int height) throws Image.ImageException
Image.ImageException
public void mkRandom()
protected void setChannel(byte channel, byte[] array) throws Image.ImageException
Image.ImageException
public byte[] toArray()
public byte getBPP()
public byte getChannels()
public int getWidth()
public int getHeight()