Windows

CD - Canvas Draw

Microsoft Windows Base Driver

This driver represents a base driver for all system-dependent drivers implemented in the Microsoft Windows system. The implementation uses Win32 API graphics functions, the GDI. The driver works better in Windows NT, but it may also work in Windows 9x/Me.

Behavior of Functions

Control 

  • Flush: does nothing.
  • Play: does nothing, returns CD_ERROR.

Coordinate System and Clipping

  • UpdateYAxis: the orientation of axis Y is the opposite to its orientation in the CD library.

Primitives

  • Text: when Write Mode is XOR or NOT_XOR, the XOR effect is simulated using bitmaps.
  • Line: needs to draw an extra pixel in the final position.

Attributes

  • WriteMode: for the client and server image functions, the mode NOT_XOR works as XOR.
  • Stipple: is always opaque. If not in Windows NT and if width or height are greater than 8, the stipple is simulated using non-regular Windows clipping regions and bitmaps. The simulation is made when filled boxes, sectors and polygons are drawn.
  • Pattern: If not in Windows NT and if width or height are greater than 8, the pattern is simulated using non-regular Windows clipping regions and bitmaps. The simulation is made when filled boxes, sectors and polygons are drawn.
  • TextAlignment: the vertical alignment of CD_CENTER, CD_EAST, CD_WEST is manually calculated.
  • LineWidth: If not in Windows NT line width is always 1. If line width is 1, then a cosmetic pen is used for fast drawing.
  • LineStyle: If line width is 1, the style is a little different from when line width is not 1, because a cosmetic pen is used for width=1.
  • NativeFont: also accepts "-d"  to show the font-selection dialog box.
  • Font: "Courier" is mapped to "Courier New", "Helvetica" is mapped to "Arial", and "Times" is mapped to "Times New Roman". Underline and Strikeout are supported. The System font does not have orientation.

Client Images

  • PutImageRGBA: Try to use the new GDI function AlphaBlend, if not available captures an image from the canvas to blend it manually.

Colors

  • Palette: is useful only if the device has 256 colors. If it has less than 256 colors, ignore this function, for it will not make much difference. If two different canvases have their palettes modified, the last one to be modified will have the best quality; the other one will not have good quality and the colors might have a completely different appearance.

Exclusive Attributes

  • "HDC": returns the HDC of the Win32 canvas. It can only be retrieved (get only). In Lua is returned as a user data.
  • "PENFILLPOLY": controls the polygon filling outline. Assumes values "1" (active) and "0" (inactive). Default value: "1". When a filled polygon is drawn, a line in the same color is used to draw the border which is not included in the filling. Deactivating this attribute solves the problem of polygons with holes, in which there is a line connecting the external polygon to the internal polygon.
  • "IMAGEFORMAT": defines the number of bits per pixel used to create server images. It uses 1 integer that can have the values: "32" or "24" (%d). Use NULL to remove the attribute. It is used only in the cdCreateImage. When not defined, the server images use the same format of the canvas.
  • "IMAGEALPHA":  allows the usage of an alpha channel for server images if IMAGEFORMAT=32. The attribute format is a pointer to the transparency values in a sequence of chars in the same format of alpha for client images. The attribute is used only in the cdCreateImage and for every cdPutImageRect, the pointer must exists while the image exists. The alpha values are transfered to the image only in cdPutImageRect, so they can be freely changed any time. It will use the AlphaBlend GDI function. The data is not duplicated, only the pointer is stored. The size of the data must be the same size of the image. Use NULL to remove the attribute. Not accessible in Lua.
  • "IMAGEMASK":  defines a binary transparency mask for server images. The format is the same of a stipple, can contain only 0s and 1s. Use 2 integers, width and height, and a char pointer to the mask values inside a string ("%d %d %p"). Use NULL to remove the attribute. It can not be retrieved (set only). Not accessible in Lua. It will use the MaskBlt GDI function.
  • "IMAGEPOINTS":  define 3 coordinates of a paralelogram that will be used to warp server images. Use 6 integer values inside a string ("%d %d %d %d %d %d" = x1 y1 x2 y2 x3 y3). Use NULL to remove the attribute. The respective specified points are the upper-left corner, the upper-right corner and the lower left corner. The drawing is also affected by the "IMAGEMASK" attribute. It will use the PlgBlt GDI function.
  • "ROTATE":  allows the usage of 1 angle and 1 coordinate (x, y), that define a global rotation transformation centered in the specified coordinate. Use 1 real and 2 integer values inside a string ("%g %d %d" = angle x y).