DESY ACOP Beans Home

de.desy.acop.video.displayer.timage
Class TImageUtils

java.lang.Object
  extended by de.desy.acop.video.displayer.timage.TImageUtils

public class TImageUtils
extends java.lang.Object


Constructor Summary
TImageUtils()
           
 
Method Summary
static java.awt.image.BufferedImage addInsets(java.awt.image.BufferedImage src, java.awt.Insets insets, java.awt.Paint paint)
          Add the insets to the image and fill span between image and new borders.
static java.awt.image.BufferedImage bitmapToImage(byte[] data, java.lang.String format)
          Convert a bitmap to an Image object
static de.desy.tine.types.IMAGE clone(de.desy.tine.types.IMAGE timage)
          Deprecated. mdavid: use IMAGE.clone() instead
static boolean compare(de.desy.tine.types.IMAGE cTImage, de.desy.tine.types.IMAGE jTImage)
           
static java.awt.image.BufferedImage convertGrayByteToRGB(java.awt.image.BufferedImage image)
          Convert 8 bit gray BufferedImage to RGB BufferedImage.
static java.awt.image.BufferedImage convertGrayShortToGrayByte(java.awt.image.BufferedImage image)
          Convert 16 bit gray BufferedImage to 8 bit gray BufferedImage.
static java.awt.image.BufferedImage convertGrayShortToRGB(java.awt.image.BufferedImage srcImage)
          Convert 16 bit gray BufferedImage to RGB BufferedImage.
static java.awt.image.BufferedImage convertToGrayscale(java.awt.image.BufferedImage source)
           
static java.awt.image.BufferedImage convertToGrayscale2(java.awt.image.BufferedImage colorImage)
           
static java.awt.Image convertToGrayscale3(java.awt.image.BufferedImage colorImage)
           
static byte[] getImageByteArray(java.awt.image.BufferedImage image)
          Get a byte array associated with input buffered image.
static java.awt.Image getImageFromArray(int[] pixels, int width, int height, int type)
          Creates an Image from array using raster.
static int[] getImageIntArray(java.awt.image.BufferedImage image)
          Get a integer array associated with input buffered image.
static byte[] imageToBitmap(java.awt.image.BufferedImage image, float resolution, java.lang.String format)
          Create an PNG image bitmap.
static java.lang.String padString(java.lang.String s, int n, char c, boolean padLeft)
          Pad a string S with a size of N with char C on the left(True) or on the right(False)
static java.awt.image.BufferedImage scale(java.awt.image.BufferedImage src, int dstWidth, int dstHeight, boolean keepRatio)
           
static de.desy.tine.types.IMAGE setFrameHeader(de.desy.tine.types.IMAGE timage, de.desy.tine.types.IMAGE.FrameHeader fraHeader)
          TODO: should be replaced/changed into IMAGE.FrameHeader class
static de.desy.tine.types.IMAGE setSourceHeader(de.desy.tine.types.IMAGE timage, de.desy.tine.types.IMAGE.SourceHeader srcHeader)
          TODO: should be replaced/changed into IMAGE.FrameHeader class
static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
          Convenient static method to convert Image instances to BufferedImage instances.
static java.awt.image.BufferedImage toColoredBufferedImage(java.awt.image.BufferedImage srcImage)
          Converts image into colored buffered image.
static java.awt.image.BufferedImage toIndexedBufferedImage(java.awt.image.BufferedImage srcImage, java.awt.image.ColorModel icm)
          Converts grayscale image into paletted (indexed) buffered image.
static byte[] toRawBytes(java.awt.image.RenderedImage rimage, java.lang.String formatName)
          Writes an image using an arbitrary ImageWriter that supports the given format to a newly allocated byte array.
static de.desy.tine.types.IMAGE uncompressImage(de.desy.tine.types.IMAGE timage)
          Uncompresses the TINE image data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TImageUtils

public TImageUtils()
Method Detail

toBufferedImage

public static final java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
Convenient static method to convert Image instances to BufferedImage instances.

If the specified image is already instance of BufferedImage then it's returned without processing.

Parameters:
image - - image to convert if it's necessary
Returns:
instance of BufferedImage or null if Image loading process is failed
Throws:
java.lang.NullPointerException - image is null

addInsets

public static final java.awt.image.BufferedImage addInsets(java.awt.image.BufferedImage src,
                                                           java.awt.Insets insets,
                                                           java.awt.Paint paint)
Add the insets to the image and fill span between image and new borders.

Parameters:
src - - image to inset
insets - - instance of Insets class
paint - - to fill the span
Returns:
BufferedImage instance with added insets.
Throws:
java.lang.NullPointerException -
  1. If src is null
  2. If insets is null

scale

public static final java.awt.image.BufferedImage scale(java.awt.image.BufferedImage src,
                                                       int dstWidth,
                                                       int dstHeight,
                                                       boolean keepRatio)
Parameters:
src - - image to scale
dstWidth - - width which source image should be minimized to (the result image can have less width if 'keepRatio' parameter set to true)
dstHeight - - height which source image should be minimized to (the result image can have less height if 'keepRatio' parameter set to true)
keepRatio - -resize image proportionally
Returns:
new scaled instance of BufferedImage
Throws:
java.lang.NullPointerException - If src is null
java.lang.IllegalArgumentException -
  1. If dstWidth < 1
  2. If dstHeight < 1

toRawBytes

public static byte[] toRawBytes(java.awt.image.RenderedImage rimage,
                                java.lang.String formatName)
                         throws java.io.IOException
Writes an image using an arbitrary ImageWriter that supports the given format to a newly allocated byte array.

Parameters:
rimage - - a RenderedImage to be written.
formatName - - a String contain the informal name of the format.
Returns:
a newly allocated byte array
Throws:
java.io.IOException - if an error occurs during writing.

getImageFromArray

public static java.awt.Image getImageFromArray(int[] pixels,
                                               int width,
                                               int height,
                                               int type)
Creates an Image from array using raster.

Parameters:
pixels - - The input int pixel array.
width - - Width of the pixel rectangle.
height - - Height of the pixel rectangle.
type - - type of the created image
Returns:
Image

getImageByteArray

public static byte[] getImageByteArray(java.awt.image.BufferedImage image)
Get a byte array associated with input buffered image.

Parameters:
image - - input buffered image
Returns:
byte-array

getImageIntArray

public static int[] getImageIntArray(java.awt.image.BufferedImage image)
Get a integer array associated with input buffered image.

Parameters:
image - - input buffered image
Returns:
int-array

imageToBitmap

public static byte[] imageToBitmap(java.awt.image.BufferedImage image,
                                   float resolution,
                                   java.lang.String format)
                            throws java.io.IOException
Create an PNG image bitmap.

Parameters:
image - The image to render.
resolution - The DPI of the image.
format - The format to convert to.
Returns:
A file image of the bitmap.
Throws:
java.io.IOException

bitmapToImage

public static java.awt.image.BufferedImage bitmapToImage(byte[] data,
                                                         java.lang.String format)
                                                  throws java.io.IOException
Convert a bitmap to an Image object

Parameters:
data - The bitmap file.
format - The format the data is in.
Returns:
The Image of this data.
Throws:
java.io.IOException - thrown if a problem reading the data or the format is wrong.

convertToGrayscale

public static java.awt.image.BufferedImage convertToGrayscale(java.awt.image.BufferedImage source)

convertToGrayscale2

public static java.awt.image.BufferedImage convertToGrayscale2(java.awt.image.BufferedImage colorImage)

convertToGrayscale3

public static java.awt.Image convertToGrayscale3(java.awt.image.BufferedImage colorImage)

uncompressImage

public static de.desy.tine.types.IMAGE uncompressImage(de.desy.tine.types.IMAGE timage)
Uncompresses the TINE image data.

Parameters:
timage - - input TINE IMAGE
Returns:
- uncompressed TINE IMAGE

clone

public static final de.desy.tine.types.IMAGE clone(de.desy.tine.types.IMAGE timage)
Deprecated. mdavid: use IMAGE.clone() instead

Creates and returns a copy of TINE image.

Returns:
a copy of a timage TINE image.

setFrameHeader

public static final de.desy.tine.types.IMAGE setFrameHeader(de.desy.tine.types.IMAGE timage,
                                                            de.desy.tine.types.IMAGE.FrameHeader fraHeader)
TODO: should be replaced/changed into IMAGE.FrameHeader class


setSourceHeader

public static final de.desy.tine.types.IMAGE setSourceHeader(de.desy.tine.types.IMAGE timage,
                                                             de.desy.tine.types.IMAGE.SourceHeader srcHeader)
TODO: should be replaced/changed into IMAGE.FrameHeader class


padString

public static java.lang.String padString(java.lang.String s,
                                         int n,
                                         char c,
                                         boolean padLeft)
Pad a string S with a size of N with char C on the left(True) or on the right(False)


compare

public static boolean compare(de.desy.tine.types.IMAGE cTImage,
                              de.desy.tine.types.IMAGE jTImage)

convertGrayByteToRGB

public static java.awt.image.BufferedImage convertGrayByteToRGB(java.awt.image.BufferedImage image)
Convert 8 bit gray BufferedImage to RGB BufferedImage.

Parameters:
image - - source 8 bit gray BufferedImage
Returns:
RGB BufferedImage

convertGrayShortToRGB

public static java.awt.image.BufferedImage convertGrayShortToRGB(java.awt.image.BufferedImage srcImage)
Convert 16 bit gray BufferedImage to RGB BufferedImage.

Parameters:
srcImage - - source 16 bit gray BufferedImage
Returns:
RGB BufferedImage

convertGrayShortToGrayByte

public static java.awt.image.BufferedImage convertGrayShortToGrayByte(java.awt.image.BufferedImage image)
Convert 16 bit gray BufferedImage to 8 bit gray BufferedImage.

Parameters:
image - - source 16 bit gray BufferedImage
Returns:
RGB BufferedImage

toIndexedBufferedImage

public static java.awt.image.BufferedImage toIndexedBufferedImage(java.awt.image.BufferedImage srcImage,
                                                                  java.awt.image.ColorModel icm)
Converts grayscale image into paletted (indexed) buffered image.

Parameters:
srcImage - - grayscale buffered image
icm - - indexed color model
Returns:
- paletted buffered image

toColoredBufferedImage

public static java.awt.image.BufferedImage toColoredBufferedImage(java.awt.image.BufferedImage srcImage)
Converts image into colored buffered image.

Parameters:
srcImage - - buffered image
Returns:
- colored buffered image


Copyright © 2010. All Rights Reserved.