LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view.common
Class LyImageUtils

java.lang.Object
  extended by leon.view.common.LyImageUtils

public class LyImageUtils
extends java.lang.Object

This class gives utility methods to handle images.


Field Summary
static java.lang.String __VERSION
           
static java.awt.Frame _frame
          Default Frame used in some parts of the code when a default AWT component is needed (for example to create an image).
 
Constructor Summary
LyImageUtils()
           
 
Method Summary
static void clean()
          Clean all statics used by this class.
static boolean encodeImage(java.awt.Image image, java.lang.String imageDir, java.lang.String imageFile)
          Encodes an image to JPEG format.
static java.io.OutputStream encodeImageToStream(java.awt.Image image, java.lang.String imageDir, java.lang.String imageFile)
          Encodes an image to JPEG format.
static void freeImage(java.awt.Image image)
          Free the resources of the image if not in the cache.
static java.awt.Image getDefaultImage()
          Constructs a default image.
static java.lang.Object getScaledInstance(java.awt.Image image, int width, int height)
          Creates a scaled version of the given image.
static int[] getSizes(java.awt.Image image)
          Gets images sizes.
static boolean isSameImage(java.awt.Image image1, java.awt.Image image2)
          Compare two images pixel by pixel.
static java.lang.Object loadImageFromStream(java.awt.Component component, java.io.InputStream resource)
          retreives an image from a Stream.
static void waitForLoading(java.awt.Component component, java.awt.Image image)
          Waits for the image loaging.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

_frame

public static java.awt.Frame _frame
Default Frame used in some parts of the code when a default AWT component is needed (for example to create an image).

Constructor Detail

LyImageUtils

public LyImageUtils()
Method Detail

clean

public static void clean()
Clean all statics used by this class.


encodeImage

public static boolean encodeImage(java.awt.Image image,
                                  java.lang.String imageDir,
                                  java.lang.String imageFile)
Encodes an image to JPEG format.

Parameters:
image - the image to encode
imageDir - temporary directory
imageFile - the JPEG File
Returns:
true if the file was generated, false otherwise.

encodeImageToStream

public static java.io.OutputStream encodeImageToStream(java.awt.Image image,
                                                       java.lang.String imageDir,
                                                       java.lang.String imageFile)
Encodes an image to JPEG format.

Parameters:
image - the image to encode
imageDir - temporary directory
imageFile - the JPEG File
Returns:
true if the file was generated, false otherwise.

getDefaultImage

public static java.awt.Image getDefaultImage()
Constructs a default image.

Returns:
the default image

getSizes

public static int[] getSizes(java.awt.Image image)
Gets images sizes.

Parameters:
image -
Returns:
Image size (table with 2 entries).

getScaledInstance

public static java.lang.Object getScaledInstance(java.awt.Image image,
                                                 int width,
                                                 int height)
Creates a scaled version of the given image.

Parameters:
image - The image to scale.
width - The width to which to scale the image.
height - The height to which to scale the image.
Returns:
A scaled version of the image.

waitForLoading

public static void waitForLoading(java.awt.Component component,
                                  java.awt.Image image)
                           throws java.lang.InterruptedException
Waits for the image loaging.

Parameters:
component -
image - Image to load.
Throws:
java.lang.InterruptedException

loadImageFromStream

public static java.lang.Object loadImageFromStream(java.awt.Component component,
                                                   java.io.InputStream resource)
                                            throws java.io.IOException
retreives an image from a Stream.

Parameters:
component - The client of the image creation.
resource - stream inputStream to the image data
Returns:
the image or null if an error occurs
Throws:
java.io.IOException - if something is wrong during loading

freeImage

public static void freeImage(java.awt.Image image)
Free the resources of the image if not in the cache. If the image is in the cache, this method does nothing.

Parameters:
image - The image that must be freed.

isSameImage

public static boolean isSameImage(java.awt.Image image1,
                                  java.awt.Image image2)
                           throws java.lang.InterruptedException
Compare two images pixel by pixel.

Parameters:
image1 - first image to compare
image2 - second image to compare
Returns:
true if images are the same.
Throws:
java.lang.InterruptedException - exception if problems on grabber or loading.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com