Server Images

It is a high performance image compatible with a specific canvas. It is faster than user image functions, but less flexible. It is commonly used for off-screen drawing in Window Systems.

You can make gets and puts on several canvases but they must be created using the same driver. It is possible to specify a part of the image to be drawn, but it is not possible to zoom.

It is called "server" images because the data is stored in a system private format, that the application (or the client) does not have access.

To create a server image there must be an active canvas of a driver with server image support. Only the base drivers Win32, Direct2D, GDI+, X-Windows, XRender and Cairo, support server images.


cdImage* cdCanvasCreateImage(cdCanvas* canvas, int w, int h); [in C]

canvas:CreateImage(w, h: number) -> (image: cdImage) [in Lua]

Creates a compatible image with size = w x h pixels. A compatible image has the same color representation (number of bits per pixel) of the active canvas. Once the server image is created it is independent of the active canvas. The server image can only be used with an other canvas of the same type as the canvas that was active when the image was created. The default background is the same as the canvas, CD_WHITE.

void cdKillImage(cdImage* image); [in C]

image:KillImage() [in Lua]

Liberates memory allocated for the image. If this function is not called in Lua, the garbage collector will call it.

void cdCanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y); [in C]

canvas:GetImage(image: cdImage; x, y: number) [in Lua]

Copies a rectangular region from the current rectangular context to the memory (image). (x,y) is the coordinate of the bottom left corner of the rectangular region. The width and height of the rectangular region are defined in the image structure (when the image is created).

void cdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax); [in C]
void wdCanvasPutImageRect(cdCanvas* canvas, cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax); (WC) [in C]

canvas:PutImageRect(image: cdImage; x, y, xmin, xmax, ymin, ymax: number) [in Lua]
canvas:wPutImageRect(image: cdImage; x, y, xmin, xmax, ymin, ymax: number) (WC) [in Lua]

Copies an image in a rectangular region of the canvas with the bottom left corner in (x,y). Allows specifying a rectangle inside the image to be drawn, if xmin, xmax, ymin and ymax are 0, then the whole image is assumed.

void cdCanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy); [in C]

canvas:ScrollArea(xmin, xmax, ymin, ymax, dx, dy: number) [in Lua]

Copies the rectangle defined by the coordinates (xmin,ymin) and (xmax,ymax) to the rectangle defined by (xmin+dx,ymin+dy) and (xmax+dx,ymax+dy). It has the same effect as cdGetImage followed by cdPutImage, but it should be faster and does not require the explicit creation of an image to be executed. Note that the region belonging to the first rectangle, but not to the second, remains unchanged (the function does not clean this region).