it.geosolutions.imageio.plugins.nitronitf
Class ImageIOUtils

java.lang.Object
  extended by it.geosolutions.imageio.plugins.nitronitf.ImageIOUtils

public class ImageIOUtils
extends Object


Method Summary
static boolean canDisplay(BufferedImage image)
           
static void centerWindow(Window w)
           
static ColorModel createGrayscaleColorModel(boolean invert)
           
static void doubleToByteBuffer(double[] doubleData, byte[] byteData, int pixelStride, int numBands)
          Converts the float data to byte data, and sets the values in the byteData buffer
static double[] findMinAndMax(double[] buffer, int pixelStride, int numBands)
           
static float[] findMinAndMax(float[] buffer, int pixelStride, int numBands)
           
static int[] findMinAndMax(short[] buffer, int pixelStride, int numBands)
           
static void floatToByteBuffer(float[] floatData, byte[] byteData, int pixelStride, int numBands)
          Converts the float data to byte data, and sets the values in the byteData buffer
static List<File> getFiles(String[] filesOrDirs, String[] extensions)
          Returns a list of Files contained in the given String array of files or directories.
static ImageReader getImageReader(File file)
          Returns an ImageReader given the input file
static ImageReader getImageReader(String filename)
          Returns an ImageReader given the input filename
static ImageReader getImageReader(String format, Object input)
          Returns an ImageReader given the format, and sets the input source
static ImageWriter getImageWriter(File file)
          Returns an ImageWriter given the input file
static ImageWriter getImageWriter(String filename)
          Returns an ImageWriter given the output filename
static String getPackageName(Class clazz)
           
static void main(String[] args)
           
static WritableRaster makeGenericBandedWritableRaster(int numElems, int numLines, int numBands, int dataType)
          Returns a generic banded WritableRaster
static WritableRaster makeGenericPixelInterleavedWritableRaster(int numElems, int numLines, int numBands, int dataType)
          Returns a generic pixel interleaved WritableRaster
static int makeUnsigned(byte b)
          Turns a signed byte into an unsigned one.
static BufferedImage rasterToBufferedImage(Raster raster, ImageTypeSpecifier imageType)
          Utility method for creating a BufferedImage from a source raster Currently only Float->Byte and Byte->Byte are supported.
static void shortToByteBuffer(short[] shortData, byte[] byteData, int pixelStride, int numBands)
          Converts the float data to byte data, and sets the values in the byteData buffer
static JFrame showImage(BufferedImage image, String title)
           
static JFrame showImage(BufferedImage image, String title, boolean fitToScreen)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImageReader

public static ImageReader getImageReader(String filename)
                                  throws IOException
Returns an ImageReader given the input filename

Parameters:
filename -
Returns:
Throws:
IOException

getImageReader

public static ImageReader getImageReader(File file)
                                  throws IOException
Returns an ImageReader given the input file

Parameters:
file -
Returns:
Throws:
IOException

getImageReader

public static ImageReader getImageReader(String format,
                                         Object input)
                                  throws IOException
Returns an ImageReader given the format, and sets the input source

Parameters:
file -
Returns:
Throws:
IOException

getImageWriter

public static ImageWriter getImageWriter(String filename)
                                  throws IOException
Returns an ImageWriter given the output filename

Parameters:
filename -
Returns:
Throws:
IOException

getImageWriter

public static ImageWriter getImageWriter(File file)
                                  throws IOException
Returns an ImageWriter given the input file

Parameters:
file -
Returns:
Throws:
IOException

getPackageName

public static String getPackageName(Class clazz)

canDisplay

public static boolean canDisplay(BufferedImage image)

getFiles

public static List<File> getFiles(String[] filesOrDirs,
                                  String[] extensions)
Returns a list of Files contained in the given String array of files or directories. If one of the array contents is a directory, it searches it. Files ending in the extensions provided are returned in the list.

Parameters:
filesOrDirs -
extensions -
Returns:

showImage

public static JFrame showImage(BufferedImage image,
                               String title)

showImage

public static JFrame showImage(BufferedImage image,
                               String title,
                               boolean fitToScreen)

centerWindow

public static void centerWindow(Window w)

createGrayscaleColorModel

public static ColorModel createGrayscaleColorModel(boolean invert)

findMinAndMax

public static float[] findMinAndMax(float[] buffer,
                                    int pixelStride,
                                    int numBands)

findMinAndMax

public static double[] findMinAndMax(double[] buffer,
                                     int pixelStride,
                                     int numBands)

findMinAndMax

public static int[] findMinAndMax(short[] buffer,
                                  int pixelStride,
                                  int numBands)

makeGenericBandedWritableRaster

public static WritableRaster makeGenericBandedWritableRaster(int numElems,
                                                             int numLines,
                                                             int numBands,
                                                             int dataType)
Returns a generic banded WritableRaster

Parameters:
numElems -
numLines -
bandOffsets -
dataType -
Returns:

makeGenericPixelInterleavedWritableRaster

public static WritableRaster makeGenericPixelInterleavedWritableRaster(int numElems,
                                                                       int numLines,
                                                                       int numBands,
                                                                       int dataType)
Returns a generic pixel interleaved WritableRaster

Parameters:
numElems -
numLines -
bandOffsets -
dataType -
Returns:

floatToByteBuffer

public static void floatToByteBuffer(float[] floatData,
                                     byte[] byteData,
                                     int pixelStride,
                                     int numBands)
Converts the float data to byte data, and sets the values in the byteData buffer

Parameters:
floatData -
byteData -

doubleToByteBuffer

public static void doubleToByteBuffer(double[] doubleData,
                                      byte[] byteData,
                                      int pixelStride,
                                      int numBands)
Converts the float data to byte data, and sets the values in the byteData buffer

Parameters:
doubleData -
byteData -

shortToByteBuffer

public static void shortToByteBuffer(short[] shortData,
                                     byte[] byteData,
                                     int pixelStride,
                                     int numBands)
Converts the float data to byte data, and sets the values in the byteData buffer

Parameters:
shortData -
byteData -

rasterToBufferedImage

public static BufferedImage rasterToBufferedImage(Raster raster,
                                                  ImageTypeSpecifier imageType)
Utility method for creating a BufferedImage from a source raster Currently only Float->Byte and Byte->Byte are supported. Will throw an UnsupportedOperationException if the conversion is not supported.

Parameters:
raster -
imageType -
Returns:

makeUnsigned

public static int makeUnsigned(byte b)
Turns a signed byte into an unsigned one.

Parameters:
b - The byte to read
Returns:
An unsigned integer

main

public static void main(String[] args)


Copyright © 2006–2013 GeoSolutions. All rights reserved.