CD - Canvas Draw

CD_IMAGERGB - RGB Client Image Driver (cdirgb.h)

This driver allows access to a Client Image, an imaged based in RGB colors with 24 bits per pixel (8 per channel). It is used to implement high-quality offscreen drawings, but is slower than the Server Image version. In fact, it is a rasterizer, that is, it converts vector primitives into a raster representation. All primitives are implemented by the library and are not system-dependent (the primitives of the Server Image version are system-dependent).


Use

The canvas is created by means of a call to the function cdCreateCanvas(CD_IMAGERGB, Data), after which other functions in the CD library can be called as usual. The function creates an RGB image, and then a CD canvas. The Data parameter string has the following format:

"widthxheight [r g b] -r[resolution]" or in C "%dx%d %p %p %p -r%g"

It must include the canvas' dimensions. Width and height are provided in pixels (note the lowercase "x" between them). As an option, you can specify the buffers to be used by the driver, so that you can draw over an existing image. The resolution can be defined with parameter -r; its default value is "3.8 pixels/mm" (96.52 DPI). 

Any amount of such canvases may exist simultaneously. It is important to note that a call to function cdKillCanvas is required to close the file properly.

In CDLUA, the canvas can be created in two ways: with an already defined image or without it. With an image, an RGB image must be passed as parameter, created by functions cdCreateImageRGB or cdCreateBitmap in Lua. The resolution must be passed as in the string above, in an extra parameter after the image. Without an image, the parameter passed must be a string in the format above, excluding the r, g and b pointers.


Exclusive Functions in this Driver

unsigned char * cdRedImage(cdCanvas* canvas); [in C]

Returns the red image buffer. The buffer's format is compatible with the Client Image specification.

unsigned char * cdGreenImage(cdCanvas* canvas); [in C]

Returns the green image buffer. The buffer's format is compatible with the Client Image specification.

unsigned char * cdBlueImage(cdCanvas* canvas); [in C]

Returns the blue image buffer. The buffer's format is compatible with the Client Image specification.

cdImageRGB(canvas: canvas_tag) -> (image: imagergb_tag) [in Lua]

Returns the canvas' internal RGB image.


Behavior of Functions

All primitives are from the Simulation driver, see the Simulation driver's documentation for further information.

Control

Coordinate System and Clipping

  • cdUpdateYAxis: does nothing. The axis orientation is the same as the CD library's.
  • Polygon clipping is not performed for Server and  Client Images.

Colors

Exclusive Attributes

  • "REDIMAGE", "GREENIMAGE", "BLUEIMAGE": return the respective pointers of the canvas RGB image (get only). Alternative for the functions cdRedImage, cdGreenImage, cdBlueImage. Not accessible in Lua.