org.cruxframework.crux.core.client.image
Class ImageProcessor

java.lang.Object
  extended by org.cruxframework.crux.core.client.image.ImageProcessor

public class ImageProcessor
extends Object

An Image processor

Author:
Thiago da Rosa de Bustamante

Nested Class Summary
static interface ImageProcessor.ImageCreateAndLoadHandler
           
static interface ImageProcessor.ImageLoadHandler
           
 
Constructor Summary
protected ImageProcessor()
          Constructor
 
Method Summary
 Blob asGif()
          Export content image as a GIF file.
 Blob asJpeg(double quality)
          Export content image as a JPEG file.
 Blob asPng()
          Export content image as a PNG file.
static ImageProcessor createIfSupported()
          If the current browser supports, create a new ImageProcessor
static void createIfSupportedAndLoadImage(Blob image, ImageProcessor.ImageCreateAndLoadHandler handler)
          Create ImageProcessor instance and automatically loads the image.
static void createIfSupportedAndLoadImage(String url, ImageProcessor.ImageCreateAndLoadHandler handler)
          Create ImageProcessor instance and automatically loads the image.
 void ensureMaxSize(int maxHeight, int maxWidth, boolean keepProportions)
          Ensure a max size for the image
static boolean isSupported()
          Check if browser supports this feature
 void loadImage(Blob image, ImageProcessor.ImageLoadHandler handler)
          Loads an image to the processor.
 void loadImage(String url, ImageProcessor.ImageLoadHandler handler)
          Loads an image to the processor.
 void resize(int width, int height)
          Resize the internal image
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageProcessor

protected ImageProcessor()
Constructor

Method Detail

createIfSupportedAndLoadImage

public static void createIfSupportedAndLoadImage(Blob image,
                                                 ImageProcessor.ImageCreateAndLoadHandler handler)
Create ImageProcessor instance and automatically loads the image.

Parameters:
file - Image File
handler - Called whem image is completely loaded

createIfSupportedAndLoadImage

public static void createIfSupportedAndLoadImage(String url,
                                                 ImageProcessor.ImageCreateAndLoadHandler handler)
Create ImageProcessor instance and automatically loads the image.

Parameters:
url - Image URL
handler - Called whem image is completely loaded

loadImage

public void loadImage(String url,
                      ImageProcessor.ImageLoadHandler handler)
Loads an image to the processor.

Parameters:
url - Image URL
handler - Called whem image is completely loaded

loadImage

public void loadImage(Blob image,
                      ImageProcessor.ImageLoadHandler handler)
Loads an image to the processor.

Parameters:
file - Image File
handler - Called whem image is completely loaded

ensureMaxSize

public void ensureMaxSize(int maxHeight,
                          int maxWidth,
                          boolean keepProportions)
Ensure a max size for the image

Parameters:
maxHeight -
maxWidth -
keepProportions -

resize

public void resize(int width,
                   int height)
Resize the internal image

Parameters:
width -
height -

asJpeg

public Blob asJpeg(double quality)
Export content image as a JPEG file.

Parameters:
quality - JPEG quality. It ranges from 0.0 to 1.0
Returns:

asPng

public Blob asPng()
Export content image as a PNG file.

Returns:

asGif

public Blob asGif()
Export content image as a GIF file.

Returns:

isSupported

public static boolean isSupported()
Check if browser supports this feature

Returns:

createIfSupported

public static ImageProcessor createIfSupported()
If the current browser supports, create a new ImageProcessor

Returns:


Copyright © 2014. All rights reserved.