GiciFile
Class SaveFile

java.lang.Object
  extended by GiciFile.SaveFile

public class SaveFile
extends java.lang.Object

This class receives a 3D array and saves in any JAI format or raw data.

Version:
1.02
Author:
Group on Interactive Coding of Images (GICI)

Constructor Summary
SaveFile()
           
 
Method Summary
static int getFormat(java.lang.String imageFile)
          Gets the extension, if any, of the image to be saved.
static void SaveFileByExtension(float[][][] imageSamples, java.lang.String imageFile, int[] imageGeometry)
          Saves image samples in the format given by the extension.
static void SaveFileByExtensionAndName(float[][][] imageSamples, java.lang.String imageFile, int[] imageGeometry, java.lang.String outputImagefile)
          Saves image samples in the format given by the extension.
static void SaveFileExtension(float[][][] imageSamples, int[] QComponentsBits, java.lang.String imageFile, int[] imageGeometry)
          This functions saves the image samples to an image file with the format specified by its extension.
static void SaveFileFormat(float[][][] imageSamples, java.lang.String imageFile, int format)
          Saves image samples using specified format using JAI.
static void SaveFileRaw(float[][][] imageSamples, java.lang.String imageFile, int sampleType, int byteOrder)
          Saves image samples in raw data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaveFile

public SaveFile()
Method Detail

SaveFileFormat

public static void SaveFileFormat(float[][][] imageSamples,
                                  java.lang.String imageFile,
                                  int format)
                           throws WarningException
Saves image samples using specified format using JAI. This function uses byte type to save image (because is the only allowed by JAI libraries) and it can manage only images with 1 or 3 components. File extension is added automatically depending on the format.

Parameters:
imageSamples - a 3D float array that contains image samples
imageFile - file name where raw data will be stored
format - format type to save image. The value indicates the following:
  • 0- PNM (pgm or ppm)
  • 1- TIFF
  • 2- PNG
  • 3- JPEG (not recommended because it degenerates image)
  • 4- BMP (not recommended because it is not standard)
Throws:
WarningException - when the file cannot be saved (incorrect number of components, file format unrecognized, etc.)

SaveFileRaw

public static void SaveFileRaw(float[][][] imageSamples,
                               java.lang.String imageFile,
                               int sampleType,
                               int byteOrder)
                        throws WarningException
Saves image samples in raw data.

Parameters:
imageSamples - a 3D float array that contains image samples
imageFile - file name where raw data will be stored
sampleType - an integer representing the class of image samples type. Samples types can be:
  • 0- boolean
  • 1- byte
  • 2- char
  • 3- short
  • 4- int
  • 5- long
  • 6- float
  • 7- double
byteOrder - 0 if BIG_ENDIAN, 1 if LITTLE_ENDIAN
Throws:
WarningException - when the file cannot be saved (incorrect number of components, file format unrecognized, etc.)

SaveFileExtension

public static void SaveFileExtension(float[][][] imageSamples,
                                     int[] QComponentsBits,
                                     java.lang.String imageFile,
                                     int[] imageGeometry)
                              throws WarningException
This functions saves the image samples to an image file with the format specified by its extension.

Parameters:
imageSamples - the image samples
QComponentsBits - the bit depth of each image component
imageFile - the name file
imageGeometry - image geometry needed in the case that the output file is raw or img
Throws:
WarningException - when the file can not be saved

SaveFileByExtension

public static void SaveFileByExtension(float[][][] imageSamples,
                                       java.lang.String imageFile,
                                       int[] imageGeometry)
                                throws WarningException,
                                       ParameterException
Saves image samples in the format given by the extension.

Parameters:
imageSamples - a 3D float array that contains image samples
imageFile - file name where raw data will be stored
imageGeometry - a 1D integer array that contains the format when the data is stored in raw data
Throws:
WarningException - when the file cannot be saved (incorrect number of components, file format unrecognized, etc.)
ParamterException - when saving with raw mode and the imageGeometry parameter has some problems
ParameterException

SaveFileByExtensionAndName

public static void SaveFileByExtensionAndName(float[][][] imageSamples,
                                              java.lang.String imageFile,
                                              int[] imageGeometry,
                                              java.lang.String outputImagefile)
                                       throws WarningException,
                                              ParameterException
Saves image samples in the format given by the extension.

Parameters:
imageSamples - a 3D float array that contains image samples
imageFile - file name that contains original data
imageGeometry - a 1D integer array that contains the format when the data is stored in raw data
imageFile - file name where raw data will be stored
Throws:
WarningException - when the file cannot be saved (incorrect number of components, file format unrecognized, etc.)
ParamterException - when saving with raw mode and the imageGeometry parameter has some problems
ParameterException

getFormat

public static int getFormat(java.lang.String imageFile)
                     throws WarningException
Gets the extension, if any, of the image to be saved.

Parameters:
imageFile - contains the name of the image to be saved
Returns:
an integer that indicated containing the format
Throws:
WarningException - when the file has no extension


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)