<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi, <br>
I am trying to use the GDALDataset::RasterIO method to read all the
bands into a chunk of memory, and be able to access a pixel's values in
all bands by using a <i>[]</i> operator on the memory. <br>
I got the sizes of the data types in all the bands, sum up to get the
total data type size, then define a new type: <br>
<b><br>
typedef char NewType[totalSize]</b>; <i>/* For exmaple, for a
Byte-type RGB raster, the totalSize is 3 */</i><br>
<b>pData = (NewType *)CPLMalloc(totalSize*nRows*nCols);<br>
poDataset->RasterIO(GF_Read, 0, 0, nCols, nRows,<br>
pData, nCols, nRows,<br>
vDataTypes[0], </b><i>/* using the data type
of band 1 */</i><b><br>
nBands, aBandMap,<br>
totalSize, </b><i>/* The byte offset for
one pixel is the totalSize, e.g., 3 for a RGB raster */</i><b><br>
totalSize*nCols, </b><i>/* The byte offset for
one line */</i><b><br>
totalSize/nBands </b><i>/* The byte offset for
one band is the size of the data type of one band, e.g, 1 for a RGB
raster */</i><b><br>
);</b><br>
<br>
<b>NewType pixVal;<br>
memcpy(pixVal,<br>
pData[0], </b><i>/* This should return the pixel's values in
all bands, e.g., a 3-byte array containing the RGB values */</i><b><br>
totalSize);</b><br>
<br>
However, this approach somehow didn't work. Anyone has an idea
how to do this? Is it because the NewType isn't correct?<br>
Thanks.
<div class="moz-signature">-- <br>
<title></title>
<font face="Courier New">---=== Qingfeng (Gene) Guan ===---</font><br>
</div>
</body>
</html>