[gdal-dev] Writing pixel values

Akhil Jaggarwal axj4159 at cs.rit.edu
Wed Sep 15 11:52:04 EDT 2010


Hi,

Any comments/suggestions on this issue would be immensely helpful!

I'm storing the pixel values in a buffer like this:

 pafScanline = (short int*)CPLMalloc(sizeof(short int)*nxSize*nySize);

I can read the data alright. The call to GDALRasterIO is being made
correctly, which I do with:

GDALRasterIO(hBand, GF_Read, 0, 0, nxSize, nySize,
                       pafScanline,
                       nxSize,nySize,
                       GDT_Int16,
                       0, 0);
However, when it comes to the part of writing a pixel data to an
output file, the call to GDALRasterIO fails:

for(i = 0; i < nySize; i++) {
               for(j = 0; j < nxSize; j++) {

                       if( CE_Failure == GDALRasterIO( hDestDS,
GF_Write, 0, 0, j, i,
                         change1, j, i , GDT_Int16, 0,0) ) {
                                 printf("Write Error!");
                                 return 1;
                         }
             }
  }

Where change1 is a variable to hold pixel data that I want to change.
It's declared in the following manner:

short int*change1;
change1 = malloc(sizeof(short int));
*change1 = 1;

I can't get what exactly am I missing. The file i'm using is a tiled,
16 bit signed TIFF.

How do I change the value at a pixel location?

Thanks!


More information about the gdal-dev mailing list