<div dir="ltr"><span style="font-size:12.8px">&gt;So please edit the following line:</span><br style="font-size:12.8px"><br style="font-size:12.8px">&gt;<a href="https://github.com/malaterre/openslide/blob/dicom-wsi/src/openslide-vendor-dicom.c#L84" rel="noreferrer" target="_blank" style="font-size:12.8px">https://github.com/malaterre/openslide/blob/dicom-wsi/src/openslide-vendor-dicom.c#L84</a><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">&gt;And change:</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">&gt;const int tidx = tile_col * dicoml-&gt;tiles_across + tile_row;</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">&gt;into:</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">&gt;const int tidx = tile_row * dicoml-&gt;tiles_across + tile_col;</span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thank you Mathieu, </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I tried but I got the same result. I think that the problem lays in the number of levels of the whole slide image. When I run this function  openslide_get_level_count(openslide_t * osr) the result is 2 with the DOGDIR and the respective values are 1 for the first level and 1.9444444444444444 for the second level. If I try to do the  same thing with another file, for example OS-3.ndpi from the Openslide test data I got that is has 13 levels with respective values [1.0,</span><span style="font-size:12.8px"> 2.0, </span><span style="font-size:12.8px">4.0,</span><span style="font-size:12.8px"> 8.0, </span><span style="font-size:12.8px">16.0,</span><span style="font-size:12.8px"> 32.0,</span><span style="font-size:12.8px"> 64.0,</span><span style="font-size:12.8px"> 128.0,</span><span style="font-size:12.8px"> 256.0,</span><span style="font-size:12.8px"> 512.0,</span><span style="font-size:12.8px"> 1024.0, </span><span style="font-size:12.8px">2048.0,</span><span style="font-size:12.8px"> 4096.0].</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">So when I use the Demo.java program it is giving me the error because the highest level downsample is 1.94444444444444 and because of that the region that I am trying to open is too large for the Java heap space and  the java virtual machine is throwing me a javaOutOfMemoryError exception.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Unfortunately I know only Java, and my programming skills in C are verry, verry limited so forgive me if I can not help you more with that.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks for the help!</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 September 2015 at 14:50, Mathieu Malaterre <span dir="ltr">&lt;<a href="mailto:mathieu.malaterre@gmail.com" target="_blank">mathieu.malaterre@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Sep 14, 2015 at 6:19 PM, Ivo Rakar &lt;<a href="mailto:ivo23061987@gmail.com">ivo23061987@gmail.com</a>&gt; wrote:<br>
&gt; $ openslide-write-png DOGDIR 0 0 1 36864 34048 dicom.png<br>
&gt; openslide-write-png: Cannot seek to offset: Invalid argument<br>
<br>
</span>Thanks much !<br>
<br>
So please edit the following line:<br>
<br>
<a href="https://github.com/malaterre/openslide/blob/dicom-wsi/src/openslide-vendor-dicom.c#L84" rel="noreferrer" target="_blank">https://github.com/malaterre/openslide/blob/dicom-wsi/src/openslide-vendor-dicom.c#L84</a><br>
<br>
And change:<br>
<br>
const int tidx = tile_col * dicoml-&gt;tiles_across + tile_row;<br>
<br>
into:<br>
<br>
const int tidx = tile_row * dicoml-&gt;tiles_across + tile_col;<br>
</blockquote></div><br></div>