pavkiz,<br><br>You are using GDT_Byte in the RasterIO function call. If you want to write the date with 16bit depth you need to use GDT_Int16 or GDT_UInt16.<br><br>Check the translation with the GDAL utility gdal_translate [1] with the -ot option.<br>
<br>[1]: <a href="http://www.gdal.org/gdal_translate.html">http://www.gdal.org/gdal_translate.html</a><br><br><div class="gmail_quote">On Thu, Jul 21, 2011 at 6:16 PM, el_inca <span dir="ltr"><<a href="mailto:pavkiz@mail.ru">pavkiz@mail.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br>
Can anybody help me with saving TIFF images? I need to save 8 bit image to<br>
16 bit image.<br>
Raster data is keeping in Byte array.<br>
When i save from 8 bit to 8 bit it works good.<br>
But when i save from 8 to 16 bit Gdal creates an image, that i can read<br>
after with this library, but not with another program that supports 16 bit<br>
images.<br>
I wrote a program that makes byte shift. So when shifting at 4 bytes in each<br>
image row it displays correctly.<br>
In documentation i have read that GDAL automatically translates data types.<br>
<br>
Image colorscheme is in RGB.<br>
<br>
Here is the part of code:<br>
<br>
GDALDataset *new_dataset;<br>
<br>
new_dataset=driver->Create(Filename,<br>
image_size_x,<br>
image_size_y,<br>
poDataset->GetRasterCount(),<br>
GDT_Int16,<br>
NULL);<br>
<br>
for (int raster=0;raster<poDataset->GetRasterCount();raster++)<br>
{<br>
GDALRasterBand *new_rasterband;<br>
new_rasterband=new_dataset->GetRasterBand(raster+1);<br>
for (int j=0;j&lt;image_size_y;j++)<br>
{<br>
Byte * scanline=new Byte[image_size_x];<br>
new_rasterband-&gt;RasterIO(GF_Write,<br>
0,//start position in X<br>
y,//start position in Y<br>
image_size_x,<br>
1,<br>
scanline,<br>
image_size_x,//buffer<br>
1,<br>
GDT_Byte,<br>
0,<br>
0);<br>
}<br>
}<br>
<font color="#888888"><br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/Saving-16-bit-image-tp6606613p6606613.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/Saving-16-bit-image-tp6606613p6606613.html</a><br>
Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br>+91-9494447584<br>17.2416N 80.1426E<br>