raytracer
Parallel Ray Tracer written from scratch (no graphics API).
Loading...
Searching...
No Matches
raytracer::common::Image Class Reference

#include <image.h>

Public Member Functions

 Image (int _width, int _height, int _channels, bool _is_grayscale)
 Image (const Vec3 &color)
void draw (int x, int y, const Vec3 &color)
void add_color (int x, int y, const Vec3 &color)
void generateBmp (const std::string &file_name) const
int get_width () const
int get_height () const
int get_color_channels () const
bool get_is_grayscale () const
const std::vector< Vec3 > & get_data () const
Vec3 get_color (const int x, const int y) const

Detailed Description

A vector of colors.

Constructor & Destructor Documentation

◆ Image() [1/2]

raytracer::common::Image::Image ( int _width,
int _height,
int _channels,
bool _is_grayscale )

Creates an image with the given properties and fills it with zero vectors (black).

Parameters
_widthThe width of the image.
_heightThe height of the image.
_channelsThe number of color channels of the image.
_is_grayscaleWhether the image is grayscale (scalar color instead of RGB).

◆ Image() [2/2]

raytracer::common::Image::Image ( const Vec3 & color)
explicit

Creates a 1x1 image with the given color.

Parameters
colorThe color of the sole pixel.

Member Function Documentation

◆ add_color()

void raytracer::common::Image::add_color ( int x,
int y,
const Vec3 & color )

Adds a color vector on top of the existing one at a given position.

Parameters
xThe row of the image, starting from the top.
yThe column of the image, starting from the left.
colorThe color to add on top.

◆ draw()

void raytracer::common::Image::draw ( int x,
int y,
const Vec3 & color )

Sets the color of the image at a given position.

Parameters
xThe row of the image, starting from the top.
yThe column of the image, starting from the left.
colorThe new color at that position.
Here is the caller graph for this function:

◆ generateBmp()

void raytracer::common::Image::generateBmp ( const std::string & file_name) const

Write the pixel data to a bitmap on disk.

Parameters
file_nameThe name of the file to write to.
Here is the call graph for this function:

◆ get_color()

Vec3 raytracer::common::Image::get_color ( const int x,
const int y ) const
inlinenodiscard

Returns the color at the given position.

Parameters
xThe row of the image, starting from the top.
yThe column of the image, starting from the left.
Returns
The color at the given position.
Here is the caller graph for this function:

◆ get_color_channels()

int raytracer::common::Image::get_color_channels ( ) const
inlinenodiscard

Getter for the number of color channels the image has.

Returns
The number of color channels the image has.

◆ get_data()

const std::vector< Vec3 > & raytracer::common::Image::get_data ( ) const
inlinenodiscard

Returns a const reference to the underlying vector of colors.

Returns
A const reference to the underlying vector of colors.

◆ get_height()

int raytracer::common::Image::get_height ( ) const
inlinenodiscard

Getter for the height of the image.

Returns
The height of the image.
Here is the caller graph for this function:

◆ get_is_grayscale()

bool raytracer::common::Image::get_is_grayscale ( ) const
inlinenodiscard

Getter for whether the image is grayscale.

Returns
True if the image is grayscale, false otherwise.

◆ get_width()

int raytracer::common::Image::get_width ( ) const
inlinenodiscard

Getter for the width of the image.

Returns
The width of the image.
Here is the caller graph for this function:

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