Image List

class lwsdk.LWImageList(self)

Bases: object

Proxy of C++ PCore::LWImageList class

 RGB(LWImageID img, int x, int y) → (r, g, b)

Returns a Python tuple containing the red, green and blue values of a pixel as doubles.

 RGBSpot(LWImageID img, double x, double y, double spotSize, int in_blend) → (r, g, b)

Returns Python tuple containing the color values of a spot on the image as doubles. Like LWImageList::lumaSpot(), this function can only be called during the spot evaluation function of a shader.

 alpha(LWImageID img, int x, int y) → LWBufferValue

Returns the alpha value of a pixel.

 alphaSpot(LWImageID img, double x, double y, double spotSize, int in_blend) → double

Returns the alpha value of a spot (see LWImageList::lumaSpot() and LWImageList::RGBSpot()).

 changeEvent(LWImageEventFunc func, int code)

!! NOT IMPLEMENTED !!

 clear(LWImageID img)

Remove the image from the image list. This has the effect of removing all references to the image in the scene.

 create(char name, int width, int height, type) → LWPixmapID

Creates a new image to the image list. The pixmap of the image is returned, which can be used with the Image Utility global. This pixmap should not be destroyed. The type can be any of the pixel types. The created image will be blank. Although the image can be referenced (in for example textures), the contents of the image will not be saved. When the scene is loaded, a blank image will be recreated instead.

The name should be unique. If an image with the given name already exists, the pixmap for the existing image is returned.

The image created in this way could be used as a blank canvas to bake filters, or to create temporary images.

 evaluate(LWImageID img, LWTime t) → LWPixmapID

Returns a pixmap of the image that can be used with the Image Utility global. This function creates a copy of the image, similar to calling LWImageUtil::create() method and then copying the pixels using LWImageList::RGB() and LWImageUtil::setPixel(). But the image is evaluated, meaning that the frame matching the time argument is retrieved for sequences and animations, and any adjustments and filters are applied. The pixmap should not be destroyed. It will be managed by the image editor.

Note that the returned pixmap may become invalid if the image is evaluated again, either by a plugin or the image editor. Evaluate the image just before the pixmap is needed, and do not hold on to it for any length of time (for example, after a plugin returns control back to LightWave).

 filename(LWImageID img, LWFrame frame) → char

Returns the filename of the image. This is the value that should be stored for later retrieval of the image using LWImageList::load().

 first() → LWImageID

Returns the first image in the list.

 hasAlpha(LWImageID img) → int

True if the image includes an alpha channel.

 isColor(LWImageID img) → int

True for images with color data and false for grayscale images.

 load(char filename) → LWImageID

Add the image to the list and return its ID. Animation files can be loaded with this function, but image sequences cannot.

 luma(LWImageID img, int x, int y) → LWBufferValue

Returns the grayscale value of a pixel. If this is a color image (LWImageist::isColor() is true), the value returned is the NTSC/PAL luminance, which combines the RGB levels using the weights 0.2989 red, 0.5866 green, 0.1144 blue.

 lumaSpot(LWImageID img, double x, double y, double spotSize, int in_blend) → double

Returns the grayscale value of a spot on the image. x and y are the center of the spot in pixels, and the spot size is the diameter of the spot in pixel units. The value is the weighted average of the pixels within the spot. If blend is true and the spot size is small, however, the value will be interpolated from neighboring pixels that may be outside the spot. Currently this function can only be called during the spot evaluation function of a shader, and LWImageList::needAA() must have been called previously from the Shader's __init__() method.

 name(LWImageID img) → char

Returns the name of the image as it appears to the user.

 needAA(LWImageID img)

Called by shaders that want to use the LWImageList::lumaSpot() and LWImageList::RGBSpot() method during rendering. This tells Layout to prefilter the image for later spot evaluation. Currently this function can only be called from a Shader's __init__() method.

 next(LWImageID img) → LWImageID

Returns the image after img in the list, or None if img is the last image in the list.

 replace(LWImageID img, char filename) → int

This function will perform an in-place substitution of the specified LWImageID with the image found in the provided filename. If the replacement succeeds, a non-zero value is returned.

 saverNotifyAttach(LWInstance arg1, LWImageSaverNotify arg2)

!! NOT IMPLEMENTED !!

 saverNotifyDetach(LWInstance arg1)

!! NOT IMPLEMENTED !!

 saverNotifyMarkUsage(LWTextureID arg1)

!! NOT IMPLEMENTED !!

 sceneLoad(LWLoadState load) → LWImageID

Read an image reference from a file and add the image to the image list. This is meant to be called by a Handler's inst_load() callback (see Handler Interfaces) to retrieve an image that's part of its instance data. The reference will have been written by sceneSave.

 sceneSave(LWSaveState save, LWImageID img)

Write an image reference to a file. This is meant to be called by a Handler's inst_save() callback (see Handler Interfaces) to store a reference to the image as part of the Handler's instance data.

 size(LWImageID img) → (width, height)

Returns a Python tuple containing the integer width and height of the image, in pixels.

Previous topic

Info Messages

Next topic

Image Utility

This Page