Class Image¶
Defined in File point_viz.h
Class Documentation¶
-
class Image¶
Manages the state of an image.
Public Functions
-
Image()¶
-
void update_from(const Image &other)¶
Updates this image’s state with the state of other, accounting for prior changes to this objects’s state.
- Parameters:
other[in] the object to update the state from.
-
void clear()¶
Clear dirty flags.
Resets any changes since the last call to PointViz::update()
-
void dirty()¶
Set all dirty flags.
Re-sets everything so the object is always redrawn.
-
void set_image(size_t width, size_t height, const float *image_data)¶
Set the image data.
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
image_data[in] pointer to an array of width * height elements interpreted as a row-major monochrome image
-
void set_image(size_t width, size_t height, const uint8_t *image_data)¶
Set the image data.
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
image_data[in] pointer to an array of width * height elements interpreted as a row-major monochrome image
-
void set_image_rgb(size_t width, size_t height, const float *image_data_rgb)¶
Set the image data (RGB).
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
image_data_rgb[in] pointer to an array of width * height elements interpreted as a row-major RGB image
-
void set_image_rgb(size_t width, size_t height, const uint8_t *image_data_rgb)¶
Set the image data (RGB).
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
image_data_rgb[in] pointer to an array of width * height elements interpreted as a row-major RGB image
-
void set_image_rgba(size_t width, size_t height, const float *image_data_rgba)¶
Set the image data (RGBA).
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
image_data_rgba[in] pointer to an array of width * height elements interpreted as a row-major RGBA image
-
void set_image_rgba(size_t width, size_t height, const uint8_t *image_data_rgba)¶
Set the image data (RGBA).
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
image_data_rgba[in] pointer to an array of width * height elements interpreted as a row-major RGBA image
-
void set_mask(size_t width, size_t height, const float *mask_data)¶
Set the RGBA mask.
Not required to be the same resolution as the image data
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
mask_data[in] pointer to array of 4 * width * height elements interpreted as a row-major rgba image
-
void set_mask(size_t width, size_t height, const uint8_t *mask_data)¶
Set the RGBA mask.
Not required to be the same resolution as the image data
- Parameters:
width[in] width of the image data in pixels
height[in] height of the image data in pixels
mask_data[in] pointer to array of 4 * width * height elements interpreted as a row-major rgba image
-
void set_position(float x_min, float x_max, float y_min, float y_max)¶
Set the display position of the image.
- Parameters:
x_min[in]
x_max[in]
y_min[in]
y_max –
-
void set_hshift(float hshift)¶
Set horizontal shift in normalized viewport screen width coordinate.
This may be used to “snap” images to the left/right screen edges.
Some example values: 0 - default, image is centered horizontally on the screen -0.5 - image moved to the left for the 1/4 of a horizontal viewport -1 - image moved to the left for the 1/2 of a horizontal viewport +1 - image moved to the right for the 1/2 of a horizontal viewport +0.5 - image moved to the right for the 1/4 of a horizontal viewport
- Parameters:
hshift[in] shift in normalized by width coordinates from 0 at the center [-1.0..1.0]
-
void set_palette(const float *palette, size_t palette_size)¶
Set the image color palette.
- Parameters:
palette[in] the new palette to use, must have size 3*palette_size
palette_size[in] the number of colors in the new palette
-
void clear_palette()¶
Removes the image color palette.
-
std::pair<int, int> viewport_coordinates_to_image_pixel(const WindowCtx &ctx, double x, double y) const¶
Returns the image pixel corresponding to the provided viewport coordinates.
- Parameters:
ctx[in] the WindowCtx.
x[in] X coordinate for the viewport
y[in] Y coordinate for the viewport
- Throws:
std::runtime_error – if the image data has not been set, or if the image size (set by set_position) is zero in either dimension.
- Returns:
Image pixel corresponding to the provided viewport coordinates. IMPORTANT: the pixel is outside the image if either the (x, y) are less than zero or greater than the image (width, height).
-
std::pair<double, double> image_pixel_to_viewport_coordinates(const WindowCtx &ctx, int px, int py) const¶
Returns the inverse of “viewport_coordinates_to_image_pixel” This is useful for computing positions relative to an image pixel.
- Parameters:
ctx[in] the WindowCtx.
px[in] X pixel coordinate
py[in] Y pixel coordinate
- Returns:
a coordinate normalized to -1, 1 in the window’s Y axis
Friends
- friend class impl::GLImage
- friend class PointViz
-
Image()¶