<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi Even,</p>
<p><br>
</p>
<p>OK. It is what it is. I guess.</p>
<p><br>
</p>
<p>I wrote a little test code:</p>
<p><br>
</p>
<p></p>
<div><span style="font-family:"Courier New",monospace">#include <gdal.h></span><br>
<span style="font-family:"Courier New",monospace">#include <gdal_utils.h></span><br>
<br>
<span style="font-family:"Courier New",monospace">int main( int argc, char** argv )</span><br>
<span style="font-family:"Courier New",monospace">{</span><br>
<span style="font-family:"Courier New",monospace">   char* papszArgv[1024];</span><br>
<span style="font-family:"Courier New",monospace">   int i = 0;</span><br>
<br>
<span style="font-family:"Courier New",monospace">   const char*     pszSrcFilename = "rgbsmall.tif";</span><br>
<span style="font-family:"Courier New",monospace">   const char*     pszDstFilename = "test90.tif";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   GDALDatasetH    hSrcDataset = NULL;</span><br>
<span style="font-family:"Courier New",monospace">   GDALDatasetH    hDstDataset = NULL;</span><br>
<br>
<span style="font-family:"Courier New",monospace">   GDALTranslateOptions* psOptions = NULL;</span><br>
<br>
<span style="font-family:"Courier New",monospace">   GDALAllRegister();</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "-of";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "GTIFF";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "-b";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "3";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "-b";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "2";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "-b";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "1";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "-srcwin";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "10";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "10";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "30";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "30";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "-co";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "BLOCKXSIZE=4";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "-co";</span><br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = "BLOCKYSIZE=4";</span><br>
<br>
<span style="font-family:"Courier New",monospace">   papszArgv[i++] = NULL;</span><br>
<br>
<span style="font-family:"Courier New",monospace">   psOptions   = GDALTranslateOptionsNew( papszArgv, NULL );</span><br>
<br>
<span style="font-family:"Courier New",monospace">   hSrcDataset = GDALOpen( pszSrcFilename, GA_ReadOnly );</span><br>
<br>
<span style="font-family:"Courier New",monospace">   hDstDataset = GDALTranslate( pszDstFilename, hSrcDataset, psOptions, NULL );</span><br>
<br>
<span style="font-family:"Courier New",monospace">   GDALTranslateOptionsFree( psOptions );</span><br>
<br>
<span style="font-family:"Courier New",monospace">   GDALClose( hSrcDataset );</span><br>
<br>
<span style="font-family:"Courier New",monospace">   GDALClose( hDstDataset );</span><br>
<span style="font-family:"Courier New",monospace">}</span><br>
</div>
<p></p>
<p><br>
</p>
<p>And I can say that it does work as expected. Maybe we should put that example somewhere on the wiki.</p>
<p><br>
</p>
<p>I found to interesting issues. That is just a C application using the GDAL C API but I could only compile with g++, not with gcc. I can't record that was the case 10 years ago. It used to be the case that gdal_translate itself was isolated from the core.
 Maybe it has something to do with that.</p>
<p><br>
</p>
<p>The GTIFF create-option BLOCKXSIZE doesn't seems to work. I tries with larger images and it seems like we can only control the number of rows on a block (BLOCKYSIZE),  but not the number of columns (BLOCKXSIZE).</p>
<p><br>
</p>
<p>Thanks again.</p>
<p><br>
</p>
<p>Best regards,</p>
<p>Ivan<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Even Rouault <even.rouault@spatialys.com><br>
<b>Sent:</b> Wednesday, October 19, 2016 3:55:09 PM<br>
<b>To:</b> gdal-dev@lists.osgeo.org<br>
<b>Cc:</b> Ivan Lucena<br>
<b>Subject:</b> Re: [gdal-dev] Utilities as a library, C API</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Ivan,<br>
<br>
The fact that GDALTranslateOptions is opaque is a design decision that was the <br>
outcome of the discussion phase of RFC 59. It was thought that it would be <br>
difficult to have a stable C structure that could be also extented in the future <br>
without becoming too messy. For example regarding old options that would have <br>
been generalized into newer syntax. Hence the decision to have a minimal <br>
string based interface that takes the same arguments than the command line <br>
strings that lead to RFC 59.1.<br>
So it is up to you to build a nicer API on top of this and build the string <br>
array (that's what the python bindings do for example). Note that the strings <br>
must be split like the arguments of the main(), ie. { "-of", "GTiff", NULL }. <br>
<br>
Even<br>
<br>
-- <br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com">http://www.spatialys.com</a><br>
</div>
</span></font>
</body>
</html>