Viskores  1.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
viskores::io::BasePixel< BitDepth, Channels > Class Template Referenceabstract

Base type for more complex pixels (RGB, Greyscale, etc) that describes various values such as bit-depth, channel width, bytes per pixel, and how various data should be polled. More...

#include <PixelTypes.h>

Inheritance diagram for viskores::io::BasePixel< BitDepth, Channels >:
viskores::Vec< ComponentTypeFromSize< BitDepth >::type, Channels >

Public Types

using Superclass = viskores::Vec< typename ComponentTypeFromSize< BitDepth >::type, Channels >
 
using ComponentType = typename Superclass::ComponentType
 
using BaseType = BasePixel< BitDepth, Channels >
 
- Public Types inherited from viskores::Vec< ComponentTypeFromSize< BitDepth >::type, Channels >
using ComponentType = ComponentTypeFromSize< BitDepth >::type
 

Public Member Functions

 BasePixel ()=default
 
 BasePixel (const unsigned char *imageData, const viskores::Id index)
 Fills in this->Components by calling ConstructPixelFromImage. More...
 
virtual ~BasePixel ()=default
 
virtual ComponentType Diff (const BaseType &pixel) const =0
 Calculates this difference between two pixels as a single value. More...
 
virtual viskores::Vec4f_32 ToVec4f () const =0
 Generates a Vec4f_32 from the current data available in the pixel. More...
 
void FillImageAtIndexWithPixel (unsigned char *imageData, const viskores::Id index)
 Takes an output imageData pointer and in index to a location in that dataset and fills in the pixel data at the location. More...
 
- Public Member Functions inherited from viskores::Vec< ComponentTypeFromSize< BitDepth >::type, Channels >
constexpr Vec ()=default
 
void CopyInto (Vec< ComponentTypeFromSize< BitDepth >::type, Size > &dest) const
 

Static Public Member Functions

static constexpr viskores::IdComponent GetBitDepth ()
 

Static Public Attributes

static constexpr viskores::IdComponent BIT_DEPTH = BitDepth
 
static constexpr viskores::IdComponent NUM_BYTES = BitDepth / 8
 
static constexpr viskores::IdComponent MAX_COLOR_VALUE = (1 << BitDepth) - 1
 
static constexpr viskores::IdComponent NUM_CHANNELS = Superclass::NUM_COMPONENTS
 
static constexpr viskores::IdComponent BYTES_PER_PIXEL = NUM_CHANNELS * NUM_BYTES
 
- Static Public Attributes inherited from viskores::Vec< ComponentTypeFromSize< BitDepth >::type, Channels >
static constexpr viskores::IdComponent NUM_COMPONENTS
 

Protected Member Functions

void ConstructPixelFromImage (const unsigned char *imageData, const viskores::Id index)
 Takes an input imageData pointer and an index to a location in that dataset and fills in this->Components correctly using the provided BIT_DEPTH and NUM_CHANNELS. More...
 
virtual void print (std::ostream &os) const =0
 

Friends

std::ostream & operator<< (std::ostream &os, const BaseType &basePixel)
 Implement the << operator for this class type. More...
 

Detailed Description

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
class viskores::io::BasePixel< BitDepth, Channels >

Base type for more complex pixels (RGB, Greyscale, etc) that describes various values such as bit-depth, channel width, bytes per pixel, and how various data should be polled.

BasePixel takes BitDepth and Channels as template parameters. BitDepth describes the number of bits in the pixel, while Channels describes the multiple of bits that are available. BasePixel extends viskores::Vec. The ComponentType is pulled from the ComponentTypeFromSize SFINAE struct defined above. This helps with optimizing the pixel size for a given bit-depth. The Size is pulled from the Channels param.

BasePixel requires BitDepths that are > 8 and powers of 2 at the moment. BitDepths of 4, 2, or 1 bit are not correctly handled at the moment.

BasePixel describes how to populate itself from an unsigned char pointer (assuming that the data stored within the pointer matches the bit-depth and channels described by the BasePixel type), and how to fill in data for an unsigned char pointer. This is mostly useful in serialization and deserialization to various image formats.

Member Typedef Documentation

◆ BaseType

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
using viskores::io::BasePixel< BitDepth, Channels >::BaseType = BasePixel<BitDepth, Channels>

◆ ComponentType

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
using viskores::io::BasePixel< BitDepth, Channels >::ComponentType = typename Superclass::ComponentType

◆ Superclass

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
using viskores::io::BasePixel< BitDepth, Channels >::Superclass = viskores::Vec<typename ComponentTypeFromSize<BitDepth>::type, Channels>

Constructor & Destructor Documentation

◆ BasePixel() [1/2]

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
viskores::io::BasePixel< BitDepth, Channels >::BasePixel ( )
default

◆ BasePixel() [2/2]

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
viskores::io::BasePixel< BitDepth, Channels >::BasePixel ( const unsigned char *  imageData,
const viskores::Id  index 
)
inline

Fills in this->Components by calling ConstructPixelFromImage.

Requires the base vec values to be zeroed out initially.

◆ ~BasePixel()

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
virtual viskores::io::BasePixel< BitDepth, Channels >::~BasePixel ( )
virtualdefault

Member Function Documentation

◆ ConstructPixelFromImage()

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
void viskores::io::BasePixel< BitDepth, Channels >::ConstructPixelFromImage ( const unsigned char *  imageData,
const viskores::Id  index 
)
protected

Takes an input imageData pointer and an index to a location in that dataset and fills in this->Components correctly using the provided BIT_DEPTH and NUM_CHANNELS.

Does NOT 0 out the current Components.

◆ Diff()

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
virtual ComponentType viskores::io::BasePixel< BitDepth, Channels >::Diff ( const BaseType pixel) const
pure virtual

Calculates this difference between two pixels as a single value.

◆ FillImageAtIndexWithPixel()

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
void viskores::io::BasePixel< BitDepth, Channels >::FillImageAtIndexWithPixel ( unsigned char *  imageData,
const viskores::Id  index 
)

Takes an output imageData pointer and in index to a location in that dataset and fills in the pixel data at the location.

Utilizes BIT_DEPTH and NUM_CHANNELS to fill in multiple bytes worth of data if necessary.

◆ GetBitDepth()

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
static constexpr viskores::IdComponent viskores::io::BasePixel< BitDepth, Channels >::GetBitDepth ( )
inlinestaticconstexpr

◆ print()

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
virtual void viskores::io::BasePixel< BitDepth, Channels >::print ( std::ostream &  os) const
protectedpure virtual

◆ ToVec4f()

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
virtual viskores::Vec4f_32 viskores::io::BasePixel< BitDepth, Channels >::ToVec4f ( ) const
pure virtual

Generates a Vec4f_32 from the current data available in the pixel.

Friends And Related Function Documentation

◆ operator<<

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
std::ostream& operator<< ( std::ostream &  os,
const BaseType basePixel 
)
friend

Implement the << operator for this class type.

Will call the overloaded print method for the subclassed type.

Member Data Documentation

◆ BIT_DEPTH

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
constexpr viskores::IdComponent viskores::io::BasePixel< BitDepth, Channels >::BIT_DEPTH = BitDepth
staticconstexpr

◆ BYTES_PER_PIXEL

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
constexpr viskores::IdComponent viskores::io::BasePixel< BitDepth, Channels >::BYTES_PER_PIXEL = NUM_CHANNELS * NUM_BYTES
staticconstexpr

◆ MAX_COLOR_VALUE

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
constexpr viskores::IdComponent viskores::io::BasePixel< BitDepth, Channels >::MAX_COLOR_VALUE = (1 << BitDepth) - 1
staticconstexpr

◆ NUM_BYTES

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
constexpr viskores::IdComponent viskores::io::BasePixel< BitDepth, Channels >::NUM_BYTES = BitDepth / 8
staticconstexpr

◆ NUM_CHANNELS

template<const viskores::Id BitDepth, const viskores::IdComponent Channels>
constexpr viskores::IdComponent viskores::io::BasePixel< BitDepth, Channels >::NUM_CHANNELS = Superclass::NUM_COMPONENTS
staticconstexpr

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