hey Peppe, hmm these changes create a copy of the image in memory. can you check with a really big file that this does not "explode" in memory? ..ede
On 8/27/2020 10:07 AM, jump-pilot-svn--- via Jump-pilot-devel wrote: > Revision: 6391 > http://sourceforge.net/p/jump-pilot/code/6391 > Author: ma15569 > Date: 2020-08-27 08:07:43 +0000 (Thu, 27 Aug 2020) > Log Message: > ----------- > Workaround to read color depth and DPI from Aster dem files. Previous methods > (based on JAI) seem to fail with 32DPI/ 4bpp tiff files > > Modified Paths: > -------------- > > core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java > > Modified: > core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java > =================================================================== > --- > core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java > 2020-08-26 16:02:28 UTC (rev 6390) > +++ > core/trunk/src/org/openjump/core/ui/plugin/raster/RasterImageLayerPropertiesPlugIn.java > 2020-08-27 08:07:43 UTC (rev 6391) > @@ -4,6 +4,7 @@ > import java.awt.Dimension; > import java.awt.GridBagLayout; > import java.awt.event.ActionEvent; > +import java.awt.image.BufferedImage; > import java.awt.image.ColorModel; > import java.awt.image.DataBuffer; > import java.awt.image.Raster; > @@ -16,7 +17,7 @@ > import java.util.Hashtable; > import java.util.Locale; > > -import javax.media.jai.PlanarImage; > +//import javax.media.jai.PlanarImage; > import javax.swing.BorderFactory; > import javax.swing.Box; > import javax.swing.Icon; > @@ -442,9 +443,10 @@ > raster_bands = df.format(rLayer.getNumBands());// Get raster number > of > // bands > Raster raster = rLayer.getRasterData(null); > + BufferedImage bImage = rLayer.getImage(); > raster_datatype = getDataType(raster); // Get raster data type > - raster_colordepth = getColorDepth(raster); // Get raster color depth > - raster_dpi = getDPI(raster); // Get raster DPI > + raster_colordepth = getColorDepth(bImage); // Get raster color depth > + raster_dpi = getDPI(bImage); // Get raster DPI > extent = rLayer.getWholeImageEnvelope(); // Get Envelope > extent_cellSizeX = df.format(cellSizeX(raster, extent));// Get X Cell > // size > @@ -616,22 +618,33 @@ > /* > * Gets color depth > */ > - public String getColorDepth(Raster r) throws IOException { > + /* public String getColorDepth(Raster r) throws IOException { > SampleModel sm = r.getSampleModel(); > ColorModel cm = PlanarImage.createColorModel(sm); > int colordepth = cm.getNumComponents(); > return String.valueOf(colordepth) + " bpp"; > - } > + }*/ > + public String getColorDepth(BufferedImage r) throws IOException { > > + ColorModel cm = r.getColorModel(); > + int colordepth = cm.getNumComponents(); > + return String.valueOf(colordepth) + " bpp"; > + } > + > /* > * Gets Dots per Inch (DPI) > */ > - public String getDPI(Raster r) throws IOException { > + /* public String getDPI(Raster r) throws IOException { > SampleModel sm = r.getSampleModel(); > ColorModel cm = PlanarImage.createColorModel(sm); > return String.valueOf(cm.getPixelSize()); > - } > + }*/ > + public String getDPI(BufferedImage r) throws IOException { > > + ColorModel cm = r.getColorModel(); > + return String.valueOf(cm.getPixelSize()); > + } > + > /* > * Gets cell size > */ > > > > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel