SatDump 2.0.0-alpha-76a915210
|
Public Member Functions | |
Image () | |
Init null image, with no data buffer. | |
Image (int bit_depth, size_t width, size_t height, int channels) | |
Init emtpy image, set to 0 but with an allocated data buffer. | |
Image (void *buffer, int bit_depth, size_t width, size_t height, int channels) | |
Init an image, reading the contents of the data buffer from a provided buffer. This is useful to for example turn a uint16_t buffer directly into an usable image. | |
Image (const Image &img) | |
Image & | operator= (const Image &img) |
void | to_rgb () |
Convert this image from B&W to RGB (if it is B&W / RGBA) | |
void | to_rgba () |
Convert this image from to RGBA (if it is B&W / RGB) | |
Image | to8bits () |
Convert to 8-bits. Returns the current image if it's already 8-bits. | |
Image | to16bits () |
Convert to 16-bits. Returns the current image if it's already 16-bits. | |
Image | to_depth (int bit_depth) |
Converts to a specific target bit depth. | |
void | draw_image (int channel, Image image, int x=0, int y=0) |
Draw a B&W Image onto an image channel, or if channel is kept at 0, RGB or RGBA images as well. | |
void | draw_image_alpha (Image image, int x=0, int y=0) |
Draw an alpha Image onto an image or if channel is kept at 0, RGB or RGBA images as well. Respects the image's Alpha channel. | |
void | draw_pixel (size_t x, size_t y, std::vector< double > color) |
Set a pixel's color. | |
void | draw_line (int x0, int y0, int x1, int y1, std::vector< double > color) |
Draw a line with Bresenham's algorithm. | |
void | draw_circle (int x0, int y0, int radius, std::vector< double > color, bool fill=false) |
Draw a circle with Bresenham's Midpoint algorithm. | |
void | draw_rectangle (int x0, int y0, int x1, int y1, std::vector< double > color, bool fill=true) |
Draw a rectangle onto the image. | |
void | init (int bit_depth, size_t width, size_t height, int channels) |
Init (empty, filled with zeroes) image buffer. | |
void | clear () |
Delete current buffer (and set size to 0) | |
int | clamp (int input) |
Clamp input value to what this image can handle. | |
double | clampf (double input) |
Clamp input value to what this image can handle as float (0, 1) | |
void * | raw_data () const |
Returns the RAW void pointer. MUST ONLY BE USED IF YOU KNOW WHAT YOU ARE DOING! | |
int | depth () const |
Returns image bit depth. | |
int | typesize () const |
Returns image type size (in bytes) | |
size_t | width () const |
Returns image width. | |
size_t | height () const |
Returns image height. | |
int | channels () const |
Returns image channel count. | |
size_t | size () const |
Returns image data size. | |
int | maxval () const |
Returns image max value. | |
void | crop (int x0, int y0, int x1, int y1) |
Crop an image region. Must be with x0 <= x1 and y0 <= y1. | |
void | crop (int x0, int x1) |
Crop an image region, x axis only. | |
Image | crop_to (int x0, int y0, int x1, int y1) |
Crop an image region. Must be with x0 <= x1 and y0 <= y1. Provides image as a return value. | |
Image | crop_to (int x0, int x1) |
Crop an image region, x asus only Provides image as a return value. | |
void | mirror (bool x, bool y) |
Mirror the image. | |
void | resize (int width, int height) |
Resize image, using a simple pixel scaling attribution (not the best, but fast) | |
Image | resize_to (int width, int height) |
Resize image, to another image. Same as resize otherwise. | |
void | resize_bilinear (int width, int height, bool text_mode=false) |
Resize image, using a bilinear algorithm. | |
int | get_pixel_bilinear (int channel, double x, double y) |
Get a pixel from the image, but with the option to interpolate fractional pixels. | |
void | fill (int val) |
Fill image with a single value. | |
void | fill_color (std::vector< double > color) |
Fill image with a color. | |
void | set (size_t p, int v) |
Standard int set. No bound check! Variants to pass a channel index and X / Y position are also available. | |
int | get (size_t p) |
Standard int get. No bound check! Variants to pass a channel index and X / Y position are also available. | |
void | setf (size_t p, double v) |
Standard float set. No bound check! Variants to pass a channel index and X / Y position are also available. | |
double | getf (size_t p) |
Standard float get. No bound check! Variants to pass a channel index and X / Y position are also available. | |
void | set (size_t channel, size_t p, int v) |
int | get (size_t channel, size_t p) |
void | set (size_t channel, size_t x, size_t y, int v) |
int | get (size_t channel, size_t x, size_t y) |
void | setf (size_t channel, size_t p, double v) |
double | getf (size_t channel, size_t p) |
void | setf (size_t channel, size_t x, size_t y, double v) |
double | getf (size_t channel, size_t x, size_t y) |
Public Attributes | |
void * | metadata_obj = nullptr |
Protected Member Functions | |
void | copy_meta (const Image &img) |
Protected Attributes | |
size_t | data_size = 0 |
size_t | type_size = 0 |
void * | d_data = nullptr |
int | d_depth = 0 |
int | d_maxv = 0 |
size_t | d_width = 0 |
size_t | d_height = 0 |
int | d_channels = 0 |
satdump::image::Image::Image | ( | int | bit_depth, |
size_t | width, | ||
size_t | height, | ||
int | channels ) |
satdump::image::Image::Image | ( | void * | buffer, |
int | bit_depth, | ||
size_t | width, | ||
size_t | height, | ||
int | channels ) |
Init an image, reading the contents of the data buffer from a provided buffer. This is useful to for example turn a uint16_t buffer directly into an usable image.
|
inline |
Returns image channel count.
int satdump::image::Image::clamp | ( | int | input | ) |
Clamp input value to what this image can handle.
input | the input value |
double satdump::image::Image::clampf | ( | double | input | ) |
Clamp input value to what this image can handle as float (0, 1)
input | the input value |
void satdump::image::Image::crop | ( | int | x0, |
int | x1 ) |
Crop an image region, x axis only.
x0 | x position of the first column |
x1 | x position of the second column |
void satdump::image::Image::crop | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1 ) |
Crop an image region. Must be with x0 <= x1 and y0 <= y1.
x0 | x position of the first pixel |
y0 | y position of the first pixel |
x1 | x position of the second pixel |
y1 | y position of the second pixel |
Image satdump::image::Image::crop_to | ( | int | x0, |
int | x1 ) |
Crop an image region, x asus only Provides image as a return value.
x0 | x position of the first column |
x1 | x position of the second column |
Image satdump::image::Image::crop_to | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1 ) |
Crop an image region. Must be with x0 <= x1 and y0 <= y1. Provides image as a return value.
x0 | x position of the first pixel |
y0 | y position of the first pixel |
x1 | x position of the second pixel |
y1 | y position of the second pixel |
|
inline |
Returns image bit depth.
void satdump::image::Image::draw_circle | ( | int | x0, |
int | y0, | ||
int | radius, | ||
std::vector< double > | color, | ||
bool | fill = false ) |
Draw a circle with Bresenham's Midpoint algorithm.
x0 | center X position |
y0 | center Y position |
radius | in pixels |
color | of the circle |
fill | should be true if the circle is to be filled |
void satdump::image::Image::draw_image | ( | int | channel, |
Image | image, | ||
int | x = 0, | ||
int | y = 0 ) |
Draw a B&W Image onto an image channel, or if channel is kept at 0, RGB or RGBA images as well.
channel | index. If 0, draws as color image |
image | the image to draw |
x | offset |
y | offset |
void satdump::image::Image::draw_image_alpha | ( | Image | image, |
int | x = 0, | ||
int | y = 0 ) |
Draw an alpha Image onto an image or if channel is kept at 0, RGB or RGBA images as well. Respects the image's Alpha channel.
channel | index. If 0, draws as color image |
image | the image to draw |
x | offset |
y | offset |
void satdump::image::Image::draw_line | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
std::vector< double > | color ) |
Draw a line with Bresenham's algorithm.
x0 | line start X position |
y0 | line start Y position |
x1 | line stop X position |
y1 | line stop Y position |
color | of the line |
void satdump::image::Image::draw_pixel | ( | size_t | x, |
size_t | y, | ||
std::vector< double > | color ) |
Set a pixel's color.
x | position |
y | position |
color | of the pixel |
void satdump::image::Image::draw_rectangle | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
std::vector< double > | color, | ||
bool | fill = true ) |
Draw a rectangle onto the image.
x0 | rectangle start X position |
y0 | rectangle start Y position |
x1 | rectangle stop X position |
y1 | rectangle stop Y position |
color | of the rectangle |
fill | should be true if the rectangle is to be filled |
void satdump::image::Image::fill | ( | int | val | ) |
Fill image with a single value.
val | the value |
void satdump::image::Image::fill_color | ( | std::vector< double > | color | ) |
Fill image with a color.
color | the color, must match the number of image channels |
|
inline |
Standard int get. No bound check! Variants to pass a channel index and X / Y position are also available.
p | index of the pixel to get |
int satdump::image::Image::get_pixel_bilinear | ( | int | channel, |
double | x, | ||
double | y ) |
Get a pixel from the image, but with the option to interpolate fractional pixels.
channel | index of the channel to use |
x | position |
y | position |
|
inline |
Standard float get. No bound check! Variants to pass a channel index and X / Y position are also available.
p | index of the pixel to get |
|
inline |
Returns image height.
void satdump::image::Image::init | ( | int | bit_depth, |
size_t | width, | ||
size_t | height, | ||
int | channels ) |
|
inline |
Returns image max value.
void satdump::image::Image::mirror | ( | bool | x, |
bool | y ) |
Mirror the image.
x | mirror on X axis |
y | mirror on Y axis |
|
inline |
Returns the RAW void pointer. MUST ONLY BE USED IF YOU KNOW WHAT YOU ARE DOING!
void satdump::image::Image::resize | ( | int | width, |
int | height ) |
Resize image, using a simple pixel scaling attribution (not the best, but fast)
width | x size to resize to |
height | y size to resize to |
void satdump::image::Image::resize_bilinear | ( | int | width, |
int | height, | ||
bool | text_mode = false ) |
Resize image, using a bilinear algorithm.
width | x size to resize to |
height | y size to resize to |
text_mode | makes any pixel that is no 0 the maximum value of the pixel |
Image satdump::image::Image::resize_to | ( | int | width, |
int | height ) |
Resize image, to another image. Same as resize otherwise.
width | x size to resize to |
height | y size to resize to |
|
inline |
Standard int set. No bound check! Variants to pass a channel index and X / Y position are also available.
p | index of the pixel to set |
v | value to set |
|
inline |
Standard float set. No bound check! Variants to pass a channel index and X / Y position are also available.
p | index of the pixel to set |
v | value to set between 0 and 1 |
|
inline |
Returns image data size.
Image satdump::image::Image::to_depth | ( | int | bit_depth | ) |
Converts to a specific target bit depth.
bit_depth | to convert to |
|
inline |
Returns image type size (in bytes)
|
inline |
Returns image width.