Kill off synfig ./bootstrap
[synfig.git] / synfig-core / trunk / src / modules / mod_imagemagick / trgt_imagemagick.cpp
index 610390a..88dd95a 100644 (file)
@@ -1,7 +1,9 @@
-/*! ========================================================================
-** Synfig
-** ppm Target Module
-** $Id: trgt_imagemagick.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $
+/* === S Y N F I G ========================================================= */
+/*!    \file trgt_imagemagick.cpp
+**     \brief ppm Target Module
+**
+**     \legal
+** $Id$
 **
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **
@@ -14,6 +16,7 @@
 **     but WITHOUT ANY WARRANTY; without even the implied warranty of
 **     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 **     General Public License for more details.
+**     \endlegal
 **
 ** === N O T E S ===========================================================
 **
@@ -52,7 +55,7 @@ SYNFIG_TARGET_INIT(imagemagick_trgt);
 SYNFIG_TARGET_SET_NAME(imagemagick_trgt,"imagemagick");
 SYNFIG_TARGET_SET_EXT(imagemagick_trgt,"miff");
 SYNFIG_TARGET_SET_VERSION(imagemagick_trgt,"0.1");
-SYNFIG_TARGET_SET_CVS_ID(imagemagick_trgt,"$Id: trgt_imagemagick.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $");
+SYNFIG_TARGET_SET_CVS_ID(imagemagick_trgt,"$Id$");
 
 /* === M E T H O D S ======================================================= */
 
@@ -77,8 +80,7 @@ imagemagick_trgt::~imagemagick_trgt()
 bool
 imagemagick_trgt::set_rend_desc(RendDesc *given_desc)
 {
-       String  ext(find(filename.begin(),filename.end(),'.')+1,filename.end());
-       if(ext=="xpm")
+       if(filename_extension(filename) == ".xpm")
                pf=PF_RGB;
        else
                pf=PF_RGB|PF_A;
@@ -111,19 +113,30 @@ imagemagick_trgt::end_frame()
                pclose(file);
        }
        file=NULL;
+       imagecount++;
 }
 
 bool
 imagemagick_trgt::start_frame(synfig::ProgressCallback *cb)
 {
        string command;
+       string newfilename;
 
-       if(channels(pf)==4)
-               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());
+       if (multi_image)
+               newfilename = (filename_sans_extension(filename) +
+                                          etl::strprintf(".%04d",imagecount) +
+                                          filename_extension(filename));
        else
-               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());
+               newfilename = filename;
+
+       command=strprintf("convert -depth 8 -size %dx%d rgb%s:-[0] -density %dx%d \"%s\"\n",
+                                         desc.get_w(), desc.get_h(),                                   // size
+                                         ((channels(pf) == 4) ? "a" : ""),                             // rgba or rgb?
+                                         round_to_int(desc.get_x_res()/39.3700787402), // density
+                                         round_to_int(desc.get_y_res()/39.3700787402),
+                                         newfilename.c_str());
 
-       file=popen(command.c_str(),"w");
+       file=popen(command.c_str(),POPEN_BINARY_WRITE_TYPE);
 
        if(!file)
        {
@@ -139,7 +152,7 @@ imagemagick_trgt::start_frame(synfig::ProgressCallback *cb)
 }
 
 Color *
-imagemagick_trgt::start_scanline(int scanline)
+imagemagick_trgt::start_scanline(int /*scanline*/)
 {
        return color_buffer;
 }