Ray Tracer Common Project
Image rendering program based on the ray tracing technique.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rt::image Class Reference

Image surface. More...

#include <image.hpp>

Inheritance diagram for rt::image:
rt::bitmap rt::screen

Public Member Functions

 image (int width, int height)
 
 image (const image &img)
 
virtual ~image ()
 
virtual int width () const
 
virtual int height () const
 
virtual image copy () const
 
virtual color get_pixel (int x, int y) const
 
virtual void set_pixel (int x, int y, const color &c)
 
virtual void blit (image &dst, const rect &srcrect, int dstx, int dsty) const
 
virtual void blit (image &dst, int dstx, int dsty) const
 
virtual void draw_line (int x1, int y1, int x2, int y2, const color &c)
 
virtual void draw_rect (int x1, int y1, int x2, int y2, const color &c)
 
virtual void fill_rect (int x1, int y1, int x2, int y2, const color &c)
 

Protected Member Functions

 image ()
 

Protected Attributes

SDL_Surface * data
 

Detailed Description

Image surface.

The image class wraps a SDL_Surface structure to offer object-oriented access to its data. It represents an in-memory image.

Constructor & Destructor Documentation

◆ image() [1/3]

rt::image::image ( )
protected

Default constructor is protected and can be used only by inheriting classes. It is forbidden to build an image without at least its dimensions.

◆ image() [2/3]

rt::image::image ( int  width,
int  height 
)

Main constructor. Builds an image from its dimensions.

◆ image() [3/3]

rt::image::image ( const image img)

Copy constructor. Warning: this does not copy the actual data, so any modification to the copy will impact the original. To build a hard copy, use the copy member function.

◆ ~image()

rt::image::~image ( )
virtual

Destructor. Will decrease the reference counter of the wrapped data and free it if it goes to 0.

Member Function Documentation

◆ blit() [1/2]

void rt::image::blit ( image dst,
const rect srcrect,
int  dstx,
int  dsty 
) const
virtual

Copy/Past the image's source rectangle to a given destiation at given coordinates.

◆ blit() [2/2]

void rt::image::blit ( image dst,
int  dstx,
int  dsty 
) const
virtual

Copy/Past time entire image to a given destiation at given coordinates.

◆ copy()

image rt::image::copy ( ) const
virtual

Returns a hard copy of the image.

◆ draw_line()

void rt::image::draw_line ( int  x1,
int  y1,
int  x2,
int  y2,
const color c 
)
virtual

Draws a line from \((x1,y1)\) to \((x2,y2)\) of a given color.

◆ draw_rect()

void rt::image::draw_rect ( int  x1,
int  y1,
int  x2,
int  y2,
const color c 
)
virtual

Draws a rectangle (uses draw_line) of a given color.

◆ fill_rect()

void rt::image::fill_rect ( int  x1,
int  y1,
int  x2,
int  y2,
const color c 
)
virtual

Draws a filled rectangle of a given color.

◆ get_pixel()

color rt::image::get_pixel ( int  x,
int  y 
) const
virtual

Returns the color of a pixel.

Reimplemented in rt::bitmap.

◆ height()

virtual int rt::image::height ( ) const
inlinevirtual

Returns the height of the image.

◆ set_pixel()

void rt::image::set_pixel ( int  x,
int  y,
const color c 
)
virtual

Sets a pixel to a given color.

Reimplemented in rt::bitmap.

◆ width()

virtual int rt::image::width ( ) const
inlinevirtual

Returns the width of the image.

Member Data Documentation

◆ data

SDL_Surface* rt::image::data
protected

Wrapped SDL surface


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