Home  Contents

gcx:save

Graphics Core4 Lua Commands

SYNOPSIS

  1. gcx:save(filename[, ...])
  2. gcx:save(handle, format [, ...])
  3. data = gcx:encode(format [, ...])

  4. gcx:saveat(x, y, width, height, filename[, ...])
  5. gcx:saveat(x, y, width, height, handle, format [, ...])
  6. data = gcx:encodeat(x, y, width, height, format [, ...])

  7. gcx:saveat(rect, filename[, ...])
  8. gcx:saveat(rect, handle, format [, ...])
  9. data = gcx:encodeat(rect, format [, ...])

DESCRIPTION

Save the image contents of the graphics context. The first form saves the data to a file named filename. The file format is automatically detected from the file extension.

The second form saves/sends the image to a file handle (which might be a serial port or network socket). The data format is indicated by the format variable.

The third form encodes the image data and returns it as a string. The data format is also indicated by the format variable.

The other forms allow selecting a specific rectangle out of the source bitmap. This can either be done with integer coordinates and sizes or with a rectangle object.

The format parameter selects the data encoding.

format Description
"FPMRAW" Encode data for immediate printing on a Teratronik HSP (High Speed Printer).
"FPMSTORE" Save data to a Teratronik HSP (High Speed Printer). The image is saved in the printer's image buffer. The image can be printed by following up with the escape sequence 1B 2B 01, possibly after moving the cursor to the right place with 1B 7C xl xh yl yh.
For backward compatibility, the format string "FPM" also selects this option.
"C56RAW" Send data to a Hengstler C56 printer for immediate printing.
"C56STORE" Save data to a Hengstler C56 printer's image buffer in flash memory. The command needs an additional parameter, the unique identification number of the image (1..255).
"X56RAW" Send data to a Hengstler X56 printer for immediate printing.
"X80RAW" Send data to a Hengstler X80 printer for immediate printing.
"PIXI" Send data to a Hengstler PIXI printer for immediate printing.

RETURN VALUE

On success, the first and second forms return true, the third form returns the encoded data. On error, all forms return three values: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

BUGS

This is work in progress. It would be nice to have support for PNG format.

SEE ALSO