Lagrange
RawInputImage Class Reference

RawInputImage holds the basic info and the raw pointer (without ownership) to the image pixels. More...

#include <lagrange/image/RawInputImage.h>

Classes

struct  PixelTraits
 
struct  PixelTraits< Scalar, 1 >
 

Public Types

enum class  precision_semantic : uint32_t { byte_p , half_p , single_p , double_p }
 
enum class  color_space : uint32_t { linear , sRGB }
 
enum class  texture_format : uint32_t {
  luminance = ((1) << 8) | 0x0 , luminance_alpha = ((2) << 8) | 0x1 , alpha_luminance = ((2) << 8) | 0x2 , rgb = ((3) << 8) | 0x4 ,
  bgr = ((3) << 8) | 0x8 , rgba = ((4) << 8) | 0x10 , argb = ((4) << 8) | 0x12 , bgra = ((4) << 8) | 0x14 ,
  max = ((4) << 8) | ((1 << 8) - 1)
}
 
enum class  image_storage_format : uint32_t { first_pixel_row_at_bottom , first_pixel_row_at_top }
 first_pixel_row_at_bottom: y is up (like OpenGL texcoords) first_pixel_row_at_top: y is down just like most image file formats More...
 
enum class  wrap_mode : uint32_t { repeat , clamp , mirror }
 
enum class  texture_filtering : uint32_t { nearest , bilinear }
 

Public Member Functions

size_t get_width () const
 
size_t get_height () const
 
size_t get_row_byte_stride () const
 
precision_semantic get_pixel_precision () const
 
color_space get_color_space () const
 
texture_format get_tex_format () const
 
wrap_mode get_wrap_u () const
 
wrap_mode get_wrap_v () const
 
image_storage_format get_storage_format () const
 
size_t get_size_precision () const
 
size_t get_num_channels () const
 
size_t get_size_pixel () const
 
size_t get_row_stride () const
 
size_t get_pixel_data_offset () const
 
const void * get_pixel_data () const
 
void set_width (size_t x)
 
void set_height (size_t x)
 
void set_row_byte_stride (size_t x)
 
void set_pixel_precision (precision_semantic x)
 
void set_color_space (color_space x)
 
void set_tex_format (texture_format x)
 
void set_wrap_u (wrap_mode x)
 
void set_wrap_v (wrap_mode x)
 
void set_storage_format (image_storage_format x)
 
void set_pixel_data (const void *pixel_data, const bool copy_to_local)
 set_pixel_data must be called all other member variables are well set if copy_to_local == false: m_local_pixel_data empty m_pixel_data points to the external pixel_data else: external pixel_data are copied to m_local_pixel_data m_pixel_data is nullptr
 
void set_pixel_data_buffer (std::vector< unsigned char > pixel_data_buffer)
 m_local_pixel_data takes over pixel_data_buffer m_pixel_data is set to nullptr
 
bool operator== (const RawInputImage &other) const
 
bool operator!= (const RawInputImage &other) const
 
template<typename TexcoordScalar , typename Scalar , uint32_t NumChannels>
PixelTraits< Scalar, NumChannels >::Pixel sample (const TexcoordScalar u, const TexcoordScalar v, const texture_filtering filtering=texture_filtering::bilinear) const
 Sample an image at a given location. More...
 
template<typename TexcoordScalar , typename Scalar , uint32_t NumChannels>
PixelTraits< Scalar, NumChannels >::Pixel sample_float (const TexcoordScalar u, const TexcoordScalar v, const texture_filtering filtering=texture_filtering::bilinear) const
 Similar to sample, but remaps the output values from [0, 255] to [0, 1] if the pixel data is stored as 8-bit integers. More...
 
template<typename Archive >
void serialize_impl (Archive &ar)
 Serialization. More...
 

Protected Member Functions

template<typename TexcoordScalar , typename Scalar , uint32_t NumChannels, typename InternalScalar , uint32_t InternalNumChannels>
PixelTraits< Scalar, NumChannels >::Pixel sample (const TexcoordScalar u, const TexcoordScalar v, const texture_filtering filtering=texture_filtering::bilinear) const
 

Protected Attributes

size_t m_width = 0
 
size_t m_height = 0
 
size_t m_row_byte_stride = 0
 
precision_semantic m_pixel_precision = precision_semantic::single_p
 
color_space m_color_space = color_space::linear
 
texture_format m_tex_format = texture_format::rgba
 
wrap_mode m_wrap_u = wrap_mode::clamp
 
wrap_mode m_wrap_v = wrap_mode::clamp
 
image_storage_format m_storage_format = image_storage_format::first_pixel_row_at_top
 
const void * m_pixel_data = nullptr
 Raw pixel data pointer. Assumed ownership by host, host's responsibility to keep it valid as long as Lagrange has access to it.
 
std::vector< unsigned char > m_local_pixel_data
 

Detailed Description

RawInputImage holds the basic info and the raw pointer (without ownership) to the image pixels.

  • there are not paddings inner or inter pixels
  • there may be paddings between rows
  • m_row_byte_stride can be zero, when there are not paddings between rows, the row stride can be calculated according to m_pixel_precision, m_tex_format and m_width
  • the memory of pixels is always with the top-down layout if m_storage_format is image_storage_format::first_pixel_row_at_top get_pixel_data points to the beginning of the memory block if m_storage_format is image_storage_format::first_pixel_row_at_bottom get_pixel_data points to the beginning of the bottom row
  • get_pixel_data can pointer to external memory without ownership, or inside m_local_pixel_data with ownership if set_pixel_data(*, false), m_pixel_data points to external memory, m_local_pixel_data is empty if set_pixel_data(*, true), m_pixel_data is nullptr, m_local_pixel_data holds the pixels

Member Enumeration Documentation

◆ precision_semantic

enum class precision_semantic : uint32_t
strong
Enumerator
byte_p 

8-bit uint8_t

half_p 

16-bit floating point

single_p 

32-bit floating point

double_p 

64-bit floating point

◆ color_space

enum class color_space : uint32_t
strong
Enumerator
linear 

pixel format is in linear space

sRGB 

pixel format is in sRGB space

◆ texture_format

enum class texture_format : uint32_t
strong
Enumerator
argb 

suboptimal format

bgra 

suboptimal format

◆ image_storage_format

enum class image_storage_format : uint32_t
strong

first_pixel_row_at_bottom: y is up (like OpenGL texcoords) first_pixel_row_at_top: y is down just like most image file formats

Enumerator
first_pixel_row_at_bottom 

+y up

first_pixel_row_at_top 

+y down

◆ wrap_mode

enum class wrap_mode : uint32_t
strong
Enumerator
repeat 

tiles the texture

clamp 

clamp to the last pixel on the edge

mirror 

tiles the texture, mirrored when the integer coord is odd

◆ texture_filtering

enum class texture_filtering : uint32_t
strong
Enumerator
nearest 

nearest neighbor interpolation

bilinear 

bilinear interpolation

Member Function Documentation

◆ sample()

RawInputImage::PixelTraits< Scalar, NumChannels >::Pixel sample ( const TexcoordScalar  u,
const TexcoordScalar  v,
const texture_filtering  filtering = texture_filtering::bilinear 
) const

Sample an image at a given location.

Parameters
[in]uFirst sampling coordinate.
[in]vSecond sampling coordinate.
[in]filteringFiltering scheme (nearest or bilinear).
Template Parameters
TexcoordScalarTexture coordinate type.
ScalarPixel scalar type.
NumChannelsNumber of color channels in the pixel.
Returns
Pixel data.

◆ sample_float()

RawInputImage::PixelTraits< Scalar, NumChannels >::Pixel sample_float ( const TexcoordScalar  u,
const TexcoordScalar  v,
const texture_filtering  filtering = texture_filtering::bilinear 
) const

Similar to sample, but remaps the output values from [0, 255] to [0, 1] if the pixel data is stored as 8-bit integers.

Parameters
[in]uFirst sampling coordinate.
[in]vSecond sampling coordinate.
[in]filteringFiltering scheme (nearest or bilinear).
Template Parameters
TexcoordScalarTexture coordinate type.
ScalarPixel scalar type. Must be a floating point type.
NumChannelsNumber of color channels in the pixel.
Returns
Pixel data.

◆ serialize_impl()

void serialize_impl ( Archive &  ar)
inline

Serialization.

Serialization implementation.

Caution: TessellationOptions::facet_budget_callback is not serialized


The documentation for this class was generated from the following files: