Phongo Clap RT  1.0
Simple Raytracing Renderer
Public Member Functions | Private Attributes | Friends | List of all members
Film Class Reference

Holds all the operations regarding to input/output of colour information. More...

#include <Film.h>

Collaboration diagram for Film:
Collaboration graph

Public Member Functions

 Film ()
 Film constructor. More...
 
void setDimensions (int _w, int _h)
 Sets the dimensions of the Film. More...
 
 ~Film ()
 Destructor for the Film. More...
 
void writePixel (ngl::Colour _colour)
 Will create a pixel and push it to the pixel vector. More...
 
void writeFile (const char *_image_name)
 Iterates over the pixel vector and writes into a file using basic output stream methods. More...
 

Private Attributes

int m_width
 Width of the Film's image. More...
 
int m_height
 Height of the Film's image. More...
 
std::vector< Pixelm_pixels
 Vector of pixels. The index of the pixel corresponds to this equation: i = height * y + x. More...
 
std::ofstream m_file
 File output stream, in charge of writing the pixels into a file. More...
 

Friends

class Renderer
 

Detailed Description

Holds all the operations regarding to input/output of colour information.

Author
Ramon Blanquer

Definition at line 29 of file Film.h.

Constructor & Destructor Documentation

Film::Film ( )

Film constructor.

Definition at line 7 of file Film.cpp.

7 {}
Film::~Film ( )

Destructor for the Film.

Definition at line 9 of file Film.cpp.

9 {}

Member Function Documentation

void Film::setDimensions ( int  _w,
int  _h 
)

Sets the dimensions of the Film.

Parameters
[in]_wWidth of the Film/Image.
[in]_hHeight of the Film/Image.

Definition at line 11 of file Film.cpp.

References m_height, and m_width.

12 {
13  m_width = _w;
14  m_height = _h;
15 }
int m_width
Width of the Film's image.
Definition: Film.h:64
int m_height
Height of the Film's image.
Definition: Film.h:68

Here is the caller graph for this function:

void Film::writeFile ( const char *  _image_name)

Iterates over the pixel vector and writes into a file using basic output stream methods.

Parameters
[in]_image_nameThe file will be written with the name [_image_name].ppm

Definition at line 26 of file Film.cpp.

References m_file, m_height, m_pixels, and m_width.

27 {
28  m_file.open(_image_name, std::ios::out | std::ios::binary);
29  m_file << "P6\n" << m_width << " " << m_height << "\n255\n";
30 
31  for(unsigned int i = 0; i < m_pixels.size(); ++i)
32  {
33  m_file << (unsigned char) (m_pixels.at(i).r * 255) <<
34  (unsigned char) (m_pixels.at(i).g * 255) <<
35  (unsigned char) (m_pixels.at(i).b * 255);
36  }
37 
38  m_file.close();
39 }
std::ofstream m_file
File output stream, in charge of writing the pixels into a file.
Definition: Film.h:76
std::vector< Pixel > m_pixels
Vector of pixels. The index of the pixel corresponds to this equation: i = height * y + x...
Definition: Film.h:72
int m_width
Width of the Film's image.
Definition: Film.h:64
int m_height
Height of the Film's image.
Definition: Film.h:68

Here is the caller graph for this function:

void Film::writePixel ( ngl::Colour  _colour)

Will create a pixel and push it to the pixel vector.

Parameters
[in]_colourColour that will be written in that pixel.

Definition at line 17 of file Film.cpp.

References Pixel::b, Pixel::g, m_pixels, and Pixel::r.

18 {
19  Pixel curr;
20  curr.r = _colour.m_r;
21  curr.g = _colour.m_g;
22  curr.b = _colour.m_b;
23  m_pixels.push_back(curr);
24 }
float b
Definition: Film.h:21
float g
Definition: Film.h:20
std::vector< Pixel > m_pixels
Vector of pixels. The index of the pixel corresponds to this equation: i = height * y + x...
Definition: Film.h:72
float r
Definition: Film.h:19
Pixel data structure that will be used to hold the image units.
Definition: Film.h:17

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class Renderer
friend

Definition at line 58 of file Film.h.

Member Data Documentation

std::ofstream Film::m_file
private

File output stream, in charge of writing the pixels into a file.

Definition at line 76 of file Film.h.

int Film::m_height
private

Height of the Film's image.

Definition at line 68 of file Film.h.

std::vector<Pixel> Film::m_pixels
private

Vector of pixels. The index of the pixel corresponds to this equation: i = height * y + x.

Definition at line 72 of file Film.h.

int Film::m_width
private

Width of the Film's image.

Definition at line 64 of file Film.h.


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