Function qtwidget.newimage creates an image in memory
that can be the target of drawing operations.
This function returns a Lua table that
serves as a drawing port descriptor.
There are several ways to specify its arguments:
qtwidget.newimage(w,h,[monoflag])
Creates an image of width w and height h.
When the optional argument monoflag is true,
a bitonal image is created.
Otherwise the image can contain arbitrary RGBA colors.
qtwidget.newimage(filename,[format])
Creates an image by loading the contents of file filename.
The file format is defined by the optional string argument format
or derived from the file name extension.
qtwidget.newimage(torchtensor)
Creates an image by extracting the contents of the specified
torch.Tensor.
The valid tensor formats are described in the documentation for function
qt.QImage.fromTensor.
This only works when both packages torch
and qttorch have been loaded.