[gdal-dev] Issue with writen colortables

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Issue with writen colortables

Joaquim Luis

Attached are two tinny indexed images created with GMT but via GDAL.

The .tif file looks right but if look at the .png (it needs lots of zoom) we can see that the top left pixel is missing. That happens, I think, because the transparency column has a first value of 0 whilst all the others are 1’s. I checked this both with GDAL and Matlab.

 

The code that writes it is

https://github.com/GenericMappingTools/gmt/blob/master/src/gmt_gdalwrite.c#L343

where .c4 is well set to 255. However when it lands on the file, the first was converted to 0.

 

Again, I’m doing this the Julia bindings so have no C code to provide a MWE.

 

 

 

Thanks

 

Joaquim


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

lixo.png (1K) Download Attachment
lixo.tif (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Issue with writen colortables

Even Rouault-2

On jeudi 26 mars 2020 19:58:52 CET Joaquim Manuel Freire Luís wrote:

> images created with GMT but via GDAL.

> The .tif file looks right but if look at the .png (it needs lots of zoom) we

> can see that the top left pixel is missing. That happens, I think, because

> the transparency column has a first value of 0 whilst all the others are

> 1's. I checked this both with

 

You should probably not set the nodata value to 0. This will cause the alpha component for entry 0 of the color table to be set to 0 when writing PNG

 

Even

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Issue with writen colortables

Joaquim Luis

Funny, I made it nodata = 1 and the zero moved to second place.

 

 

From: Even Rouault <[hidden email]>
Sent: Thursday, March 26, 2020 8:47 PM
To: [hidden email]
Cc: Joaquim Manuel Freire Luís <[hidden email]>
Subject: Re: [gdal-dev] Issue with writen colortables

 

On jeudi 26 mars 2020 19:58:52 CET Joaquim Manuel Freire Luís wrote:

> images created with GMT but via GDAL.

> The .tif file looks right but if look at the .png (it needs lots of zoom) we

> can see that the top left pixel is missing. That happens, I think, because

> the transparency column has a first value of 0 whilst all the others are

> 1's. I checked this both with

 

You should probably not set the nodata value to 0. This will cause the alpha component for entry 0 of the color table to be set to 0 when writing PNG

 

Even

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Issue with writen colortables

Even Rouault-2

On jeudi 26 mars 2020 23:19:47 CET Joaquim Manuel Freire Luís wrote:

> Funny, I made it nodata = 1 and the zero moved to second place.

 

Fully determinstic behaviour: GDAL sets the alpha component of the entry in

the color table whose value is nodata to 0:

 

https://github.com/OSGeo/gdal/blob/master/gdal/frmts/png/pngdataset.cpp#L1820

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Issue with writen colortables

Joaquim Luis

Ah, thanks. So the solution is to not call GDALSetRasterNoDataValue() unless we really want to set one color as transparent.

 

From: Even Rouault <[hidden email]>
Sent: Thursday, March 26, 2020 11:24 PM
To: Joaquim Manuel Freire Luís <[hidden email]>
Cc: [hidden email]
Subject: Re: [gdal-dev] Issue with writen colortables

 

On jeudi 26 mars 2020 23:19:47 CET Joaquim Manuel Freire Luís wrote:

> Funny, I made it nodata = 1 and the zero moved to second place.

 

Fully determinstic behaviour: GDAL sets the alpha component of the entry in

the color table whose value is nodata to 0:

 

https://github.com/OSGeo/gdal/blob/master/gdal/frmts/png/pngdataset.cpp#L1820

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Issue with writen colortables

Osahon Oduware
In reply to this post by Joaquim Luis
**Copy links to browser address bar if they are not opening upon click:  
*LEAH SHARIBU, 2 YEARS AFTER*:  

BE WISE AS SERPENTS (Facebook Page Link)*:  


On Mar 26, 2020 20:59, "Joaquim Manuel Freire Luís" <[hidden email]> wrote:

Attached are two tinny indexed images created with GMT but via GDAL.

The .tif file looks right but if look at the .png (it needs lots of zoom) we can see that the top left pixel is missing. That happens, I think, because the transparency column has a first value of 0 whilst all the others are 1’s. I checked this both with GDAL and Matlab.

 

The code that writes it is

https://github.com/GenericMappingTools/gmt/blob/master/src/gmt_gdalwrite.c#L343

where .c4 is well set to 255. However when it lands on the file, the first was converted to 0.

 

Again, I’m doing this the Julia bindings so have no C code to provide a MWE.

 

 

 

Thanks

 

Joaquim


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev