GenericMappingTools / GenericMappingTools/gmt

gdal_read is not filling out the pixels correctly (?)

Open
#3,294 22 comments 0 reactions 0 assignees View on GitHub
longterm
Dominant language
C
Stars
979
Forks
414
Avg merge
17h 26m
Merged PRs (30d)
54

Description

In debugging new module **grdmix** in branch mix-imgs-module I read in a 50x50 all red PNG. GDAL correctly reports 50x50 with 3 bands, and we allocate 50x50x3 = 7500 bytes for it. However, the I->data array returned by _GMT_Read_Data_, if we loop over the 2500 pixels and print the R/G/B values, yields this result:

```
Pixel 0 is 255/000/000
Pixel 1 is 255/000/000
Pixel 2 is 255/000/000
Pixel 3 is 255/000/000
...
Pixel 832 is 255/000/000
Pixel 833 is 255/000/000
Pixel 834 is 000/000/000
...
Pixel 2499 is 000/000/000
```

All pixels after 833 are 0/0/0. So instead of 2500 red pixels, we get 2500/3 ~ 834 red pixels and the rest are all zero. Somewhere in _gmt_gdalread_ there is a division of 3 that causes problems. I note that if I plot the red.png in **psimage** it comes out correctly, but this may be because postscriptlight detects this as an indexed image with 1 color so it makes a 1-bit image. Hard to trace. However, clearly the 3*size array returned by _GMT_Read_Data_ is flawed. Need @joa-quim to have a look. Attached is red.png.

![red](https://user-images.githubusercontent.com/26473567/81464459-b30a3c80-915d-11ea-9e43-e1786e6804a4.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.