Ticket #773 (closed defect: fixed)
RasterIO() "expansion" doesn't work right in most cases.
| Reported by: | warmerdam | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | high | Milestone: | 1.6.0 |
| Component: | GDAL_Raster | Version: | unspecified |
| Severity: | normal | Keywords: | rasterio expansion |
| Cc: |
Description
Hi Frank again,
OK, the Fill() seems to be a reasonable way to assure that
you put some appropriate "background" value. That's OK.
However, I'm still noticing something wrong regarding my
original posting: replicating a value. The attached test
program creates a 10x6 1-band raster of type byte; fills
it with '_' and then calls RasterIO to set the upper left
7x3 region with 'X':
$ g++ rasteriotest.cc -lgdal -Wall
$ ./a.out
result = 0
$ cat raster
_____________X______________________________________________
but it should be:
XXXXXXXXXXXXXXXXXXXXX_______________________________________
Right?
... test code:
#include "gdal.h"
#include "gdal_priv.h"
#include <iostream>
#include <cassert>
using namespace std;
/*
RasterIO bug?
$ g++ rasteriotest.cc -lgdal -Wall
$ ./a.out
result = 0
$ cat raster
_____________X______________________________________________
but it should be:
XXXXXXXXXXXXXXXXXXXXX_______________________________________
*/
int main() {
GDALAllRegister();
GDALDriver* hDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
assert(hDriver);
GDALDataset* dataset = hDriver->Create(
"raster",
10, //nXSize
6, //nYSize
1, //nBands
GDT_Byte, //GDALDataType
NULL //papszParmList
);
dataset->GetRasterBand(1)->Fill('_');
char value = 'X';
int result = dataset->RasterIO(
GF_Write,
0, //nXOff,
0, //nYOff,
7, //nXSize,
3, //nYSize,
&value, //pData,
1, //nBufXSize,
1, //nBufYSize,
GDT_Byte, //eBufType,
1, //nBandCount,
NULL, //panBandMap,
0, //nPixelSpace,
0, //nLineSpace,
0 //nBandSpace
);
cout<< "result = " <<result<< endl;
dataset->FlushCache();
delete dataset;
return 0;
}
Change History
Note: See
TracTickets for help on using
tickets.
