<div dir="ltr"><div><div><div><div><div><br></div>Dear gdal-developers,<br><br></div>I noticed a strange behaviour while reading Pleaides Jpeg2000 4 bands EO products using overviews. I use GDAL 1.10.1 with Erdas ECW4.3 to support jpeg2000 files. The following code <br>
<br></div><div><span style="color:rgb(128,0,128)">GDALDataset</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">dataset</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">static_cast</span><span style="color:rgb(0,0,0)"><</span><span style="color:rgb(128,0,128)">GDALDataset</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*>(</span><span style="color:rgb(0,0,0)">GDALOpen</span><span style="color:rgb(0,0,0)">(</span>inputFilename<span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">GA_ReadOnly</span><span style="color:rgb(0,0,0)">));</span><br>
<br></div><div>< Image has : 4 bands, and WxH : <span style="font-family:'Courier';font-size:10pt;color:rgb(0,0,0)">10296, 6573</span>><br></div><div>< Image DataType : GDT_UInt16><br></div><div><define parameters : offset={0,0}, <span style="color:rgb(0,0,0)">desiredNbOfSamples=167424, data.width=500, data.height=400</span>><br>
</div><div><br></div><div>// Just get and show twice the same data :<br></div><div>for (int index = 0; index < 2; index++)<br>{<br><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">pixelSizeInBytes</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">nbBands</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> 8</span><span style="color:rgb(0,0,0)">;<br>
</span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">rowSizeInBytes</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">pixelSizeInBytes</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">data</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(128,0,0)">width</span><span style="color:rgb(0,0,0)">;</span></div>
<div><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">band</span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(0,0,0)">band</span><span style="color:rgb(0,0,0)"><=</span><span style="color:rgb(0,0,0)">nbBands</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(0,0,0)">band</span><span style="color:rgb(0,0,0)">++)</span> <br>
<pre style="margin:0px;text-indent:0px">{<span style="color:rgb(0,0,0)"></span><br></pre><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">GDALRasterBand</span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">rasterBand</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">= </span><span style="color:rgb(192,192,192)"></span><span style="color:rgb(0,0,0)">dataset</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">GetRasterBand</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">band</span><span style="color:rgb(0,0,0)">)-></span><span style="font-style:italic;color:rgb(0,0,0)">GetRasterSampleOverview</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">desiredNbOfSamples</span><span style="color:rgb(0,0,0)">);</span><br>
<span style="color:rgb(192,192,192)"></span><span style="color:rgb(0,0,0)"> rasterBand</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">RasterIO</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">GF_Read</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">offset</span><span style="color:rgb(0,0,0)">[</span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">],</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">offset</span><span style="color:rgb(0,0,0)">[</span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">],</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">data</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(128,0,0)">width</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">data</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(128,0,0)">height</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><br>
data.buffer</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">+</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">8</span><span style="color:rgb(0,0,0)">*(</span><span style="color:rgb(0,0,0)">band</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">-</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">),</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">data</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(128,0,0)">width</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">data</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(128,0,0)">height</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">GDT_Float64</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">pixelSizeInBytes</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">rowSizeInBytes</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">);</span><br>
}<br>
</div>showData(data);<br><br>}<br><span style="color:rgb(0,0,0)">GDALClose</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">dataset</span><span style="color:rgb(0,0,0)">);</span><br><br></div>The result of the code is intended to show twice the same data, however the result is that the first shown image is correct and the second image is horizontally distorted (compressed) as 1/4 of the good width. <br>
</div><div>Could anyone, please explain me whether I missed something ?<br><br></div><div>Cheers,<br>Victor <br></div><br></div>