Image Saver Class

Note

These interface classes are not intended for direct usage; rather they should be inherited by your own subclass. (See Anatomy of a LightWave Python Plug-in)

Handler

class lwsdk.IImageSaver

Bases: lwsdk.lwsdk.IHandlerFuncs

Proxy of C++ PCore::IImageSaver class

 done(int arg2) → int

Called when there's no more image data to send. The incoming error code and the outgoing result can be any of the result codes defined below.

 sendLine(int row, PyObject data) → int

Send one scanline from the image. The data argument is a Python sequence, one item per pixel, each in the format specified by the LWImageSaverLocal::type provided to your constructor.

Scanlines are numbered from the top of the image, starting at 0. Savers will receive scanlines in top to bottom order (or bottom to top if they return the lwsdk.IMGF_REVERSE flag in their LWImageSaverLocal::result value). A scanline begins with the leftmost pixel. The structure of the pixel data depends on the LWImageSaverLocal::type code. Returns lwsdk.IPSTAT_OK, or an error code.

 setMap(int arg2, unsigned char arg3)

Set the color of an entry in the color table of an indexed-color image. This may be called any time before the first call to IImageSaver::sendLine(). The index identifies the color table entry, which is numbered from 0 to numcolors - 1.

 setParam(arg2, char arg3) → int

Set other image parameters. In most cases, only one of the two parameter arguments will be used, while the other should be set to 0 by sources and ignored by destinations.

 setSize(int arg2, int arg3)

Set the pixel dimensions of the image. The width and height are the number of pixels in a scanline and the number of scanlines, respectively. This is called before the first call to IImageSaver::sendLine().

Access

class lwsdk.LWImageSaverLocal(*args)

Bases: object

Proxy of C++ PCore::LWImageSaverLocal class

 filename → char

The name of the image file to write.

 flags → int

Set this value to lwsdk.IMGF_REVERSE in your plug-in's constructor if you wish to have scanlines provided in reversse (bottom to top) order, otherwise set it to 0.

 monitor → LWMonitor

An insatnce of the LWMonitor class for displaying the progress of the save to the user. You don't have to use this, but you're encouraged to if your image saving takes an unusual amount of time. This is the same structure returned by the monitor global.

 result → int

Set this to indicate whether the Image Saver plug-in initialized properly in its constructor.

 type → LWImageType

The kind of pixel data to be saved. Pixel types are listed on the Image I/O page. The most common types will be lwsdk.LWIMTYP_RGBAFP for color images, and lwsdk.LWIMTYP_GREYFP for grayscale images. Use this to decide what kind of pixel data you want to receive. If your file format supports 24-bit color and 8-bit grayscale, for example, you would set your image protocol type to lwsdk.LWIMTYP_RGB24 when the local type field contains any of the RGB types, and lwsdk.LWIMTYP_GREY8 when it contained either lwsdk.LWIMTYP_GREYFP or lwsdk.LWIMTYP_GREY8.

Factory

class lwsdk.ImageSaverFactory(name, klass)

Bases: lwsdk.lwsdk.IImageSaverFactory

Default Python Factory for IImageSaverFactory

 create(context, imagesaver_local)
 destroy(instance)

Example

1
2
3
4
5
6
7
8
9
class bob_image_saver(lwsdk.IImageSaver):
    def __init__(self, context, image_saver_local):
        super(bob_image_saver, self).__init__()
[...]
        if image_saver_local.type == lwsdk.LWIMTYP_INDEX8:
            # we don't currently support this
            image_saver_local.result = lwsdk.IPSTAT_FAILED
[...]
ServerRecord = { lwsdk.ImageSaverFactory("LW_PyBobImageSaver(.bob)", bob_image_saver) : ServerTagInfo }

Table Of Contents

Previous topic

Image Loader Class

Next topic

Enviroment Class

This Page