Struct vfxpreopenexr::flat::flat_image::FlatImage[][src]

#[repr(transparent)]
pub struct FlatImage(_);
Expand description

An in-memory data structure that can hold an arbitrary OpenEXR image with one or multiple resolution levels, and with an arbitrary set of channels.

An image is a container for a set of image levels, and an image level is a container for a set of image channels. An image channel contains an array of pixel values of type f16, f32 or u32.

For example:

    image ──┬── level 0 ──┬── channel "R" ─── pixel data
            │             │
            │             ├── channel "G" ─── pixel data
            │             │
            │             └── channel "B" ─── pixel data
            │
            ├── level 1 ──┬── channel "R" ─── pixel data
            │             │
            │             ├── channel "G" ─── pixel data
            │             │
            │             └── channel "B" ─── pixel data
            │
            └── level 2 ──┬── channel "R" ─── pixel data
                          │
                          ├── channel "G" ─── pixel data
                          │
                          └── channel "B" ─── pixel data

An image has a level mode, which can be LevelMode::OneLevel, LevelMode::MipmapLevels or LevelMode::RipmapLevels, and a level rounding mode, which can be LevelRoundingMode::RoundUp or LevelRoundingMode::RoundDown. Together, the level mode and the level rounding mode determine how many levels an image contains, and how large the data window for each level is. All levels in an image have the same set of channels.

An image channel has a name (e.g. “R”, “Z”, or “xVelocity”), a type (CHANNEL_HALF, CHANNEL_FLOAT or CHANNEL_UINT) and x and y sampling rates. A channel stores samples for a pixel if the pixel is inside the data window of the level to which the channel belongs, and the x and y coordinates of the pixel are divisible by the x and y sampling rates of the channel.

In a flat image each channel in each level stores at most one value per pixel.

Implementations

Constructs a new FlatImage with the given data_window, level_mode and level_rounding_mode

Errors

Get the level mode

Get the level rounding mode

Get the number of levels in the image.

This is a convenience function for use with mipmaps, in which case this function is equivalent to num_x_levels().

If this image’s level mode is LevelMode::RipmapLevels, you must call num_x_levels() or num_y_levels instead.

Errors

Returns the image’s number of levels in the x direction.

Returns

Where:

Returns the image’s number of levels in the y direction.

Returns

Where:

Returns the data window for the whole image.

Equivalent to data_window_for_level(0, 0).

Returns the data window for the image at level (lx, ly).

That is, the window for which the image level with level number (lx, ly) has allocated pixel storage.

Returns

A reference to a Bound2<i32> with min value (dataWindow().min.x, dataWindow().min.y) and max value (dataWindow().min.x + levelWidth(lx) - 1, dataWindow().min.y + levelHeight(ly) - 1)

Errors

Returns the width of a level with level number (lx, *), where * is any number.

Returns

max (1, rfunc (w / pow (2, lx)))

Errors

Returns the height of a level with level number (*, ly), where * is any number.

Returns

max (1, rfunc (y / pow (2, ly)))

Errors

Resize the image.

Sets the data window of the image to dw, sets the level mode to lm and the level rounding mode to lrm, and allocates new storage for image levels and image channels. The set of channels in the image does not change.

The contents of the image are lost; pixel data are not preserved across the resize operation. If resizing fails, then the image will be left with an empty data window and no image levels.

Errors

*Error::Base - if any error occurs. The image will be set to empty in this case.

Shift the pixels and the data window of an image.

Shifts the image by dx pixels horizontally and dy pixels vertically.
A pixel at location (x,y) moves to position (x+dx, y+dy). The data window of the image is shifted along with the pixels. No pixel data are lost.

The horizontal and vertical shift distances must be multiples of the x and y sampling rates of all image channels. If they are not, Error::InvalidArgument is returned and this method has no effect.

Insert a new channel into the image.

The arguments to this function are the same as for adding a a channel to a Header: channel name, x and y sampling rates, and a “perceptually approximately linear” flag.

If the image already contains a channel with the same name as the new name then the existing channel is deleted before the new channel is added.

Errors

Erase the channel name from the image

If no channel called name is in the image, this method has no effect.

Erase all channels from the image.

Rename the channel old_name to have the name new_name

Errors

Error::InvalidArgument - if a channel called new_name already exists, or if no channel named old_name exists. Error::OutOfMemory - if allocation fails, in which case the channel being renamed is erased.

Access image level with number (lx, ly)

Errors

Access image level with number (lx, ly) as a mutable ref.

Errors

Trait Implementations

Constructs a FlatImage with an empty data window, LevelMode::OneLevel level and LevelRoundingMode::RoundDown

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.