1 /* === S Y N F I G ========================================================= */
3 ** \brief ppm Target Module
6 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** General Public License for more details.
19 ** === N O T E S ===========================================================
21 ** ========================================================================= */
23 /* === H E A D E R S ======================================================= */
34 #include <ETL/stringf>
43 /* === M A C R O S ========================================================= */
45 using namespace synfig;
49 /* === G L O B A L S ======================================================= */
51 SYNFIG_TARGET_INIT(dv_trgt);
52 SYNFIG_TARGET_SET_NAME(dv_trgt,"dv");
53 SYNFIG_TARGET_SET_EXT(dv_trgt,"dv");
54 SYNFIG_TARGET_SET_VERSION(dv_trgt,"0.1");
55 SYNFIG_TARGET_SET_CVS_ID(dv_trgt,"$Id: trgt_dv.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
57 /* === M E T H O D S ======================================================= */
60 dv_trgt::dv_trgt(const char *Filename)
77 delete [] color_buffer;
81 dv_trgt::set_rend_desc(RendDesc *given_desc)
83 // Set the aspect ratio
87 given_desc->set_wh(160,90);
89 // Widescreen should be progressive scan
90 given_desc->set_interlaced(false);
95 given_desc->set_wh(400,300);
97 // We should be interlaced
98 given_desc->set_interlaced(true);
101 // but the pixel res should be 720x480
102 given_desc->clear_flags(),given_desc->set_wh(720,480);
104 // NTSC Frame rate is 29.97
105 given_desc->set_frame_rate(29.97);
107 // The pipe to encodedv is PPM, which needs RGB data
108 //given_desc->set_pixel_format(PF_RGB);
110 // Set the description
119 imagecount=desc.get_frame_start();
124 command=strprintf("encodedv -w 1 - > \"%s\"\n",filename.c_str());
126 command=strprintf("encodedv - > \"%s\"\n",filename.c_str());
128 // Open the pipe to encodedv
129 file=popen(command.c_str(),"w");
133 synfig::error(_("Unable to open pipe to encodedv"));
137 // Sleep for a moment to let the pipe catch up
138 etl::clock().sleep(0.25f);
152 dv_trgt::start_frame(synfig::ProgressCallback *callback)
154 int w=desc.get_w(),h=desc.get_h();
159 fprintf(file, "P6\n");
160 fprintf(file, "%d %d\n", w, h);
161 fprintf(file, "%d\n", 255);
164 buffer=new unsigned char[3*w];
166 delete [] color_buffer;
167 color_buffer=new Color[w];
173 dv_trgt::start_scanline(int scanline)
179 dv_trgt::end_scanline()
184 convert_color_format(buffer, color_buffer, desc.get_w(), PF_RGB, gamma());
186 if(!fwrite(buffer,1,desc.get_w()*3,file))