|
mousetrap v0.2.0
|
a 2d buffer container RGBA pixels More...
#include <image.hpp>
Public Member Functions | |
| Image () | |
| default ctor, initialize as image of size 0x0 | |
| Image (const std::string &path) | |
| construct from file | |
| Image (uint64_t width, uint64_t height, RGBA rgba=RGBA(0, 0, 0, 0)) | |
| construct as single-color image | |
| ~Image () | |
| destruct, frees data | |
| Image (const Image &other) | |
| copy ctor, invokes deep copy of the data | |
| Image (Image &&other) noexcept | |
| move ctor, moves data, empties original image | |
| Image & | operator= (const Image &other) |
| copy assignment, invokes deep copy of the data | |
| Image & | operator= (Image &&other) noexcept |
| move assignment, empties original image | |
| operator GdkPixbuf * () const | |
| expose as GdkPixbuf, for interal use only | |
| void | create (uint64_t width, uint64_t height, RGBA default_color=RGBA(0, 0, 0, 1)) |
| create image of given size and identical color | |
| bool | create_from_file (const std::string &path) |
| create an image by reading a file | |
| bool | save_to_file (const std::string &path) const |
| sae to file | |
| void * | data () const |
| expose pixel data, linear array of RGBA values. For internal use only | |
| uint64_t | get_data_size () const |
| get length of linear data | |
| uint64_t | get_n_pixels () const |
| get number of pixels | |
| Vector2ui | get_size () const |
| get dimensions | |
| Image | as_scaled (uint64_t size_x, uint64_t size_y, InterpolationType interpolation_type=InterpolationType::TILES) const |
| create a new image, scaled according to the scale mode | |
| Image | as_cropped (int offset_x, int offset_y, uint64_t new_width, uint64_t new_height) const |
| create a new image, cropped | |
| Image | as_flipped (bool flip_horizontally, bool flip_vertically) const |
| create a new image, flipped | |
| void | set_pixel (uint64_t x, uint64_t y, RGBA new_color) |
| set value of individual pixel, prints soft warning if indices out of bounds | |
| void | set_pixel (uint64_t x, uint64_t y, HSVA new_color) |
| set value of individual pixel, prints soft warning if indices out of bounds | |
| RGBA | get_pixel (uint64_t x, uint64_t y) const |
| get value of individual pixel, prints soft warning if indices out of bounds | |
| void | set_pixel (uint64_t linear_index, RGBA new_color) |
| set value of individual pixel, linear indexing. Prints soft warning if index out of bounds | |
| void | set_pixel (uint64_t linear_index, HSVA new_color) |
| set value of individual pixel, linear indexing. Prints soft warning if index out of bounds | |
| RGBA | get_pixel (uint64_t linear_index) const |
| get value of individual pixel, linear indexing. | |
a 2d buffer container RGBA pixels
| mousetrap::Image::Image | ( | const std::string & | path | ) |
construct as single-color image
| width | |
| height | |
| rgba | default color for all pixels |
References create().
| mousetrap::Image::Image | ( | const Image & | other | ) |
copy ctor, invokes deep copy of the data
| other |
|
noexcept |
move ctor, moves data, empties original image
| other |
| Image mousetrap::Image::as_cropped | ( | int | offset_x, |
| int | offset_y, | ||
| uint64_t | new_width, | ||
| uint64_t | new_height | ||
| ) | const |
create a new image, cropped
| offset_x | left most anchor of the newly cropped image, may be negative |
| offset_y | top most anchor of the newly cropped image, may be negative |
| new_width | new width |
| new_height | new height |
References get_pixel(), get_size(), and Image().
| Image mousetrap::Image::as_flipped | ( | bool | flip_horizontally, |
| bool | flip_vertically | ||
| ) | const |
create a new image, flipped
| flip_horizontally | flip along the x-axis |
| flip_vertically | flip along the y-axis |
References get_pixel(), and Image().
| Image mousetrap::Image::as_scaled | ( | uint64_t | size_x, |
| uint64_t | size_y, | ||
| InterpolationType | interpolation_type = InterpolationType::TILES |
||
| ) | const |
create a new image, scaled according to the scale mode
| size_x | new width |
| size_y | new height |
| interpolation_type | interpolation algorithm to use |
References Image().
| void mousetrap::Image::create | ( | uint64_t | width, |
| uint64_t | height, | ||
| RGBA | default_color = RGBA(0, 0, 0, 1) |
||
| ) |
create image of given size and identical color
| width | new x-dimension |
| height | new y-dimension |
| default_color | color of all pixels after initialization |
References mousetrap::RGBA::a, mousetrap::RGBA::b, mousetrap::RGBA::g, mousetrap::RGBA::r, and set_pixel().
Referenced by Image().
| bool mousetrap::Image::create_from_file | ( | const std::string & | path | ) |
create an image by reading a file
| path |
References mousetrap::log::critical().
Referenced by Image().
| void * mousetrap::Image::data | ( | ) | const |
expose pixel data, linear array of RGBA values. For internal use only
Referenced by mousetrap::Texture::create_from_image(), get_pixel(), and set_pixel().
| uint64_t mousetrap::Image::get_data_size | ( | ) | const |
| uint64_t mousetrap::Image::get_n_pixels | ( | ) | const |
| RGBA mousetrap::Image::get_pixel | ( | uint64_t | linear_index | ) | const |
| RGBA mousetrap::Image::get_pixel | ( | uint64_t | x, |
| uint64_t | y | ||
| ) | const |
get value of individual pixel, prints soft warning if indices out of bounds
| x | row-index |
| y | column-index |
References mousetrap::log::critical(), data(), and get_data_size().
Referenced by as_cropped(), and as_flipped().
| Vector2ui mousetrap::Image::get_size | ( | ) | const |
get dimensions
Referenced by as_cropped(), mousetrap::Texture::create_from_image(), mousetrap::ImageDisplay::create_from_image(), and get_n_pixels().
copy assignment, invokes deep copy of the data
| other |
move assignment, empties original image
| other |
| bool mousetrap::Image::save_to_file | ( | const std::string & | path | ) | const |
sae to file
| path |
References mousetrap::log::critical().
| void mousetrap::Image::set_pixel | ( | uint64_t | linear_index, |
| HSVA | new_color | ||
| ) |
set value of individual pixel, linear indexing. Prints soft warning if index out of bounds
| linear_index | |
| new_color | HSVA |
References set_pixel().
| void mousetrap::Image::set_pixel | ( | uint64_t | linear_index, |
| RGBA | new_color | ||
| ) |
set value of individual pixel, linear indexing. Prints soft warning if index out of bounds
| linear_index | |
| new_color | RBGA |
References mousetrap::RGBA::a, mousetrap::RGBA::b, mousetrap::log::critical(), data(), mousetrap::RGBA::g, get_data_size(), and mousetrap::RGBA::r.
| void mousetrap::Image::set_pixel | ( | uint64_t | x, |
| uint64_t | y, | ||
| HSVA | new_color | ||
| ) |
set value of individual pixel, prints soft warning if indices out of bounds
| x | row-index |
| y | column-index |
| new_color | HSVA |
References set_pixel().
| void mousetrap::Image::set_pixel | ( | uint64_t | x, |
| uint64_t | y, | ||
| RGBA | new_color | ||
| ) |
set value of individual pixel, prints soft warning if indices out of bounds
| x | row-index |
| y | column-index |
| new_color | RGBA |
References mousetrap::RGBA::a, mousetrap::RGBA::b, data(), mousetrap::RGBA::g, get_data_size(), and mousetrap::RGBA::r.
Referenced by create(), and set_pixel().