|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.image.ImageUtils
public class ImageUtils
implements several useful image-related functions
| Nested Class Summary | |
|---|---|
static class |
ImageUtils.Axis
|
| Method Summary | |
|---|---|
static String |
asHexString(Color c)
|
static BufferedImage |
captureComponent(Component c)
|
static BufferedImage |
centerImageOnImage(Image foreground,
Image background)
the returned Image is as large as needed to fully show both, foreground and background |
static BufferedImage |
centerTextOnImage(Image background,
String text,
Font font,
Paint paint,
boolean antiAlias)
the image is exactly as big as the background; if the text is larger, it is cut off |
static BufferedImage |
convertCMYK2RGB(Image img)
very useful when writing jpeg images |
static void |
copyToClipboard(Image image)
|
static Image |
createGreyscale(Image image)
|
static ImageIcon |
createIcon(String chars)
uses the default label font and a standard icon dimension of 16x16; useful for a single character |
static ImageIcon |
createIcon(String chars,
Font font,
Dimension dim)
|
static BufferedImage |
createImage(Component c)
|
static BufferedImage |
createImage(Component c,
int width,
int height)
|
static Image |
createImage(Icon icon)
|
static ImageIcon |
createImageIcon(Icon icon)
|
static Image |
createNegative(Image image)
|
static byte[] |
createThumbnail(Image image,
int maxSize,
float quality)
convenience method to create thumbnail |
static Image |
createTransparentImage(Image image,
Color transparentColor)
|
static Image |
crop(Image image,
RectangularShape rect)
|
static BufferedImage |
deserialize(byte[] imageData)
|
static Iterator<BufferedImage> |
extractFrames(InputStream animatedGifStream)
|
static BufferedImage |
extractImage(URL url)
makes a thorough attempt to extract an image from the given location. |
static Image |
filterImage(Image image,
ImageFilter filter)
|
static AffineTransform |
findUpperLeftTranslation(AffineTransform at,
Image image)
checks the four corners of the image and returns an AffineTransform that makes sure that the upper-left corner of the image is painted at the coordintates (0/0). |
static BufferedImage |
flip(Image image,
ImageUtils.Axis axis)
|
static BufferedImage |
generateBarcodeImage(String code,
String type,
boolean showLabel)
|
static BufferedImage |
generateBarcodeImage(String code,
String type,
int dpi,
boolean showLabel)
if type is null, Code128 is assumed. |
static BufferedImage |
generateTextImage(String text)
generates an image based on the given text. |
static BufferedImage |
generateTextImage(String text,
Font font,
Paint textColor,
Paint backgroundColor,
boolean antiAlias)
generates an image based on the given text. |
static BufferedImage |
generateTransparentImage(int width,
int height)
|
static Color |
getColorByName(String color)
first, this method looks for a field name (such as 'green') to derive the color, then it calls Color.decode(String). |
static String |
getImageFormat(InputStream stream)
|
static Dimension |
getImageSize(InputStream stream)
|
static RGBImageFilter |
getNegativeFilter()
|
static RGBImageFilter |
getTransparentColorFilter(Color color)
makes the given Color transparent; already existing transparency is preserved |
static boolean |
hasAlpha(Image image)
|
static Image |
makeColorTransparent(Image image,
Color c)
|
static Image |
makeTransparent(Image image,
float scaleFactor)
returns a transparent version of the given image |
static BufferedImage |
paintImage(Paint paint,
Dimension d)
|
static Image |
pasteFromClipboard()
returns null if the clipboard content cannot be read into an image |
static BufferedImage |
renderImage(Image image)
allows to convert an Image to a BufferedImage |
static BufferedImage |
rewriteImage(Image image,
int bufferedImageType)
|
static Image |
rotate(Image image,
double degrees)
|
static Image |
scale(Image image,
double factor)
scales the image based on one given factor while preserving its ratio |
static Image |
scaleToFit(Image image,
int size)
scales the image so that it fits into a square of the given size; if the image is smaller than the given boundary, it's returned with a scale of 1 |
static Image |
scaleToFit(Image image,
int size,
int renderHints)
|
static byte[] |
serialize(Image image,
String format)
|
static Image |
transformImage(Image image,
AffineTransform xform)
|
static Image |
transformImage(Image image,
BufferedImageOp bio)
|
static void |
writeJpeg(Image image,
File file,
float quality)
|
static void |
writeJpeg(Image image,
OutputStream out,
float quality)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Color getColorByName(String color)
Color.decode(String).
If both fails, null is returned.
public static String asHexString(Color c)
Color.decode(String)
public static BufferedImage deserialize(byte[] imageData)
throws IOException
IOException
public static byte[] serialize(Image image,
String format)
throws IOException
IOException
public static byte[] createThumbnail(Image image,
int maxSize,
float quality)
throws IOException
IOException
public static void writeJpeg(Image image,
File file,
float quality)
throws IOException
quality - a number between 0 and 1 where 1 is the highest quality
IOException
public static void writeJpeg(Image image,
OutputStream out,
float quality)
throws IOException
quality - a number between 0 and 1 where 1 is the highest quality
IOException
public static BufferedImage convertCMYK2RGB(Image img)
throws IOException
IOException
public static BufferedImage generateBarcodeImage(String code,
String type,
boolean showLabel)
@ThirdParty(value="net.sourceforge.barbecue.BarcodeFactory")
public static BufferedImage generateBarcodeImage(String code,
String type,
int dpi,
boolean showLabel)
throws IllegalArgumentException
Code128 is assumed.
IllegalArgumentExceptionBarcodeFactorypublic static ImageIcon createIcon(String chars)
public static ImageIcon createIcon(String chars,
Font font,
Dimension dim)
public static BufferedImage captureComponent(Component c)
public static ImageIcon createImageIcon(Icon icon)
public static Image createImage(Icon icon)
public static BufferedImage createImage(Component c)
public static BufferedImage createImage(Component c,
int width,
int height)
public static String getImageFormat(InputStream stream)
throws IOException
IOException
public static Dimension getImageSize(InputStream stream)
throws IOException
IOExceptionpublic static Image pasteFromClipboard()
public static void copyToClipboard(Image image)
throws IOException
IOException
public static BufferedImage generateTransparentImage(int width,
int height)
public static BufferedImage generateTextImage(String text)
public static BufferedImage generateTextImage(String text,
Font font,
Paint textColor,
Paint backgroundColor,
boolean antiAlias)
font - may be null (in which case the default font is used)backgroundColor - may be null, in which case the picture would be transparant
public static BufferedImage centerTextOnImage(Image background,
String text,
Font font,
Paint paint,
boolean antiAlias)
public static BufferedImage centerImageOnImage(Image foreground,
Image background)
public static BufferedImage paintImage(Paint paint,
Dimension d)
public static Image scale(Image image,
double factor)
factor - a factor of 1 returns an image of the same size
public static Image scaleToFit(Image image,
int size)
public static Image scaleToFit(Image image,
int size,
int renderHints)
renderHints - example: Image.SCALE_DEFAULT
public static Image crop(Image image,
RectangularShape rect)
public static Image rotate(Image image,
double degrees)
public static BufferedImage flip(Image image,
ImageUtils.Axis axis)
public static Image makeColorTransparent(Image image,
Color c)
public static Image makeTransparent(Image image,
float scaleFactor)
scaleFactor - a number between 0 and 1; 0 means complete transparaency
and 1 means complete opacity.
public static AffineTransform findUpperLeftTranslation(AffineTransform at,
Image image)
public static Image transformImage(Image image,
AffineTransform xform)
public static Image transformImage(Image image,
BufferedImageOp bio)
public static BufferedImage rewriteImage(Image image,
int bufferedImageType)
public static BufferedImage renderImage(Image image)
public static boolean hasAlpha(Image image)
public static Image createGreyscale(Image image)
public static Image filterImage(Image image,
ImageFilter filter)
public static Image createNegative(Image image)
public static Image createTransparentImage(Image image,
Color transparentColor)
public static RGBImageFilter getTransparentColorFilter(Color color)
public static RGBImageFilter getNegativeFilter()
public static Iterator<BufferedImage> extractFrames(InputStream animatedGifStream)
throws IOException
IOException@Todo(value="may not fully load images that are embedded into the html due to the stupid HTMLEditorKit") public static BufferedImage extractImage(URL url)
JEditorPane is employed to create a component for it.
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||