1 /*! ========================================================================
4 ** $Id: trgt_imagemagick.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $
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.
18 ** === N O T E S ===========================================================
20 ** ========================================================================= */
22 /* === H E A D E R S ======================================================= */
33 #include <ETL/stringf>
34 #include "trgt_imagemagick.h"
43 /* === M A C R O S ========================================================= */
45 using namespace synfig;
49 /* === G L O B A L S ======================================================= */
51 SYNFIG_TARGET_INIT(imagemagick_trgt);
52 SYNFIG_TARGET_SET_NAME(imagemagick_trgt,"imagemagick");
53 SYNFIG_TARGET_SET_EXT(imagemagick_trgt,"miff");
54 SYNFIG_TARGET_SET_VERSION(imagemagick_trgt,"0.1");
55 SYNFIG_TARGET_SET_CVS_ID(imagemagick_trgt,"$Id: trgt_imagemagick.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $");
57 /* === M E T H O D S ======================================================= */
59 imagemagick_trgt::imagemagick_trgt(const char *Filename)
68 imagemagick_trgt::~imagemagick_trgt()
74 delete [] color_buffer;
78 imagemagick_trgt::set_rend_desc(RendDesc *given_desc)
80 String ext(find(filename.begin(),filename.end(),'.')+1,filename.end());
91 imagemagick_trgt::init()
93 imagecount=desc.get_frame_start();
94 if(desc.get_frame_end()-desc.get_frame_start()>0)
98 buffer=new unsigned char[channels(pf)*desc.get_w()];
99 delete [] color_buffer;
100 color_buffer=new Color[desc.get_w()];
105 imagemagick_trgt::end_frame()
117 imagemagick_trgt::start_frame(synfig::ProgressCallback *cb)
122 command=strprintf("convert -depth 8 -size %dx%d rgba:-[0] -density %dx%d \"%s\"\n",desc.get_w(),desc.get_h(),round_to_int(desc.get_x_res()/39.3700787402),round_to_int(desc.get_y_res()/39.3700787402),filename.c_str());
124 command=strprintf("convert -depth 8 -size %dx%d rgb:-[0] -density %dx%d \"%s\"\n",desc.get_w(),desc.get_h(),round_to_int(desc.get_x_res()/39.3700787402),round_to_int(desc.get_y_res()/39.3700787402),filename.c_str());
126 file=popen(command.c_str(),"w");
130 const char *msg=_("Unable to open pipe to imagemagick's convert utility");
131 if(cb)cb->error(N_(msg));
132 else synfig::error(N_(msg));
142 imagemagick_trgt::start_scanline(int scanline)
148 imagemagick_trgt::end_scanline(void)
153 convert_color_format(buffer, color_buffer, desc.get_w(), pf, gamma());
155 if(!fwrite(buffer,channels(pf),desc.get_w(),file))