<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi-<o:p></o:p></p><p class=MsoNormal> I’ve built GDAL 1.8.1 on Windows and used SWIG to produce the Java bindings. I’ve tried to run Worldwind’s GDALTest application (<a href="http://worldwind31.arc.nasa.gov/svn/trunk/GDAL/GDAL-1.7.2/swig/java/apps/GDALtest.java">http://worldwind31.arc.nasa.gov/svn/trunk/GDAL/GDAL-1.7.2/swig/java/apps/GDALtest.java</a>) against a known good NITF image, but with no success. <o:p></o:p></p><p class=MsoNormal> Initially, I got an exception because the image’s single band is of type UINT16, and the Worldwind code didn’t have a case for that type. I shoehorned it into the INT16 clause, producing this:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>else</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> ((buf_type == gdalconstConstants.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>GDT_Int16</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>)||(buf_type==gdalconstConstants.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>GDT_UInt16</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>))</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> System.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>out</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.println(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Int16/Uint16"</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>short</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>[][] shorts = </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>short</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>[bandCount][];</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>for</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> (</span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>int</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> i = 0; i < bandCount; i++)</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> shorts[i] = </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>short</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>[pixels];</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> bands[i].asShortBuffer().get(shorts[i]);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> imgBuffer = </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> DataBufferShort(shorts, pixels);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> buffer_type = DataBuffer.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>TYPE_USHORT</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> sampleModel = </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> BandedSampleModel(buffer_type,</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> xsize, ysize, xsize, banks, offsets);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> data_type = BufferedImage.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>TYPE_USHORT_GRAY</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> I knew it wasn’t quite correct, but it turns out that it’s not at all correct. The Worldwind function returns a BufferedImage object constructed from the NITF file. Java’s ImageIO object refuses to write the BufferedImage created for the UINT16 image using the code above. There’s no exception, the function ImageIO.write() simply returns false and no file is created.<o:p></o:p></p><p class=MsoNormal> The problem isn’t the image; the GDAL command line applications work very well with it, as does FWTools. <o:p></o:p></p><p class=MsoNormal> I don’t think this is a Java bindings problem; I just think I’m not handling UINT16 images correctly. Given the difference in sign between Java and C, what’s the best way to proceed? There has to be a straightforward answer for this, but I can’t find it. The Worldwind code handles bytes, signed int16s, and signed int32s. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> Thanks,<o:p></o:p></p><p class=MsoNormal> Mike<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>