GDBIntChanIO() automatically performs shrinking/zooming between windows of different sizes, mapping between buffer and generic database channels, and data type conversions.
GDBIntChanIO() is similar to GDBByteChanIO(), except that the image data buffer consists of int32's. Please review the GDBByteChanIO() help for information on data interleaving, zooming and windowing.
See Also: GDBByteChanIO(), GDBRealChanIO()
void GDBIntChanIO(fpGDB, nFunc, nXOff, nYOff, nXSize, nYSize,
panImgBuf, nBufXSize, nBufYSize,
nBufChanCount, panChanMap);
FILE *fpGDB;
File pointer of generic database file to access.
int nFunc;
Function to perform. This should be GDB_READ, to read
from the file into pabyImgBuf, or GDB_WRITE to write from
pabyImgBuf into the file.
int nXOff;
X (pixel) offset to imagery window in file.
int nYOff;
Y (line) offset to imagery window in file.
int nXSize;
X (pixel) size of imagery window in file.
int nYSize;
Y (line) size of imagery window in file.
int32 *panImgBuf;
Buffer of integer image data to read/write.
On a read, this buffer receives the imagery data read
from the file. On a write, this buffer contains the
imagery data to write into the file. The image held in
panImgBuf has dimensions nBufYSize lines, each line made
up of nBufXSize pixels, each pixel having nBufChanCount
channels.
int nBufXSize;
X (pixel) size of imagery window in buffer.
int nBufYSize;
Y (line) size of imagery window in buffer.
int nBufChanCount;
Number of channel values in panImgBuf.
int *panChanMap;
Channel mapping buffer. The list of channels to read,
or write. This array should contain nBufChanCount entries.
The caller of GDBIntChanIO() does not need know the type of data each channel on the file contains since GDBIntChanIO() automatically converts between int32 and other data types. This gives the appearance that all channels on the file are int32.
As a general rule, when one data type is converted to another, input values which are less than or greater than the minimum or maximum allowed output values are set to the minimum or maximum output value. Real values are truncated to integer values, where necessary. Scaling and rounding is NOT performed.
The following table shows how a pixel value N in the database is converted to and from a byte value in the buffer, for each of the four data types.
+---------+--------------------------+--------------------------+ | | READ | WRITE | +---------+------------------+-------+------------------+-------+ | data | file | buffer| buffer | file | | type | input | output| input | output| +---------+------------------+-------+------------------+-------+ | 8-bit | | | 0> N | 0 | | unsigned| 0<=N<=255 | N | 0<=N<=255 | N | | integer | | | N >255 | 255 | +---------+------------------+-------+------------------+-------+ | 16-bit | | | -32678> N |-32768 | | signed | -32768<=N<=32767 | N | -32768<=N<=32767 | N | | integer | | | N >32767 | 32767 | +---------+------------------+-------+------------------+-------+ | 16-bit | | | 0> N | 0 | | unsigned| 0<=N<=65535 | N | 0<=N<=65535 | N | | integer | | | N >65535 | 65535 | +---------+------------------+-------+------------------+-------+ | 32-bit | | | | | | real | -2147483648<=N<= | int(N)| any integer N |real(N)| | | 2147483647 | | | | +---------+------------------+-------+------------------+-------+
. . .
FILE *fp;
int chnmap[3],window[4];
char dbname[64];
int32 img[6144]; | 6144=32*64*3
. . .
fp = GDBOpen(dbname,"r+"); | Open the PCIDSK file
window[0] = 123; | X offset
window[1] = 111; | Y offset
window[2] = 128; | X size
window[3] = 128; | Y size
chnmap[0] = 7;
chnmap[1] = 3;
chnmap[2] = 5;
CheckChan (fp,"CHNMAP",CHNMAP,3);
| Check that window is valid and channels exist
CheckWin (fp,"WINDOW",window,chnmap);
GDBIntChanIO(fp,GDB_READ,window[0],window[1],window[2],
window[3],img,32,64,3,chnmap);
| Get the window off the database
. . .