Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.hipergate
Class Image

    java.lang.Object
      com.knowgate.dataobjs.DBPersist
          com.knowgate.hipergate.Image

All Implemented Interfaces:
  java.io.Serializable, java.util.Map

    public class Image

extends DBPersist

Simple imaging transformations

See Also:
  `Image`, Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary
`static short` | `ClassId`
`static int` | `USE_AWT`
`static int` | `USE_JAI`

Fields inherited from class com.knowgate.dataobjs.DBPersist
`AllVals, sAuditCls, sAuditUsr, sTransactId`

Constructor Summary
`Image()` Create empty image, use AWT imaging routines.
`Image(java.awt.Image oAWTImage, java.lang.String sImagePath, int iLibrary)` Load Image directly from a Java AWT abstract Image
`Image(int iLibraryCode)` Create empty image.
`Image(JDCConnection oConn, java.io.File oFile, java.lang.String sFilePath)` Load Image properties from database using file path as key.
`Image(JDCConnection oConn, java.lang.String sImageId)` Load image properties from database.

Method Summary
`static byte[]` | `blankGIF()` Get a transparent GIF image that can be served throught a JSP page Use code like response.setContentType("image/gif"); OutputStream oOut = response.getOutputStream(); oOut.write(Image.blankGIF()); oOut.flush();
`byte[]` | `createThumbBitmap(int iThumbWidth, int iThumbHeight, float fQuality)` Resample image.
`void` | `createThumbFile(java.lang.String sOutputPath, int iThumbWidth, int iThumbHeight, float fQuality)` Resample image.
`boolean` | `delete(JDCConnection oConn)` Delete Image from database and from disk.
`boolean` | `dimensions()` Get image dimensions.
`java.lang.String` | `getImageCodec()`
`java.lang.String` | `getImageType()` Get image file extension in lowercase.
`int` | `getImagingLibrary()` Get active imaging library.
`static void` | `main(java.lang.String[] argv)` Image command line interface
`void` | `setImagingLibrary(int iLibraryCode)` Set imaging library to use.
`boolean` | `store(JDCConnection oConn)` Store image properties at database.
`void` | `write(java.io.OutputStream oOut)` Encode Image and write it to an OutputStream

Methods inherited from class com.knowgate.dataobjs.DBPersist
`allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, size, toLowerCase, toUpperCase, toXML, toXML, toXML, toXML, values`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode`

Field Detail

### USE_AWT

    public static final int USE_AWT

See Also:
  Constant Field Values

### USE_JAI

    public static final int USE_JAI

See Also:
  Constant Field Values

### ClassId

    public static final short ClassId

See Also:
  Constant Field Values

Constructor Detail

### Image

    public Image()

  Create empty image, use AWT imaging routines.

### Image

    public Image(int iLibraryCode)
          throws java.lang.IllegalArgumentException

  Create empty image.

  Parameters:
    `iLibraryCode` - Imaging library to use. Either USE_AWT or USE_JAI.
  Throws:
    `java.lang.IllegalArgumentException`

### Image

    public Image(JDCConnection oConn,
                 java.lang.String sImageId)
          throws java.sql.SQLException

  Load image properties from database.

  Parameters:
    `oConn` - Database Connection.
    `sImageId` - Image GUID at k_images table.
  Throws:
    `java.sql.SQLException`

### Image

    public Image(java.awt.Image oAWTImage,
                 java.lang.String sImagePath,
                 int iLibrary)

  Load Image directly from a Java AWT abstract Image

  Parameters:
    `oAWTImage` - java.awt.Image object
    `sImagePath` - Optional. Path to image file name.
    `iLibraryCode` - Imaging library to use. Either USE_AWT or USE_JAI.

### Image

    public Image(JDCConnection oConn,
                 java.io.File oFile,
                 java.lang.String sFilePath)
          throws java.sql.SQLException

  Load Image properties from database using file path as key.

  This method searched a file path into field path_image from k_images table.

  Parameters:
    `oConn` - Database Connection
    `oFile` - Image File Object
    `sFilePath` - Full path to Image File (as stored at k_images.path_image)
  Throws:
    `java.sql.SQLException`

Method Detail

### setImagingLibrary

    public void setImagingLibrary(int iLibraryCode)

  Set imaging library to use.

  On many systems it is neccesary to have X-Windows started for being able to use AWT imaging routines.

  Parameters:
    `iLibraryCode` - USE_AWT or USE_JAI
  See Also:
    `http://java.sun.com/products/java-media/jai/`, `http://java.sun.com/j2se/1.4.2/docs/api/`

### getImagingLibrary

    public int getImagingLibrary()

  Get active imaging library.

  Returns:
    USE_AWT or USE_JAI

### store

    public boolean store(JDCConnection oConn)
                  throws java.sql.SQLException,
                         java.lang.UnsatisfiedLinkError,
                         java.lang.NoClassDefFoundError

  Store image properties at database.

  The image itself is kept as a disk file pointe by path_file field.
  On saving the Image a GUID is automatically assigned if one is not provided.
  Image file length, width and height are saved to len_file, dm_width and dm_height fields.
  Only GIF 89a and JPG/JPEG images are recognized for automatic dimensions computation.

  Overrides:
    `store` in class `DBPersist`
  Parameters:
    `oConn` - Database Connection
  Returns:
    boolean true if register was stored for the first time, false if register already existed.
  Throws:
    `java.sql.SQLException`
    `java.lang.NoClassDefFoundError`
    `java.lang.UnsatisfiedLinkError` - hen JAI native libraries (*_jai.so) are not installed Sun JAI tries to use AWT which is slower but more compatible. Some libraries of AWT are requiered. Particularly from Fedora Core 2:
    xorg-x11-devel (contains libXp.so, requiered by libawt.so), fontconfig, fontconfig-devel, xorg-x11-libs, xorg-x11-libs-data, xorg-x11-Mesa-libGL

### delete

    public boolean delete(JDCConnection oConn)
                   throws java.sql.SQLException

  Delete Image from database and from disk.

  Overrides:
    `delete` in class `DBPersist`
  Parameters:
    `oConn` - Database Connection
  Returns:
    true if register was successfully erased, false if not.
  Throws:
    `java.sql.SQLException`

### getImageType

    public java.lang.String getImageType()

  Get image file extension in lowercase.

### getImageCodec

    public java.lang.String getImageCodec()

### dimensions

    public boolean dimensions()
                       throws java.io.IOException,
                              java.io.FileNotFoundException,
                              java.lang.ArrayIndexOutOfBoundsException,
                              java.lang.UnsatisfiedLinkError,
                              java.lang.NullPointerException

  Get image dimensions.

  Dimensions are stored at dm_width and dm_height properties.
  Only GIF 89a and JPG/JPEG images are supported

  Returns:
    true if dimensions where successfully computed, false if routine was unable to recognize file format.
  Throws:
    `java.io.IOException`
    `java.io.FileNotFoundException`
    `java.lang.ArrayIndexOutOfBoundsException`
    `java.lang.NullPointerException`
    `java.lang.UnsatisfiedLinkError` - When JAI native libraries (*_jai.so) are not installed Sun JAI tries to use AWT which is slower but more compatible. Some libraries of AWT are requiered. Particularly from Fedora Core 2:
    xorg-x11-devel (contains libXp.so, requiered by libawt.so), fontconfig, fontconfig-devel, xorg-x11-libs, xorg-x11-libs-data, xorg-x11-Mesa-libGL

### createThumbBitmap

    public byte[] createThumbBitmap(int iThumbWidth,
                                    int iThumbHeight,
                                    float fQuality)
                             throws java.lang.NullPointerException,
                                    java.io.IOException,
                                    java.lang.InterruptedException,
                                    java.lang.InstantiationException

  Resample image.

  Parameters:
    `iThumbWidth` - Desired width
    `iThumbHeight` - Desired height
    `fQuality` - JPG Quality [1..100]
  Returns:
    Byte array holding the generated JPEG image
  Throws:
    `java.lang.NullPointerException`
    `java.io.IOException`
    `java.lang.InterruptedException`
    `java.lang.InstantiationException`

### createThumbFile

    public void createThumbFile(java.lang.String sOutputPath,
                                int iThumbWidth,
                                int iThumbHeight,
                                float fQuality)
                         throws java.lang.NullPointerException,
                                java.lang.InterruptedException,
                                java.io.IOException,
                                java.lang.InstantiationException

  Resample image.

  Parameters:
    `sOutputPath` - File path where generated JPEG shall be saved.
    `iThumbWidth` - Desired width
    `iThumbHeight` - Desired height
    `fQuality` - JPG Quality [1..100]
  Throws:
    `java.lang.NullPointerException`
    `java.io.IOException`
    `java.lang.InstantiationException`
    `java.lang.InterruptedException`
    `java.lang.InstantiationException`

### write

    public void write(java.io.OutputStream oOut)
               throws java.lang.NullPointerException,
                      java.io.IOException,
                      java.lang.InstantiationException,
                      java.lang.InterruptedException

  Encode Image and write it to an OutputStream

  Parameters:
    `oOut` - OutputStream
  Throws:
    `java.lang.NullPointerException` - If underlying java.awt.Image object is null
    `java.io.IOException`
    `java.lang.InstantiationException`
    `java.lang.InterruptedException`

### blankGIF

    public static byte[] blankGIF()

  Get a transparent GIF image that can be served throught a JSP page

  Use code like response.setContentType("image/gif"); OutputStream oOut = response.getOutputStream(); oOut.write(Image.blankGIF()); oOut.flush();

  Returns:
    byte[]
  Since:
    3.0

### main

    public static void main(java.lang.String[] argv)
                     throws java.lang.NumberFormatException,
                            java.lang.InstantiationException,
                            java.lang.InterruptedException,
                            java.io.FileNotFoundException,
                            java.io.IOException

  Image command line interface

  Parameters:
    `argv` - [jai|awt] thumbnail path_original path_new_thumbnail int_thumb_width int_thumb_height float_quality
    Options:
    jai -> Use SUN Java Advanced Imaging (requires SUN's libraries
    awt -> Use Abstract Windowing Toolkit (requires X-Windows or Win32)
    path_original -> Full path to original .GIF or .JPEG image
    path_new_thumbnail -> Full path to generated thumbnail
    int_thumb_width -> Thumbnail width"); int_thumb_height -> Thumbnail height
    float_quality -> JPEG quality for thumbnail [0..100]
  Throws:
    `java.lang.NumberFormatException`
    `java.lang.InstantiationException`
    `java.lang.InterruptedException`
    `java.io.FileNotFoundException`
    `java.io.IOException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD