-/*! ========================================================================
-** Sinfg
-** jpeg_trgt Target Module
-** $Id: trgt_jpeg.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $
+/* === S Y N F I G ========================================================= */
+/*! \file trgt_jpeg.cpp
+** \brief jpeg_trgt Target Module
**
-** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+** $Id$
**
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
**
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** 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 ===========================================================
**
/* === H E A D E R S ======================================================= */
-#define SINFG_TARGET
+#define SYNFIG_TARGET
#ifdef USING_PCH
# include "pch.h"
/* === M A C R O S ========================================================= */
-using namespace sinfg;
+using namespace synfig;
using namespace std;
using namespace etl;
/* === G L O B A L S ======================================================= */
-SINFG_TARGET_INIT(jpeg_trgt);
-SINFG_TARGET_SET_NAME(jpeg_trgt,"jpeg");
-SINFG_TARGET_SET_EXT(jpeg_trgt,"jpg");
-SINFG_TARGET_SET_VERSION(jpeg_trgt,"0.1");
-SINFG_TARGET_SET_CVS_ID(jpeg_trgt,"$Id: trgt_jpeg.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $");
+SYNFIG_TARGET_INIT(jpeg_trgt);
+SYNFIG_TARGET_SET_NAME(jpeg_trgt,"jpeg");
+SYNFIG_TARGET_SET_EXT(jpeg_trgt,"jpg");
+SYNFIG_TARGET_SET_VERSION(jpeg_trgt,"0.1");
+SYNFIG_TARGET_SET_CVS_ID(jpeg_trgt,"$Id$");
/* === M E T H O D S ======================================================= */
buffer=NULL;
ready=false;
quality=95;
- color_buffer=0;
+ color_buffer=0;
set_remove_alpha();
}
}
bool
-jpeg_trgt::start_frame(sinfg::ProgressCallback *callback)
+jpeg_trgt::start_frame(synfig::ProgressCallback *callback)
{
int w=desc.get_w(),h=desc.get_h();
-
+
if(file && file!=stdout)
fclose(file);
if(filename=="-")
}
else if(multi_image)
{
- String
- newfilename(filename),
- ext(find(filename.begin(),filename.end(),'.'),filename.end());
- newfilename.erase(find(newfilename.begin(),newfilename.end(),'.'),newfilename.end());
-
- newfilename+=etl::strprintf("%04d",imagecount)+ext;
- file=fopen(newfilename.c_str(),"wb");
+ String newfilename(filename_sans_extension(filename) +
+ etl::strprintf(".%04d",imagecount) +
+ filename_extension(filename));
+ file=fopen(newfilename.c_str(),POPEN_BINARY_WRITE_TYPE);
if(callback)callback->task(newfilename);
}
else
{
- file=fopen(filename.c_str(),"wb");
+ file=fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE);
if(callback)callback->task(filename);
}
-
+
if(!file)
return false;
-
+
delete [] buffer;
buffer=new unsigned char[3*w];
-
+
delete [] color_buffer;
color_buffer=new Color[w];
* Here we just illustrate the use of quality (quantization table) scaling:
*/
jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
-
+
/* Step 4: Start compressor */
-
+
/* TRUE ensures that we will write a complete interchange-JPEG file.
* Pass TRUE unless you are very sure of what you're doing.
*/
jpeg_start_compress(&cinfo, TRUE);
-
+
ready=true;
return true;
}
}
Color *
-jpeg_trgt::start_scanline(int scanline)
+jpeg_trgt::start_scanline(int /*scanline*/)
{
return color_buffer;
}