CD - Canvas Draw

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

A CGM file 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]" ou em 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". 

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 cdCreateImageEx 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 in the CD library.

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

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

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

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

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

Returns the canvas' internal RGB image.


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

Behavior of Functions

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. Replace the old functions cdRedImage, cdGreenImage, cdBlueImage.