template<class T>
image_t class
storage class for image data in cpu memory.
Template parameters | |
---|---|
T | pixel format |
The image_
Public types
-
using const_iterator = typename std::
vector<value_ type>::const_ iterator - const iterator type
-
using iterator = typename std::
vector<value_ type>::iterator - iterator type
- using value_type = T
- type alias value_type
Constructors, destructors, conversion operators
- image_t() defaulted constexpr
- default constructor
-
image_t(const image_
t& cpy) defaulted constexpr - copy constructor
-
image_t(image_
t&& mov) defaulted constexpr noexcept - move constructor
-
template<class U>image_t(const image_
t<U>& conv) explicit constexpr - conversion operator
- image_t(size_t width, size_t height) constexpr
- constructor with dimensions
-
image_t(size_t width,
size_t height,
const value_
type value) constexpr - constructor with dimensions and default value
-
image_t(size_t width,
size_t height,
const value_
type* begin) constexpr - constructor with dimensions and pointer to buffer
-
image_t(size_t width,
size_t height,
std::
initializer_list<T> init_list) constexpr - constructor with dimensions and initializer_list
-
template<class Range, std::image_t(size_t width, size_t height, const Range& range) constexpr
enable_if_t<std:: is_same_v<typename Range::value_type, value_ type>, int> = 0> - constructor with dimensions and generic container reference
-
template<class Iterator, std::image_t(size_t width, size_t height, const Iterator& begin, const Iterator& end) constexpr
enable_if_t<std:: is_same_v<typename std:: iterator_traits<Iterator>::value_ type, value_ type>, int> = 0> - constructor with dimensions and iterator range
- image_t(const char* filename)
- construct image_
t from file
Public functions
-
auto at(size_t x,
size_t y) -> value_
type& constexpr - get pixel
-
auto at(size_t x,
size_t y) const -> constvalue_
type& constexpr - get pixel
- auto begin() -> iterator constexpr noexcept
- get iterator to pixel data
-
auto begin() const -> const_
iterator constexpr noexcept - get iterator to pixel data
- auto channels() const -> int constexpr noexcept
- get number of color channels
- auto data() -> T* constexpr noexcept
- pointer to pixel data
- auto data() const -> const T* constexpr noexcept
- pointer to pixel data
- auto end() -> iterator constexpr noexcept
- get iterator to end of pixel data
-
auto end() const -> const_
iterator constexpr noexcept - get iterator to end of pixel data
-
auto format() const -> image_
format_ t constexpr noexcept - get image format
-
auto get(size_t x,
size_t y) -> value_
type& constexpr - get pixel
-
auto get(size_t x,
size_t y) const -> constvalue_
type& constexpr - get pixel
- auto height() const -> size_t constexpr noexcept
- get height
- void load(const char* filename)
- load an image from file
-
auto operator=(const image_
t& cpy) -> image_ t& defaulted constexpr - copy assigment operator
-
auto operator=(image_
t&& mov) -> image_ t& defaulted constexpr noexcept - move assignment operator
-
auto resize(size_t width,
size_t height) const -> image_
t - resize image
- auto size() const -> size_t constexpr noexcept
- get size
- auto type() const -> GLenum constexpr noexcept
- get base type
-
auto update(size_t x,
size_t y,
const image_
t<T>& update) -> image_ t& constexpr noexcept - update subimage
- auto width() const -> size_t constexpr noexcept
- get width
- void write(const char* filename) const
- write image to file
Function documentation
template<class T>
glpp:: core:: object:: image_t<T>:: image_t() defaulted constexpr
default constructor
The default constructor will create an empty image with the dimensions [0, 0].
template<class T>
template<class U>
glpp:: core:: object:: image_t<T>:: image_t(const image_ t<U>& conv) explicit constexpr
template<class U>
conversion operator
Parameters | |
---|---|
conv | [in] image_ |
The convertion operator will initialise the image_
template<class T>
glpp:: core:: object:: image_t<T>:: image_t(size_t width,
size_t height) constexpr
constructor with dimensions
Parameters | |
---|---|
width | [in] new width of image_ |
height | [in] new height of image_ |
This constructor will initialise a image_
template<class T>
glpp:: core:: object:: image_t<T>:: image_t(size_t width,
size_t height,
const value_ type value) constexpr
constructor with dimensions and default value
Parameters | |
---|---|
width | [in] new width of image_ |
height | [in] new height of image_ |
value | [in] default value for pixel data |
This constructor will initialise a image_
template<class T>
glpp:: core:: object:: image_t<T>:: image_t(size_t width,
size_t height,
const value_ type* begin) constexpr
constructor with dimensions and pointer to buffer
Parameters | |
---|---|
width | [in] new width of image_ |
height | [in] new height of image_ |
begin | [in] pointer to pixel data |
This constructor will initialise a image_
template<class T>
glpp:: core:: object:: image_t<T>:: image_t(size_t width,
size_t height,
std:: initializer_list<T> init_list) constexpr
constructor with dimensions and initializer_list
Parameters | |
---|---|
width | [in] new width of image_ |
height | [in] new height of image_ |
init_list | [in] initializer_list with values |
This constructor will initialise a image_
template<class T>
template<class Range, std:: enable_if_t<std:: is_same_v<typename Range::value_type, value_ type>, int> = 0>
glpp:: core:: object:: image_t<T>:: image_t(size_t width,
size_t height,
const Range& range) constexpr
template<class Range, std::
constructor with dimensions and generic container reference
Parameters | |
---|---|
width | [in] new width of image_ |
height | [in] new height of image_ |
range | [in] container with pixel data |
This constructor will initialise a image_
template<class T>
template<class Iterator, std:: enable_if_t<std:: is_same_v<typename std:: iterator_traits<Iterator>::value_ type, value_ type>, int> = 0>
glpp:: core:: object:: image_t<T>:: image_t(size_t width,
size_t height,
const Iterator& begin,
const Iterator& end) constexpr
template<class Iterator, std::
constructor with dimensions and iterator range
Parameters | |
---|---|
width | [in] new width of image_ |
height | [in] new height of image_ |
begin | [in] begin of init range |
end | [in] end of init range |
This constructor will initialise a image_
template<class T>
glpp:: core:: object:: image_t<T>:: image_t(const char* filename)
construct image_
Parameters | |
---|---|
filename | [in] name or path of file to load |
This constructor will load a image from file. The width and height is fetched from the file. If the pixel format of the file does not match the one of the image_
template<class T>
value_ type& glpp:: core:: object:: image_t<T>:: at(size_t x,
size_t y) constexpr
get pixel
Parameters | |
---|---|
x | [in] x coordinate of pixel to fetch |
y | [in] y coordinate of pixel to fetch |
Get reference the data of a single pixel. This function will perform bounds checking and throw if x and y are no valid coordinates with respect to the image.
template<class T>
constvalue_ type& glpp:: core:: object:: image_t<T>:: at(size_t x,
size_t y) const constexpr
get pixel
Parameters | |
---|---|
x | [in] x coordinate of pixel to fetch |
y | [in] y coordinate of pixel to fetch |
Get reference the data of a single pixel. This function will perform bounds checking and throw if x and y are no valid coordinates with respect to the image.
template<class T>
const_ iterator glpp:: core:: object:: image_t<T>:: begin() const constexpr noexcept
get iterator to pixel data
Returns random access iterator to the first pixel in the image.
template<class T>
int glpp:: core:: object:: image_t<T>:: channels() const constexpr noexcept
get number of color channels
Returns the number of color channels present in the picture. Can be 1, 2, 3 or 4.
template<class T>
T* glpp:: core:: object:: image_t<T>:: data() constexpr noexcept
pointer to pixel data
Returns a pointer to the underlying memory of the pixel data.
template<class T>
const T* glpp:: core:: object:: image_t<T>:: data() const constexpr noexcept
pointer to pixel data
Returns a pointer to the underlying memory of the pixel data.
template<class T>
const_ iterator glpp:: core:: object:: image_t<T>:: end() const constexpr noexcept
get iterator to end of pixel data
Returns iterator referring to the past-the-end pixel of the image.
template<class T>
image_ format_ t glpp:: core:: object:: image_t<T>:: format() const constexpr noexcept
get image format
Returns the format description value of the used pixel format.
template<class T>
value_ type& glpp:: core:: object:: image_t<T>:: get(size_t x,
size_t y) constexpr
get pixel
Parameters | |
---|---|
x | [in] x coordinate of pixel to fetch |
y | [in] y coordinate of pixel to fetch |
Get reference the data of a single pixel.
template<class T>
constvalue_ type& glpp:: core:: object:: image_t<T>:: get(size_t x,
size_t y) const constexpr
get pixel
Parameters | |
---|---|
x | [in] x coordinate of pixel to fetch |
y | [in] y coordinate of pixel to fetch |
Get reference the data of a single pixel.
template<class T>
void glpp:: core:: object:: image_t<T>:: load(const char* filename)
load an image from file
Parameters | |
---|---|
filename | [in] name or path of file to load |
This function will load a image from file and overwrite the members of this class. The width and height is fetched from the file. If the pixel format of the file does not match the one of the image_
template<class T>
image_ t& glpp:: core:: object:: image_t<T>:: operator=(image_ t&& mov) defaulted constexpr noexcept
move assignment operator
The image_
template<class T>
image_ t glpp:: core:: object:: image_t<T>:: resize(size_t width,
size_t height) const
resize image
Parameters | |
---|---|
width | [in] width of the resulting image |
height | [in] height of the resulting image |
Returns | newly allocated image with the dimensions [width, height] |
Returns a copy of the stored image resize to fit the resulution supplied by the paramets.
template<class T>
GLenum glpp:: core:: object:: image_t<T>:: type() const constexpr noexcept
get base type
Returns the OpenGL specifier for the base type of the pixel format.
template<class T>
image_ t& glpp:: core:: object:: image_t<T>:: update(size_t x,
size_t y,
const image_ t<T>& update) constexpr noexcept
update subimage
Parameters | |
---|---|
x | [in] x position of the patch that shall be updated |
y | [in] y position of the patch that shall be updated |
update | [in] image with new pixel values |
Returns | reference to self to enable chaining |
This function will overwrite a patch of the image. This patch starts at [x, y] and extends in positive x and y direction. The width of the patch is smaller or equal [update.width(), update.height()]. If [x, y] is out side of the image, no pixels will be updated. If the patch would extend over the right or bottom border, the update image will be cropped to match the bounds of this image.
template<class T>
void glpp:: core:: object:: image_t<T>:: write(const char* filename) const
write image to file
Parameters | |
---|---|
filename | [in] name or path of file to write |
This function will write the contents of this class to a file. To use this function it is required to link against glpp::image.