From: rk Date: Wed, 3 Dec 2003 15:41:11 +0000 (+0000) Subject: image bugfixx - mir now depends on jai imagio X-Git-Tag: LATEST_MERGED_1_1~211 X-Git-Url: http://erislabs.net/gitweb/?p=mir.git;a=commitdiff_plain;h=aa507bfd18e723d21e63454a26af3320bb8c27f2 image bugfixx - mir now depends on jai imagio --- diff --git a/NEWS b/NEWS index 0e5e9126..8c4f5c33 100755 --- a/NEWS +++ b/NEWS @@ -1,8 +1,8 @@ -[last changed: $Date: 2003/06/27 02:43:41 $] 2002 mir-coders group +[last changed: $Date: 2003/12/03 15:41:11 $] 2002 mir-coders group ------------------------------------------------------------------------------- ================================ -1.1 (as of yet unreleased) +1.1-rc1 (as of yet unreleased) ================================ [New features/Improvements] @@ -12,12 +12,15 @@ publication date and include things like image thumbnails [Bugfixes] +* more image formats supported with JAI / Java Image I/O [Build process] [Maintenance] [Notes] +Mir depends media operations depend on the correct installation of +JAI / Java Image I/O in the JRE running tomcat. =============================== 1.0.0 final released 2002/12/24 diff --git a/source/mircoders/media/ImageProcessor.java b/source/mircoders/media/ImageProcessor.java index a4fb96be..105e8769 100755 --- a/source/mircoders/media/ImageProcessor.java +++ b/source/mircoders/media/ImageProcessor.java @@ -74,7 +74,7 @@ public class ImageProcessor { private int iconHeight; public ImageProcessor(SeekableStream anImageStream) throws IOException { - PlanarImage tempImage = JAI.create("stream", anImageStream); + PlanarImage tempImage = JAI.create("ImageRead", anImageStream); ParameterBlockJAI params = new ParameterBlockJAI("format"); int bands[]; int nrComponents; @@ -84,6 +84,7 @@ public class ImageProcessor { params.setParameter("dataType", DataBuffer.TYPE_BYTE); ImageLayout layout = new ImageLayout(); + // TODO getColorModel fails for some jpegs sometimes nrComponents = tempImage.getColorModel().getNumColorComponents(); bands = new int[nrComponents]; diff --git a/source/tool/ImageTool.java b/source/tool/ImageTool.java new file mode 100755 index 00000000..ff68b2c9 --- /dev/null +++ b/source/tool/ImageTool.java @@ -0,0 +1,119 @@ +package tool; + +import java.awt.Transparency; +import java.awt.image.ColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.SampleModel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +import javax.media.jai.JAI; +import javax.media.jai.PlanarImage; + + +/** + * This class displays basic information about the image. + */ +public class ImageTool { + /** + * The application entry point. + * @param args the command line arguments. + */ + public static void main(String[] args) throws FileNotFoundException { + // We need one argument: the image filename. + if (args.length != 1) { + System.err.println("Usage: java tool.ImageTool image"); + System.exit(0); + } + FileInputStream fi = new FileInputStream(args[0]); + // Open the image (using the name passed as a command line parameter) + PlanarImage pi = JAI.create("ImageRead", fi); + + // Display image data. First, the image size (non-JAI related). + File image = new File(args[0]); + System.out.println("Image file size:" + image.length() + " bytes."); + + // Now let's display the image dimensions and coordinates. + System.out.print("Dimensions: "); + System.out.print(pi.getWidth() + "x" + pi.getHeight() + " pixels"); + System.out.println(" (from " + pi.getMinX() + "," + pi.getMinY() + " to " + + pi.getMaxX() + "," + pi.getMaxY() + ")"); + + // Tiles number, dimensions and coordinates. + System.out.print("Tiles:"); + System.out.print(pi.getTileWidth() + "x" + pi.getTileHeight() + " pixels" + + " (" + pi.getNumXTiles() + "x" + pi.getNumYTiles() + + " tiles)"); + System.out.print(" (from " + pi.getMinTileX() + "," + pi.getMinTileY() + + " to " + pi.getMaxTileX() + "," + pi.getMaxTileY() + ")"); + System.out.println(" offset: " + pi.getTileGridXOffset() + "," + + pi.getTileGridXOffset()); + + // Display info about the SampleModel of the image. + SampleModel sm = pi.getSampleModel(); + System.out.println("Number of bands: " + sm.getNumBands()); + System.out.print("Data type: "); + + switch (sm.getDataType()) { + case DataBuffer.TYPE_BYTE: + System.out.println("byte"); + + break; + + case DataBuffer.TYPE_SHORT: + System.out.println("short"); + + break; + + case DataBuffer.TYPE_USHORT: + System.out.println("unsigned short"); + + break; + + case DataBuffer.TYPE_INT: + System.out.println("int"); + + break; + + case DataBuffer.TYPE_FLOAT: + System.out.println("float"); + + break; + + case DataBuffer.TYPE_DOUBLE: + System.out.println("double"); + + break; + + case DataBuffer.TYPE_UNDEFINED: + System.out.println("undefined"); + + break; + } + + // Display info about the ColorModel of the image. + ColorModel cm = pi.getColorModel(); + System.out.println("Number of color components: " + cm.getNumComponents()); + System.out.println("Bits per pixel: " + cm.getPixelSize()); + System.out.print("Transparency: "); + + switch (cm.getTransparency()) { + case Transparency.OPAQUE: + System.out.println("opaque"); + + break; + + case Transparency.BITMASK: + System.out.println("bitmask"); + + break; + + case Transparency.TRANSLUCENT: + System.out.println("translucent"); + + break; + } + } +}