Gopen xsz ysz, Gclose, Gwrite x y [backfore_n=0 – Sensoray 2224 Windows User Manual
Page 86: Gfixblack [x=dc_w] [y=dc_h

gopen xsz ysz
The purpose of gopen is to create the Handle to Device Context, and Handle to Bitmap of size xsz by
ysz, that Windows needs to write graphics into. The key to this is creating the Compatible Bitmap,
g_hbmMem, from a Device Context generated from the Desktop, not the Memory Device Context (that is
also created from the Desktop.) This is because CreateCompatibleDC() will be given a default 1x1
monochrome bitmap that subsequent SelectBitmap() statements will not change the color of. i.e. it will
remain monochrome.
The other function of gopen is to setup the context's pen, brush, background color, font, and font color
with default values that may have been changed with other gxxx functions. This allows gopen to be
called multiple times without having to re-program all the default values.
NOTE: This routine, and all the gxxx routines, assume that cls has been called first, or that a suitable full
screen overlay has been loaded into overlay index-0 with the ovlimage, ovlimagei, or ovlimageraw
statements.
gclose
This routine releases all the handles to pens, brushes, bitmaps, etc.. that the gxxx tools use to create
graphics.
gwrite x y [BackFore_n=0]
The routines gets the bitmap, that is being drawn on, in the memory Device Context, converts it to a
format compatible for download, and then downloads the pixels in this overlay to the boards overlay
memory at location x,y using SN_CopyBmpToOverlayZero() API so only the pixels in the bitmap need to
be sent to the board. The default is to load the overlay ontop of the overlay currently being displayed,
thus no call to S2226_UpdateOverlay() is needed to display it.
gfixblack [x=dc_W] [y=dc_H]
Since the 2226 uses 16-bit color for the overlays, and since it treats 0,0,0 as a special transparent color,
values in the range from 0,0,0 to 3,3,3 will inadvertently be rounded down to the 0,0,0 transparent color.
This routine searches the bitmap for RGB values from 0,0,0 to 3,3,3 and replaces them with 4,4,4. This is
useful because the Text anti-aliasing can create these color values when rendering text to the bitmap.
The optional x,y parameters determine the region within the device context/bitmap to perform the
convertion. If not given, the routine will convert the whole bitmap.
86