Description
DBReadWindow() is used read a portion of an image window into a buffer.
Call Signature
void DBReadWindow ( int/string filespec, int x_offset, int y_offset, int x_size, int y_size, int num_channels, int ptr channels, any ptr buffer [, string interleaving] )
Return Value
void
This has no return value.
Arguments
int/string filespec:
This can either be the handle returned by DBOpen(), or the name of an open file.
int x_offset:
X offset to the desired window. This is zero for the very first pixel of the scanline.
int y_offset:
Y offset to the desired window. This is zero for the very first scanline on the database.
int x_size:
The number of pixels to fetch from the xoffset point in the window.
int y_size:
The number of scanlines to fetch from the yoffset point in the window.
int num_channels:
Number of channel values in channels.
int ptr channels:
The list of channels to read. This array will contain num_channels entries.
any ptr buffer:
An array of bytes, integers, or floats large enough to receive the requested number of pixels.
[ string interleaving ]:
If this argument is present, this is a flag indicating how to interleave the data in the buffer. "P", Pixel interleaved. "C", Channel interleaved. If this is missing, Pixel interleaved is used.
Remarks
DBReadWindow() and DBWriteWindow() allow direct access to imagery stored on image databases.
Note: This does not have the power and convenient abilities of the MODEL statement.
The requested pixel values are fetched and assigned to the passed buffer. The pixel values will be promoted/demoted to the type of the buffer according to the usual rules. The xoffset plus the xsize values must total, at most, the number of pixels in the database. Similarly, the yoffset plus the ysize values must total, at most, the number of scanlines in the database.
An image window with dimensions two lines by three pixels with two channels can conceptually be arranged as follows:
a11 a12 a13 b11 b12 b13
a21 a22 a23 b21 b22 b23
This data will be returned in the following way, depending on how the interleaving was specified. If interleaving is "P", return interleaved by pixel:
a11 b11 a12 b12 a13 b13 a21 b21 a22 b22 a23 b23
If interleaving is "C", return interleaved by channel:
a11 a12 a13 a21 a22 a23 b11 b12 b13 b21 b22 b23
Example
The following example mirrors a database across the horizontal axis.
local integer tfid, y_offset, float ptr buf1, float ptr buf2
local integer ptr channel_list
del "my.pix" noerror
try
Call CopyFile(GetPCIHOME()+"/demo/irvine.pix","my.pix")
tfid = DBOpen( "my.pix", "w" )
buf2 = EAlloc( float, DBPixels(tfid))
buf1 = EAlloc( float, DBPixels(tfid))
channel_list = EAlloc( integer, 1 )
channel_list[1] = 1
for y_offset = 0 to DBLines(tfid)/2 - 1
call DBReadWindow( tfid, 0, y_offset, DBPixels(tfid), 1, \
1, channel_list, buf1, "P" )
call DBReadWindow( tfid, 0, DBLines(tfid)-y_offset-1, DBPixels(tfid), 1, \
1, channel_list, buf2, "P" )
call DBWriteWindow( tfid, 0, DBLines(tfid)-y_offset-1, DBPixels(tfid), 1, \
1, channel_list, buf1, "P" )
call DBWriteWindow( tfid, 0, y_offset, DBPixels(tfid), 1, \
1, channel_list, buf2, "P" )
endfor
call DBClose( tfid )
onerror
print "Error: ", GetLastErrorMessage()
endonerror
See also
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.