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
Error::Base
- if any error occurs
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
Error::LogicError
- if this image’s level mode isLevelMode::RipmapLevels
Returns the image’s number of levels in the x direction.
Returns
1
iflevel_mode()
isLevelMode::OneLevel
rfunc(log(max(w, h)) / log(2)) + 1
iflevel_mode()
isLevelMode::MipmapLevels
rfunc(log(w) / log(2)) + 1
iflevel_mode()
isLevelMode::RipmapLevels
Where:
w
is the width of the image’s data window, max.x - min.x + 1,h
is the height of the image’s data window, max.y - min.y + 1,- and
rfunc(x)
is eitherfloor(x)
, orceil(x)
, depending on whetherlevel_rounding_mode()
returnsLevelRoundingMode::RoundDown
orLevelRoundingMode::RoundUp
.
Returns the image’s number of levels in the y direction.
Returns
- Same as
num_x_levels()
iflevel_mode()
isLevelMode::OneLevel
orLevelMode::MipmapLevels
rfunc(log(h) / log(2)) + 1
iflevel_mode()
isLevelMode::RipmapLevels
Where:
h
is the height of the image’s data window, max.y - min.y + 1,- and
rfunc(x)
is eitherfloor(x)
, orceil(x)
, depending on whetherlevel_rounding_mode()
returnsLevelRoundingMode::RoundDown
orLevelRoundingMode::RoundUp
.
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
Error::InvalidArgument
- if(lx, ly)
does not correspond to a valid image level.
Returns the width of a level with level number (lx, *), where * is any number.
Returns
max (1, rfunc (w / pow (2, lx)))
Errors
Error::InvalidArgument
- iflx
is not a valid level number
Returns the height of a level with level number (*, ly), where * is any number.
Returns
max (1, rfunc (y / pow (2, ly)))
Errors
Error::InvalidArgument
- ifly
is not a valid level number
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
Error::Base
- if any error occurs
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
Error::InvalidArgument
- if(lx, ly
) does not refer to a valid image level.
Access image level with number (lx, ly)
as a mutable ref.
Errors
Error::InvalidArgument
- if(lx, ly
) does not refer to a valid image level.
Trait Implementations
Constructs a FlatImage
with an empty data window, LevelMode::OneLevel
level and
LevelRoundingMode::RoundDown
type SysPointee = Imf_FlatImage_t
Auto Trait Implementations
impl RefUnwindSafe for FlatImage
impl UnwindSafe for FlatImage