Mercurial > hg > aimc
comparison trunk/src/Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.cc @ 443:f2dd5788e1d8
- Support for output as a set of PNG files.
author | tomwalters |
---|---|
date | Sun, 14 Nov 2010 05:56:50 +0000 |
parents | 9c26f6532ea3 |
children | 5203f75fba22 |
comparison
equal
deleted
inserted
replaced
442:2d0b057e525c | 443:f2dd5788e1d8 |
---|---|
43 : GraphicsOutputDevice(pParam) { | 43 : GraphicsOutputDevice(pParam) { |
44 m_bOutputFile = false; | 44 m_bOutputFile = false; |
45 m_iFileNumber = 0; | 45 m_iFileNumber = 0; |
46 m_iVertexType = VertexTypeNone; | 46 m_iVertexType = VertexTypeNone; |
47 m_bUseMemoryBuffer=false; | 47 m_bUseMemoryBuffer=false; |
48 parameters_->DefaultString("output.img.format", ".png"); | 48 parameters_->DefaultString("output.img.format", "png"); |
49 } | |
50 | |
51 void GraphicsOutputDeviceCairo::Reset(Parameters* global_parameters) { | |
52 Initialize(global_parameters); | |
53 } | |
54 | |
55 bool GraphicsOutputDeviceCairo::Initialize(Parameters *global_parameters) { | |
56 global_parameters_ = global_parameters; | |
57 #ifdef _WINDOWS | |
58 string pathsep("\\"); | |
59 #else | |
60 string pathsep("/"); | |
61 #endif | |
62 directory_ = global_parameters->GetString("output_filename_base") + pathsep; | |
63 //! \todo Make build system check for mkdtemp() to use it when available. See TODO.txt. | |
64 #ifdef _WINDOWS | |
65 if (_mkdir(directory_.c_str()) < 0) { | |
66 LOG_ERROR(_T("Couldn't create directory for image output.")); | |
67 return false; | |
68 } | |
69 #else | |
70 mkdir(directory_.c_str(), S_IRWXU); | |
71 #endif | |
72 InitialzeInternal(); | |
73 return true; | |
49 } | 74 } |
50 | 75 |
51 bool GraphicsOutputDeviceCairo::Initialize(string directory) { | 76 bool GraphicsOutputDeviceCairo::Initialize(string directory) { |
52 directory_ = directory; | 77 directory_ = directory; |
53 InititalzeInternal(); | 78 InitialzeInternal(); |
54 | 79 |
55 /* Try to open an image to see if everything is allright. We want to avoid | 80 /* Try to open an image to see if everything is allright. We want to avoid |
56 * errors in the main Process()ing loop. */ | 81 * errors in the main Process()ing loop. */ |
57 /*if (!OpenFile(0)) { | 82 /*if (!OpenFile(0)) { |
58 //! \todo Better error message that is more specific about the cause. | 83 //! \todo Better error message that is more specific about the cause. |
69 Init(); | 94 Init(); |
70 m_bUseMemoryBuffer = true; | 95 m_bUseMemoryBuffer = true; |
71 return(true); | 96 return(true); |
72 }*/ | 97 }*/ |
73 | 98 |
74 void GraphicsOutputDeviceCairo::InititalzeInternal() { | 99 void GraphicsOutputDeviceCairo::InitialzeInternal() { |
75 AIM_ASSERT(parameters_); | 100 AIM_ASSERT(parameters_); |
76 | 101 |
77 parameters_->DefaultString("output.img.color.background", "black"); | 102 parameters_->DefaultString("output.img.color.background", "black"); |
78 | 103 |
79 m_bInvertColors = parameters_->DefaultBool("output.img.color.invert", "false"); | 104 m_bInvertColors = parameters_->DefaultBool("output.img.color.invert", "false"); |
233 //cairo_set_source_rgb(m_cCr, 0.2, 1 - m_aPrevY[0], m_aPrevX[0]); | 258 //cairo_set_source_rgb(m_cCr, 0.2, 1 - m_aPrevY[0], m_aPrevX[0]); |
234 cairo_rectangle (m_cCr, m_aPrevX[2], | 259 cairo_rectangle (m_cCr, m_aPrevX[2], |
235 1 - m_aPrevY[2], m_aPrevX[2] - m_aPrevX[0], | 260 1 - m_aPrevY[2], m_aPrevX[2] - m_aPrevX[0], |
236 y - m_aPrevY[2]); | 261 y - m_aPrevY[2]); |
237 cairo_fill (m_cCr); | 262 cairo_fill (m_cCr); |
238 | 263 |
239 /*cairo_move_to(m_cCr, , ); | 264 /*cairo_move_to(m_cCr, , ); |
240 cairo_line_to(m_cCr, , 1 - m_aPrevY[1]); | 265 cairo_line_to(m_cCr, , 1 - m_aPrevY[1]); |
241 cairo_line_to(m_cCr, x, y); | 266 cairo_line_to(m_cCr, x, y); |
242 cairo_line_to(m_cCr, m_aPrevX[2], 1 - m_aPrevY[2]);*/ | 267 cairo_line_to(m_cCr, m_aPrevX[2], 1 - m_aPrevY[2]);*/ |
243 | |
244 | 268 |
245 // Last vertices of this quad are the first of the next | 269 // Last vertices of this quad are the first of the next |
246 m_aPrevX[0] = m_aPrevX[2]; | 270 m_aPrevX[0] = m_aPrevX[2]; |
247 m_aPrevY[0] = m_aPrevY[2]; | 271 m_aPrevY[0] = m_aPrevY[2]; |
248 m_aPrevX[1] = x; | 272 m_aPrevX[1] = x; |