SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
satdump::image::Image Class Reference

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)
Imageoperator= (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

Constructor & Destructor Documentation

◆ Image() [1/2]

satdump::image::Image::Image ( int bit_depth,
size_t width,
size_t height,
int channels )

Init emtpy image, set to 0 but with an allocated data buffer.

Parameters
bit_depthdepth of the image (usually 8 or 16)
widthImage width in pixels
heightImage height in pixels
channelsNumber of channels. See init() for more info

◆ Image() [2/2]

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.

Parameters
bufferpointer to read from
bit_depthdepth of the image (usually 8 or 16)
widthImage width in pixels
heightImage height in pixels
channelsNumber of channels. See init() for more info

Member Function Documentation

◆ channels()

int satdump::image::Image::channels ( ) const
inline

Returns image channel count.

Returns
number of image channels

◆ clamp()

int satdump::image::Image::clamp ( int input)

Clamp input value to what this image can handle.

Parameters
inputthe input value
Returns
clamped value (depends on bit depth)

◆ clampf()

double satdump::image::Image::clampf ( double input)

Clamp input value to what this image can handle as float (0, 1)

Parameters
inputthe input value
Returns
value between 0 and 1

◆ crop() [1/2]

void satdump::image::Image::crop ( int x0,
int x1 )

Crop an image region, x axis only.

Parameters
x0x position of the first column
x1x position of the second column

◆ crop() [2/2]

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.

Parameters
x0x position of the first pixel
y0y position of the first pixel
x1x position of the second pixel
y1y position of the second pixel

◆ crop_to() [1/2]

Image satdump::image::Image::crop_to ( int x0,
int x1 )

Crop an image region, x asus only Provides image as a return value.

Parameters
x0x position of the first column
x1x position of the second column
Returns
Cropped image

◆ crop_to() [2/2]

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.

Parameters
x0x position of the first pixel
y0y position of the first pixel
x1x position of the second pixel
y1y position of the second pixel
Returns
Cropped image

◆ depth()

int satdump::image::Image::depth ( ) const
inline

Returns image bit depth.

Returns
bit depth

◆ draw_circle()

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.

Parameters
x0center X position
y0center Y position
radiusin pixels
colorof the circle
fillshould be true if the circle is to be filled

◆ draw_image()

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.

Parameters
channelindex. If 0, draws as color image
imagethe image to draw
xoffset
yoffset

◆ draw_image_alpha()

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.

Parameters
channelindex. If 0, draws as color image
imagethe image to draw
xoffset
yoffset

◆ draw_line()

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.

Parameters
x0line start X position
y0line start Y position
x1line stop X position
y1line stop Y position
colorof the line

◆ draw_pixel()

void satdump::image::Image::draw_pixel ( size_t x,
size_t y,
std::vector< double > color )

Set a pixel's color.

Parameters
xposition
yposition
colorof the pixel

◆ draw_rectangle()

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.

Parameters
x0rectangle start X position
y0rectangle start Y position
x1rectangle stop X position
y1rectangle stop Y position
colorof the rectangle
fillshould be true if the rectangle is to be filled

◆ fill()

void satdump::image::Image::fill ( int val)

Fill image with a single value.

Parameters
valthe value

◆ fill_color()

void satdump::image::Image::fill_color ( std::vector< double > color)

Fill image with a color.

Parameters
colorthe color, must match the number of image channels

◆ get()

int satdump::image::Image::get ( size_t p)
inline

Standard int get. No bound check! Variants to pass a channel index and X / Y position are also available.

Parameters
pindex of the pixel to get
Returns
pixel value

◆ get_pixel_bilinear()

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.

Parameters
channelindex of the channel to use
xposition
yposition

◆ getf()

double satdump::image::Image::getf ( size_t p)
inline

Standard float get. No bound check! Variants to pass a channel index and X / Y position are also available.

Parameters
pindex of the pixel to get
Returns
pixel value between 0 and 1

◆ height()

size_t satdump::image::Image::height ( ) const
inline

Returns image height.

Returns
image height in pixels

◆ init()

void satdump::image::Image::init ( int bit_depth,
size_t width,
size_t height,
int channels )

Init (empty, filled with zeroes) image buffer.

Parameters
bit_depthImage bit depth. Usually should be 8 or 16
widthImage width in pixels
heightImage height in pixels
channelsNumber of channels (1 = Grayscale, 2 = GA, 3 = RGB, 4 = RGBA)

◆ maxval()

int satdump::image::Image::maxval ( ) const
inline

Returns image max value.

Returns
maximum int value of an image pixels

◆ mirror()

void satdump::image::Image::mirror ( bool x,
bool y )

Mirror the image.

Parameters
xmirror on X axis
ymirror on Y axis

◆ raw_data()

void * satdump::image::Image::raw_data ( ) const
inline

Returns the RAW void pointer. MUST ONLY BE USED IF YOU KNOW WHAT YOU ARE DOING!

Returns
the void pointer. Be. Careful.

◆ resize()

void satdump::image::Image::resize ( int width,
int height )

Resize image, using a simple pixel scaling attribution (not the best, but fast)

Parameters
widthx size to resize to
heighty size to resize to

◆ resize_bilinear()

void satdump::image::Image::resize_bilinear ( int width,
int height,
bool text_mode = false )

Resize image, using a bilinear algorithm.

Parameters
widthx size to resize to
heighty size to resize to
text_modemakes any pixel that is no 0 the maximum value of the pixel

◆ resize_to()

Image satdump::image::Image::resize_to ( int width,
int height )

Resize image, to another image. Same as resize otherwise.

Parameters
widthx size to resize to
heighty size to resize to
Returns
output image

◆ set()

void satdump::image::Image::set ( size_t p,
int v )
inline

Standard int set. No bound check! Variants to pass a channel index and X / Y position are also available.

Parameters
pindex of the pixel to set
vvalue to set

◆ setf()

void satdump::image::Image::setf ( size_t p,
double v )
inline

Standard float set. No bound check! Variants to pass a channel index and X / Y position are also available.

Parameters
pindex of the pixel to set
vvalue to set between 0 and 1

◆ size()

size_t satdump::image::Image::size ( ) const
inline

Returns image data size.

Returns
Image data size, in pixels

◆ to_depth()

Image satdump::image::Image::to_depth ( int bit_depth)

Converts to a specific target bit depth.

Parameters
bit_depthto convert to
Returns
converted image

◆ typesize()

int satdump::image::Image::typesize ( ) const
inline

Returns image type size (in bytes)

Returns
type size, bytes

◆ width()

size_t satdump::image::Image::width ( ) const
inline

Returns image width.

Returns
image width in pixels

The documentation for this class was generated from the following files:
  • src-core/image/image.h
  • src-core/image/image.cpp
  • src-core/image/image_draw.cpp
  • src-core/image/meta.cpp