es.prodevelop.gvsig.mobile.fmap.driver.raster.ecw
Class EcwReader

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.driver.raster.ecw.EcwReader

public class EcwReader
extends java.lang.Object

Utility class to access Ermapper's libraries through JNI

Author:
jldominguez
See Also:
EcwRasterDriver

Constructor Summary
EcwReader()
           
 
Method Summary
static boolean closeEcwFile(long ptr)
          Closes the ECW file.
static double[] getEcwImageInfo(long ptr)
          Gets metadata from the ECW raster
static int[] getEcwView(long ptr, double geo_min_x, double geo_min_y, double geo_w, double geo_h, double filemingeox, double filemingeoy, double filexcell, double ffileycell, int filew, int fileh, int out_w, int out_h, int band1, int band2, int band3)
          Renders the ECW raster as an array of RGB values (one int value for each pixel)
static byte[] getWhiteImage(int w, int h)
          gets the array of bytes (PNG format) representing a white image of the given size.
static long openEcwFile(java.lang.String full_file_path)
          Opens ECW file
static byte[] paintArray(int[] bitmap, int w, int h, int offset, boolean has_transp)
          Utility method to convert an array of integers into an array of bytes in the PNG format.
static void setCacheInKBytes(int size)
          Sets the cache that Ermapper's DLL is allowed to use.
static int test()
          Test method.
static void touch()
          Utility method to force the load of the associated DLL.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EcwReader

public EcwReader()
Method Detail

openEcwFile

public static long openEcwFile(java.lang.String full_file_path)
                        throws java.lang.Throwable
Opens ECW file

Parameters:
full_file_path - ecw full file path
Returns:
the file handler as an long value, or zero if the file was not opened
Throws:
java.lang.Throwable

closeEcwFile

public static boolean closeEcwFile(long ptr)
Closes the ECW file.

Parameters:
ptr - handler of the previously opened file
Returns:
whether the file was successfully closed

getEcwView

public static int[] getEcwView(long ptr,
                               double geo_min_x,
                               double geo_min_y,
                               double geo_w,
                               double geo_h,
                               double filemingeox,
                               double filemingeoy,
                               double filexcell,
                               double ffileycell,
                               int filew,
                               int fileh,
                               int out_w,
                               int out_h,
                               int band1,
                               int band2,
                               int band3)
Renders the ECW raster as an array of RGB values (one int value for each pixel)

Parameters:
ptr - ECW file handler
geo_min_x - minimum x in map units of the zone of interest
geo_min_y - minimum y in map units of the zone of interest
geo_w - width of the zone of interest in map units
geo_h - height of the zone of interest in map units
filemingeox - minimum x in map units of the raster
filemingeoy - minimum y in map units of the raster
filexcell - width of each pixels in map units
ffileycell - height of each pixels in map units
filew - width of the raster in pixels
fileh - height of the raster in pixels
out_w - width of the output image in pixels
out_h - height of the output image in pixels
band1 - first band requested
band2 - second band requested
band3 - third band requested
Returns:
array of integers representing the zone of interest

getEcwImageInfo

public static double[] getEcwImageInfo(long ptr)
Gets metadata from the ECW raster

Parameters:
ptr - the file handler
Returns:
array of doubles with the raster metadata

paintArray

public static byte[] paintArray(int[] bitmap,
                                int w,
                                int h,
                                int offset,
                                boolean has_transp)
Utility method to convert an array of integers into an array of bytes in the PNG format.

Parameters:
bitmap - raster as an array of integers
w - image width in pixels
h - image height in pixels
offset - offset in the array of integers
has_transp - whether the integers include an alpha band
Returns:
an array of bytes in the PNG format.

test

public static int test()
Test method.

Returns:
an irrelevant value

setCacheInKBytes

public static void setCacheInKBytes(int size)
Sets the cache that Ermapper's DLL is allowed to use. It must be set to zero to avoid memory leaks.

Parameters:
size - cache limits in kilobytes

getWhiteImage

public static byte[] getWhiteImage(int w,
                                   int h)
gets the array of bytes (PNG format) representing a white image of the given size.

Parameters:
w - image width
h - image height
Returns:
an array of bytes (PNG format) representing a white image

touch

public static void touch()
Utility method to force the load of the associated DLL.