Description
DBWriteWindow() is used to write a portion of an image window stored in a buffer.
Call Signature
void DBWriteWindow ( int/string filespec, int x_offset, int y_offsetp>, 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 write from the x_offset point in the window.
int y_size:
The number of scanlines to write from the y_offset point in the window.
int num_channels:
Number of channel values in channels.
int ptr channels:
The list of channels to write. This array will contain num_channels entries.
any ptr buffer:
An array of bytes, integers, or floats large enough to hold the requested number of pixels.
[ string interleaving ]:
An optional flag indicating how the input data is interleaved. in the buffer. The default is Pixel interleaved.: "P", Pixel interleaved. "C", Channel interleaved.
Remarks
DBReadWindow() and DBWriteWindow() allow direct access to imagery stored on image databases.
Note: These intrinsics lack the power and convenient abilities of the MODEL statement.
The requested pixel values are written to the desired window in the file from the passed buffer. The pixel values will be promoted/demoted to the type of the image channel according to the usual rules. The x_offset plus the x_size values must total, at most, the number of pixels in the database. Similarly, the y_offset plus the y_size 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 passed in the following way, depending on how interleaving was specified. If interleaving is "P", input as interleaved by pixel:
a11 b11 a12 b12 a13 b13 a21 b21 a22 b22 a23 b23
if interleaving is "C", input as 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.