<div dir="ltr"><div><div><div><div>Nik,<br><br></div>No, the PNG format does not support direct creation, only creation by copying an existing dataset (GDALCreateCopy()). You can interactively see the capabilities of a driver like this:<br>
<br>gdalinfo --format png<br>Format Details:<br> Short Name: PNG<br> Long Name: Portable Network Graphics<br> Extension: png<br> Mime Type: image/png<br> Help Topic: frmt_various.html#PNG<br> Supports: CreateCopy() - Create dataset by copying another.<br>
Supports: Virtual IO - eg. /vsimem/<br> Creation Datatypes: Byte UInt16<br><br><CreationOptionList><br> <Option name="WORLDFILE" type="boolean" description="Create world file" /><br>
<Option name="ZLEVEL" type="int" description="DEFLATE compression level 1-9" default="6" /><br></CreationOptionList><br><br></div>The "Supports: CreateCopy()" means you can create the format, but only by copying an existing dataset. Formats supporting creation will have "Supports: Create()". You can get a broad listing of all formats like this:<br>
<br>gdalinfo --formats<br>....<br> SDTS (rov): SDTS Raster<br> DTED (rwv): DTED Elevation Raster<br> PNG (rwv): Portable Network Graphics<br> JPEG (rwv): JPEG JFIF<br> MEM (rw+): In Memory Raster<br>...<br><br></div>
The "w" means it supports at least CreateCopy(). The "+" means it supports create+update. <br><br></div>Best regards,<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 16, 2013 at 10:14 PM, Nik Sands <span dir="ltr"><<a href="mailto:nixanz@nixanz.com" target="_blank">nixanz@nixanz.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can I use GDALCreate to create (and later write to) PNG images?<br>
If so, is "PNG" the correct string for GDALGetDriverByName?<br>
<br>
Otherwise, can somebody please let me know why the code below returns NULL from GDALCreate (assigned to dstDS)?<br>
<br>
Advice much appreciated, as always.<br>
<br>
Thanks,<br>
Nik.<br>
<br>
<br>
<br>
GDALDriverH hDriver = GDALGetDriverByName("PNG");<br>
char **papszOptions = NULL;<br>
<br>
papszOptions = CSLSetNameValue( papszOptions, "WORLDFILE", "NO" );<br>
papszOptions = CSLSetNameValue( papszOptions, "ZLEVEL", "9" );<br>
<br>
GDALDatasetH dstDS = GDALCreate( hDriver, "/var/tmp/image.png", 256, 256, 4, GDT_Float32, papszOptions );<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>
</blockquote></div><br><br clear="all"><br>-- <br>---------------------------------------+--------------------------------------<br>I set the clouds in motion - turn up | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>and watch the world go round - Rush | Geospatial Software Developer<br>
</div>