1 /*! ========================================================================
4 ** $Id: trgt_imagemagick.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
17 ** === N O T E S ===========================================================
19 ** ========================================================================= */
21 /* === H E A D E R S ======================================================= */
32 #include <ETL/stringf>
33 #include "trgt_imagemagick.h"
42 /* === M A C R O S ========================================================= */
44 using namespace sinfg;
48 /* === G L O B A L S ======================================================= */
50 SINFG_TARGET_INIT(imagemagick_trgt);
51 SINFG_TARGET_SET_NAME(imagemagick_trgt,"imagemagick");
52 SINFG_TARGET_SET_EXT(imagemagick_trgt,"miff");
53 SINFG_TARGET_SET_VERSION(imagemagick_trgt,"0.1");
54 SINFG_TARGET_SET_CVS_ID(imagemagick_trgt,"$Id: trgt_imagemagick.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $");
56 /* === M E T H O D S ======================================================= */
58 imagemagick_trgt::imagemagick_trgt(const char *Filename)
67 imagemagick_trgt::~imagemagick_trgt()
73 delete [] color_buffer;
77 imagemagick_trgt::set_rend_desc(RendDesc *given_desc)
79 String ext(find(filename.begin(),filename.end(),'.')+1,filename.end());
90 imagemagick_trgt::init()
92 imagecount=desc.get_frame_start();
93 if(desc.get_frame_end()-desc.get_frame_start()>0)
97 buffer=new unsigned char[channels(pf)*desc.get_w()];
98 delete [] color_buffer;
99 color_buffer=new Color[desc.get_w()];
104 imagemagick_trgt::end_frame()
116 imagemagick_trgt::start_frame(sinfg::ProgressCallback *cb)
121 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());
123 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());
125 file=popen(command.c_str(),"w");
129 const char *msg=_("Unable to open pipe to imagemagick's convert utility");
130 if(cb)cb->error(N_(msg));
131 else sinfg::error(N_(msg));
141 imagemagick_trgt::start_scanline(int scanline)
147 imagemagick_trgt::end_scanline(void)
152 convert_color_format(buffer, color_buffer, desc.get_w(), pf, gamma());
154 if(!fwrite(buffer,channels(pf),desc.get_w(),file))