Compact Class For Java – CCImage


Compact Class is a collection of common functions and classes that can make your code more concise, fast, and precise.

utility

Class CCImage

java.lang.Object

extended by

utility.CCImage

public class CCImageextends java.lang.Object

CCImage is a collection of methods to manipulate the image.

Since:
10.03.17
Version:
12.03.17
Author:
Yosua Onesimus


Field Detail

THUMBNAIL

public static int THUMBNAIL
THUMBNAIL = 120

GRAPHICS

public static final java.awt.GraphicsConfiguration GRAPHICS
GRAPHICS = null


Constructor Detail

CCImage

public CCImage()


Method Detail

getImage

public static java.awt.image.BufferedImage getImage(java.io.File file)
Returns a BufferedImage as the result of decoding a supplied File with an
ImageReader chosen automatically from among those currently registered.
The File is wrapped in an ImageInputStream. If no registered ImageReader
claims to be able to read the resulting stream, null is returned.

 

Parameters:
file – a File to read from.

 

Returns:a BufferedImage containing the decoded contents of the input, or
null.


getImage

public static java.awt.image.BufferedImage getImage(javax.imageio.stream.ImageInputStream imageInputStream)
Returns a BufferedImage as the result of decoding a supplied
ImageInputStream with an ImageReader chosen automatically from among
those currently registered. If no registered ImageReader claims to be
able to read the stream, null is returned.

 

Parameters:
imageInputStream – an ImageInputStream to read from.

 

Returns:a BufferedImage containing the decoded contents of the input, or
null.


getImage

public static java.awt.image.BufferedImage getImage(java.io.InputStream inputStream)
Returns a BufferedImage as the result of decoding a supplied InputStream
with an ImageReader chosen automatically from among those currently
registered. The InputStream is wrapped in an ImageInputStream. If no
registered ImageReader claims to be able to read the resulting stream,
null is returned.

 

Parameters:
inputStream – an InputStream to read from.

 

Returns:a BufferedImage containing the decoded contents of the input, or
null.


getImage

public static java.awt.image.BufferedImage getImage(java.net.URL url)
Returns a BufferedImage as the result of decoding a supplied URL with an
ImageReader chosen automatically from among those currently registered.
An InputStream is obtained from the URL, which is wrapped in an
ImageInputStream. If no registered ImageReader claims to be able to read
the resulting stream, null is returned.

 

Parameters:
url – a URL to read from.

 

Returns:a BufferedImage containing the decoded contents of the input, or
null.


getImage

public static java.awt.image.BufferedImage getImage(java.lang.String name)
Returns a BufferedImage as the result of decoding a supplied URL with an
ImageReader chosen automatically from among those currently registered.
An InputStream is obtained from the URL, which is wrapped in an
ImageInputStream. If no registered ImageReader claims to be able to read
the resulting stream, null is returned.
Same as :
 getImage(CCImage.class.getResource(name));

 

Parameters:
name – name of the desired resource

 

Returns:a BufferedImage containing the decoded contents of the input, or
null.


getImage

public static java.awt.image.BufferedImage getImage(byte[] byteA)
Returns a BufferedImage as the result of decoding a supplied InputStream
with an ImageReader chosen automatically from among those currently
registered. The InputStream is wrapped in an ImageInputStream. If no
registered ImageReader claims to be able to read the resulting stream,
null is returned.
Same as :
 getImage(new ByteArrayInputStream(byteA));

 

Parameters:
byteA – the input buffer.

 

Returns:a BufferedImage containing the decoded contents of the input, or
null.


getByteA

public static byte[] getByteA(java.awt.image.BufferedImage bufferedImage)
Creates a newly allocated byte array. Its size is the current size of
this output stream and the valid contents of the buffer have been copied
into it.

 

Parameters:
bufferedImage – a RenderedImage to be written.

 

Returns:byte[]


getByteA

public static byte[] getByteA(java.io.File file)
Creates a newly allocated byte array. Its size is the current size of
this output stream and the valid contents of the buffer have been copied
into it.
Same as :
 getByteA(getImage(file));

 

Parameters:
file – a File to read from.

 

Returns:byte[]


getByteA

public static byte[] getByteA(javax.imageio.stream.ImageInputStream imageInputStream)
Creates a newly allocated byte array. Its size is the current size of
this output stream and the valid contents of the buffer have been copied
into it.
Same as :
 getByteA(getImage(imageInputStream));

 

Parameters:
imageInputStream – an ImageInputStream to read from.

 

Returns:byte[]


getByteA

public static byte[] getByteA(java.io.InputStream inputStream)
Creates a newly allocated byte array. Its size is the current size of
this output stream and the valid contents of the buffer have been copied
into it.
Same as :
 getByteA(getImage(inputStream));

 

Parameters:
inputStream – an InputStream to read from.

 

Returns:byte[]


getByteA

public static byte[] getByteA(java.net.URL url)
Creates a newly allocated byte array. Its size is the current size of
this output stream and the valid contents of the buffer have been copied
into it.
Same as :
 getByteA(getImage(url));

 

Parameters:
url – a URL to read from.

 

Returns:byte[]


getByteA

public static byte[] getByteA(java.lang.String name)
Creates a newly allocated byte array. Its size is the current size of
this output stream and the valid contents of the buffer have been copied
into it.
Same as :
 getByteA(getImage(name));

 

Parameters:
name – name of the desired resource

 

Returns:byte[]


resizeImage

public static java.awt.image.BufferedImage resizeImage(java.awt.image.BufferedImage originalImage,
                                                       int width,
                                                       int height)
Renders an image, applying a transform from image space into user space
before drawing.

 

Parameters:
originalImage – the specified image to be drawn. This method does
nothing if img is null.
width– width of the created image
height – height of the created image

 

Returns:a Graphics2D, used for drawing into this image.


resizeImage_ByWidth

public static java.awt.image.BufferedImage resizeImage_ByWidth(java.awt.image.BufferedImage originalImage,
                                                               int width)
Renders an image, applying a transform from image space into user space
before drawing.

 

Parameters:
originalImage
width

 

Returns:a Graphics2D, used for drawing into this image.


resizeImage_ByHeight

public static java.awt.image.BufferedImage resizeImage_ByHeight(java.awt.image.BufferedImage originalImage,
                                                                int height)
Renders an image, applying a transform from image space into user space
before drawing.

 

Parameters:
originalImage
height

 

Returns:a Graphics2D, used for drawing into this image.


resizeImage_ByPercent

public static java.awt.image.BufferedImage resizeImage_ByPercent(java.awt.image.BufferedImage originalImage,
                                                                 int percent)
Renders an image, applying a transform from image space into user space
before drawing.

 

Parameters:
originalImage
percent

 

Returns:a Graphics2D, used for drawing into this image.


getThumbnail

public static java.awt.image.BufferedImage getThumbnail(java.awt.image.BufferedImage originalImage)
Renders an image, applying a transform from image space into user space
before drawing.

 

Parameters:
originalImage

 

Returns:a Graphics2D, used for drawing into this image.


setImage

public static boolean setImage(java.awt.image.BufferedImage bufferedImage,
                               java.lang.String formatName,
                               java.io.File file)
Writes an image using an arbitrary ImageWriter that supports the given
format to a File. If there is already a File present, its contents are
discarded.

 

Parameters:
bufferedImage– a RenderedImage to be written.
formatName– a String containg the informal name of the format.
file – a File to be written to.

 

Returns:false if no appropriate writer is found.


setImage

public static boolean setImage(java.awt.image.BufferedImage bufferedImage,
                               java.lang.String formatName,
                               javax.imageio.stream.ImageOutputStream imageOutputStream)
Writes an image using the an arbitrary ImageWriter that supports the
given format to an ImageOutputStream. The image is written to the
ImageOutputStream starting at the current stream pointer, overwriting
existing stream data from that point forward, if present.

 

Parameters:
bufferedImage– a RenderedImage to be written.
formatName– a String containg the informal name of the format.
imageOutputStream – an ImageOutputStream to be written to.

 

Returns:false if no appropriate writer is found.


setImage

public static boolean setImage(java.awt.image.BufferedImage bufferedImage,
                               java.lang.String formatName,
                               java.io.OutputStream outputStream)
Writes an image using an arbitrary ImageWriter that supports the given
format to an OutputStream.

 

Parameters:
bufferedImage– a RenderedImage to be written.
formatName– a String containg the informal name of the format.
outputStream – an OutputStream to be written to.

 

Returns:false if no appropriate writer is found.


setImage

public static boolean setImage(java.awt.image.BufferedImage bufferedImage,
                               java.io.File file)
Writes an image using an arbitrary ImageWriter that supports the given
format to a File. If there is already a File present, its contents are
discarded.
Same as :
 setImage(bufferedImage, "jpg", file);

 

Parameters:
bufferedImage– a RenderedImage to be written.
file – a File to be written to.

 

Returns:false if no appropriate writer is found.


setImage

public static boolean setImage(java.awt.image.BufferedImage bufferedImage,
                               javax.imageio.stream.ImageOutputStream imageOutputStream)
Writes an image using the an arbitrary ImageWriter that supports the
given format to an ImageOutputStream. The image is written to the
ImageOutputStream starting at the current stream pointer, overwriting
existing stream data from that point forward, if present.
Same as :
 setImage(bufferedImage, "jpg", imageOutputStream);

 

Parameters:
bufferedImage– a RenderedImage to be written.
imageOutputStream – an ImageOutputStream to be written to.

 

Returns:false if no appropriate writer is found.


setImage

public static boolean setImage(java.awt.image.BufferedImage bufferedImage,
                               java.io.OutputStream outputStream)
Writes an image using an arbitrary ImageWriter that supports the given
format to an OutputStream.
Same as :
 setImage(bufferedImage, "jpg", outputStream);

 

Parameters:
bufferedImage– a RenderedImage to be written.
outputStream – an OutputStream to be written to.

 

Returns:false if no appropriate writer is found.


newImage

public static java.awt.image.BufferedImage newImage(int width,
                                                    int height,
                                                    int transparency)
Returns a BufferedImage that supports the specified transparency and has
a data layout and color model compatible with this GraphicsConfiguration.
This method has nothing to do with memory-mapping a device. The returned
BufferedImage has a layout and color model that can be optimally blitted
to a device with this GraphicsConfiguration.

 

Parameters:
width– the width of the returned BufferedImage
height– the height of the returned BufferedImage
transparency – the specified transparency mode

 

Returns:a BufferedImage whose data layout and color model is compatible
with this GraphicsConfiguration and also supports the specified
transparency.See Also:Transparency.BITMASK,
Transparency.OPAQUE,
Transparency.TRANSLUCENT


getImage_Transparency

public static java.awt.image.BufferedImage getImage_Transparency(java.awt.Image image,
                                                                 int transparency)
Parameters:
image
transparency

Returns:BufferedImageSee Also:Transparency.BITMASK,
Transparency.OPAQUE,
Transparency.TRANSLUCENT


getImage_Bitmask

public static java.awt.image.BufferedImage getImage_Bitmask(java.awt.Image image,
                                                            java.awt.Color color)
Parameters:
image
color – masking color

Returns:BufferedImage


splitImages

public static java.awt.image.BufferedImage[] splitImages(java.awt.image.BufferedImage originalImage,
                                                         int column,
                                                         int row)
Parameters:
originalImage
column
row

Returns:BufferedImage[]


rotateImage

public static java.awt.image.BufferedImage rotateImage(java.awt.image.BufferedImage originalImage,
                                                       int angle)
Parameters:
originalImage
angle

Returns:BufferedImage


flipImage_Horizontally

public static java.awt.image.BufferedImage flipImage_Horizontally(java.awt.image.BufferedImage originalImage)
Parameters:
originalImage

Returns:BufferedImage


flipImage_Vertically

public static java.awt.image.BufferedImage flipImage_Vertically(java.awt.image.BufferedImage originalImage)
Parameters:
originalImage

Returns:BufferedImage


getByteA

public byte[] getByteA()
Returns:
byte[]

setByteA

public void setByteA(byte[] byteA)
Parameters:
byteA

setByteA

public void setByteA(java.io.File file)
Parameters:
file
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: