Image Loader 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.IImageLoader

Bases: lwsdk.lwsdk.IHandlerFuncs

Proxy of C++ PCore::IImageLoader class

 process(LWImageLoaderLocal access) → int

This is the main entry point for all Image Loader plug-ins. It provides an instance of the LWImageLoaderLocal class (described below).

Access

class lwsdk.LWImageLoaderLocal(*args)

Bases: object

Proxy of C++ PCore::LWImageLoaderLocal class

 begin(void arg1, arg2) → LWImageProtocol

Call this when you're ready to begin sending image data to LightWave. This will be after you've opened and examined the image file and know what it contains. The pixel type code in arg2 tells LightWave what kind of pixel data you will be sending, and this will in general depend on what kind of pixel data the file contains, although it doesn't have to. Pixel type codes are listed on the Image I/O page.

The LWImageLoaderLocal::begin() method returns an instance of a LWImageProtocol, which is what you'll use to actually transfer the image data. (See the example Image Loader Python scripts.) If you call LWImageLoaderLocal::begin(), you must also be sure to call LWImageLoaderLocal::done() so that LightWave can free resources associated with the LWImageProtocol instance it allocated for you.

 done(void arg1, LWImageProtocol arg2)

Completes the image loading process. The protocol is the LWImageProtocolID returned by LWImageLoaderLocal::begin(). Only call LWImageLoaderLocal::done() if you previously called LWImageLoaderLocal::begin().

 filename → char

The name of the file to load.

 monitor → LWMonitor

The loader can use this LWMonitor class instance to update the user about its progress through the frame. You don't have to use this, but you're encouraged to if your image loading takes an unusual amount of time.

 priv_data → void

Pass this as the first argument to the begin and done functions. It's an opaque pointer to data used internally by LightWave.

 result → int

Set this to indicate whether the image was loaded successfully. See the imgload.html file in the LWSDK for possible result codes.

Factory

class lwsdk.ImageLoaderFactory(name, klass)

Bases: lwsdk.lwsdk.IImageLoaderFactory

Default Python Factory for IImageLoaderFactory

 create(context)
 destroy(instance)

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class ascii_image(lwsdk.IImageLoader):
    def __init__(self, context):
        super(ascii_image, self).__init__()

    # LWImageLoader -------------------------------------------
    def process(self, loader_access):
        loader_access.result = lwsdk.IPSTAT_BADFILE

        # open and process 'filename'

        if os.path.exists(loader_access.filename) and \
           (loader_access.filename.endswith('.txt') or loader_access.filename.endswith('.asc')):
[...]
ServerRecord = { lwsdk.ImageLoaderFactory("LW_PyASCIIImage", ascii_image) : ServerTagInfo }

Table Of Contents

Previous topic

Command Sequence Class

Next topic

Image Saver Class

This Page