view release on metacpan or search on metacpan
src/Source/FreeImage/PluginJPEG.cpp view on Meta::CPAN
/// start of buffer
JOCTET * buffer;
/// have we gotten any data yet ?
boolean start_of_file;
} SourceManager;
typedef struct tagDestinationManager {
/// public fields
struct jpeg_destination_mgr pub;
/// destination stream
fi_handle outfile;
FreeImageIO *m_io;
/// start of buffer
JOCTET * buffer;
} DestinationManager;
typedef SourceManager* freeimage_src_ptr;
typedef DestinationManager* freeimage_dst_ptr;
typedef ErrorManager* freeimage_error_ptr;
// ----------------------------------------------------------
src/Source/FreeImage/PluginJPEG.cpp view on Meta::CPAN
Then reset the pointer & count to the start of the buffer, and
return TRUE indicating that the buffer has been dumped.
free_in_buffer must be set to a positive value when TRUE is
returned. A FALSE return should only be used when I/O suspension is
desired.
*/
METHODDEF(boolean)
empty_output_buffer (j_compress_ptr cinfo) {
freeimage_dst_ptr dest = (freeimage_dst_ptr) cinfo->dest;
if (dest->m_io->write_proc(dest->buffer, 1, OUTPUT_BUF_SIZE, dest->outfile) != OUTPUT_BUF_SIZE) {
// let the memory manager delete any temp files before we die
jpeg_destroy((j_common_ptr)cinfo);
JPEG_EXIT((j_common_ptr)cinfo, JERR_FILE_WRITE);
}
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
return TRUE;
src/Source/FreeImage/PluginJPEG.cpp view on Meta::CPAN
*/
METHODDEF(void)
term_destination (j_compress_ptr cinfo) {
freeimage_dst_ptr dest = (freeimage_dst_ptr) cinfo->dest;
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
// write any data remaining in the buffer
if (datacount > 0) {
if (dest->m_io->write_proc(dest->buffer, 1, (unsigned int)datacount, dest->outfile) != datacount) {
// let the memory manager delete any temp files before we die
jpeg_destroy((j_common_ptr)cinfo);
JPEG_EXIT((j_common_ptr)cinfo, JERR_FILE_WRITE);
}
}
}
// ----------------------------------------------------------
// Source manager
src/Source/FreeImage/PluginJPEG.cpp view on Meta::CPAN
src->pub.bytes_in_buffer = 0; // forces fill_input_buffer on first read
src->pub.next_input_byte = NULL; // until buffer loaded
}
/**
Prepare for output to a stdio stream.
The caller must have already opened the stream, and is responsible
for closing it after finishing compression.
*/
GLOBAL(void)
jpeg_freeimage_dst (j_compress_ptr cinfo, fi_handle outfile, FreeImageIO *io) {
freeimage_dst_ptr dest;
if (cinfo->dest == NULL) {
cinfo->dest = (struct jpeg_destination_mgr *)(*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(DestinationManager));
}
dest = (freeimage_dst_ptr) cinfo->dest;
dest->pub.init_destination = init_destination;
dest->pub.empty_output_buffer = empty_output_buffer;
dest->pub.term_destination = term_destination;
dest->outfile = outfile;
dest->m_io = io;
}
// ----------------------------------------------------------
// Special markers read functions
// ----------------------------------------------------------
/**
Read JPEG_COM marker (comment)
*/
src/Source/FreeImageLib/FreeImageLib.2013.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
src/Source/FreeImageLib/FreeImageLib.2013.vcxproj.filters view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{7c15da45-1330-439d-bd4d-2dd68052fa6a}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Source Files\Quantizers">
<UniqueIdentifier>{e42380d3-5a98-4e9f-8b7b-115a51987c46}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Conversion">
src/Source/FreeImageToolkit/JPEGTransform.cpp view on Meta::CPAN
#include "FreeImage.h"
#include "Utilities.h"
#include "FreeImageIO.h"
// ----------------------------------------------------------
// Source manager & Destination manager setup
// (see PluginJPEG.cpp)
// ----------------------------------------------------------
void jpeg_freeimage_src(j_decompress_ptr cinfo, fi_handle infile, FreeImageIO *io);
void jpeg_freeimage_dst(j_compress_ptr cinfo, fi_handle outfile, FreeImageIO *io);
// ----------------------------------------------------------
// Error handling
// (see also PluginJPEG.cpp)
// ----------------------------------------------------------
/**
Receives control for a fatal error. Information sufficient to
generate the error message has been stored in cinfo->err; call
output_message to display it. Control must NOT return to the caller;
src/Source/LibJPEG/LibJPEG.2013.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
src/Source/LibJPEG/LibJPEG.2013.vcxproj.filters view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{2fa193f8-a23e-4078-8ff6-6bf5b443df38}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{66abfe69-3f1d-455a-afad-997a86d09b0b}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
src/Source/LibJPEG/cjpeg.c view on Meta::CPAN
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2013 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains a command-line user interface for the JPEG compressor.
* It should work on any system with Unix- or MS-DOS-style command lines.
*
* Two different command line styles are permitted, depending on the
* compile-time switch TWO_FILE_COMMANDLINE:
* cjpeg [options] inputfile outputfile
* cjpeg [options] [inputfile]
* In the second style, output is always to standard output, which you'd
* normally redirect to a file or pipe to some other program. Input is
* either from a named file or from standard input (typically redirected).
* The second style is convenient on Unix but is unhelpful on systems that
* don't support pipes. Also, you MUST use the first style if your system
* doesn't do binary I/O to stdin/stdout.
* To simplify script writing, the "-outfile" switch is provided. The syntax
* cjpeg [options] -outfile outputfile inputfile
* works regardless of which command line style is used.
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "jversion.h" /* for version message */
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */
#ifdef __MWERKS__
#include <SIOUX.h> /* Metrowerks needs this */
#include <console.h> /* ... and this */
src/Source/LibJPEG/cjpeg.c view on Meta::CPAN
/*
* Argument-parsing code.
* The switch parser is designed to be useful with DOS-style command line
* syntax, ie, intermixed switches and file names, where only the switches
* to the left of a given file name affect processing of that file.
* The main program in this file doesn't actually use this capability...
*/
static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
LOCAL(void)
usage (void)
/* complain about bad command line */
{
fprintf(stderr, "usage: %s [switches] ", progname);
#ifdef TWO_FILE_COMMANDLINE
fprintf(stderr, "inputfile outputfile\n");
#else
fprintf(stderr, "[inputfile]\n");
#endif
fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n");
fprintf(stderr, " -grayscale Create monochrome JPEG file\n");
fprintf(stderr, " -rgb Create RGB JPEG file\n");
#ifdef ENTROPY_OPT_SUPPORTED
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
#endif
#ifdef C_PROGRESSIVE_SUPPORTED
src/Source/LibJPEG/cjpeg.c view on Meta::CPAN
#ifdef DCT_FLOAT_SUPPORTED
fprintf(stderr, " -dct float Use floating-point DCT method%s\n",
(JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
#endif
fprintf(stderr, " -nosmooth Don't use high-quality downsampling\n");
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
#ifdef INPUT_SMOOTHING_SUPPORTED
fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n");
#endif
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
fprintf(stderr, " -outfile name Specify name for output file\n");
fprintf(stderr, " -verbose or -debug Emit debug output\n");
fprintf(stderr, "Switches for wizards:\n");
fprintf(stderr, " -baseline Force baseline quantization tables\n");
fprintf(stderr, " -qtables file Use quantization tables given in file\n");
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
#ifdef C_MULTISCAN_FILES_SUPPORTED
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
#endif
exit(EXIT_FAILURE);
src/Source/LibJPEG/cjpeg.c view on Meta::CPAN
char * qtablefile = NULL; /* saves -qtables filename if any */
char * qslotsarg = NULL; /* saves -qslots parm if any */
char * samplearg = NULL; /* saves -sample parm if any */
char * scansarg = NULL; /* saves -scans parm if any */
/* Set up default JPEG parameters. */
force_baseline = FALSE; /* by default, allow 16-bit quantizers */
simple_progressive = FALSE;
is_targa = FALSE;
outfilename = NULL;
cinfo->err->trace_level = 0;
/* Scan command line options, adjust parameters */
for (argn = 1; argn < argc; argn++) {
arg = argv[argn];
if (*arg != '-') {
/* Not a switch, must be a file name argument */
if (argn <= last_file_arg_seen) {
outfilename = NULL; /* -outfile applies to just one input file */
continue; /* ignore this name if previously processed */
}
break; /* else done parsing switches */
}
arg++; /* advance past switch marker character */
if (keymatch(arg, "arithmetic", 1)) {
/* Use arithmetic coding. */
#ifdef C_ARITH_CODING_SUPPORTED
cinfo->arith_code = TRUE;
src/Source/LibJPEG/cjpeg.c view on Meta::CPAN
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
/* Enable entropy parm optimization. */
#ifdef ENTROPY_OPT_SUPPORTED
cinfo->optimize_coding = TRUE;
#else
fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n",
progname);
exit(EXIT_FAILURE);
#endif
} else if (keymatch(arg, "outfile", 4)) {
/* Set output file name. */
if (++argn >= argc) /* advance to next argument */
usage();
outfilename = argv[argn]; /* save it away for later use */
} else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;
/* We must postpone execution until num_components is known. */
#else
fprintf(stderr, "%s: sorry, progressive output was not compiled\n",
progname);
exit(EXIT_FAILURE);
src/Source/LibJPEG/cjpeg.c view on Meta::CPAN
/* Scan command line to find file names.
* It is convenient to use just one switch-parsing routine, but the switch
* values read here are ignored; we will rescan the switches after opening
* the input file.
*/
file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
#ifdef TWO_FILE_COMMANDLINE
/* Must have either -outfile switch or explicit output file name */
if (outfilename == NULL) {
if (file_index != argc-2) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
outfilename = argv[file_index+1];
} else {
if (file_index != argc-1) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
}
#else
/* Unix style: expect zero or one file name */
if (file_index < argc-1) {
src/Source/LibJPEG/cjpeg.c view on Meta::CPAN
if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
exit(EXIT_FAILURE);
}
} else {
/* default input file is stdin */
input_file = read_stdin();
}
/* Open the output file. */
if (outfilename != NULL) {
if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
exit(EXIT_FAILURE);
}
} else {
/* default output file is stdout */
output_file = write_stdout();
}
#ifdef PROGRESS_REPORT
start_progress_monitor((j_common_ptr) &cinfo, &progress);
#endif
src/Source/LibJPEG/ckconfig.c view on Meta::CPAN
#ifdef HAVE_PROTOTYPES
int main (int argc, char ** argv)
#else
int main (argc, argv)
int argc;
char ** argv;
#endif
{
char signed_char_check = (char) (-67);
FILE *outfile;
/* Attempt to write jconfig.h */
if ((outfile = fopen("jconfig.h", "w")) == NULL) {
printf("Failed to write jconfig.h\n");
return 1;
}
/* Write out all the info */
fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n");
fprintf(outfile, "/* see jconfig.txt for explanations */\n\n");
#ifdef HAVE_PROTOTYPES
fprintf(outfile, "#define HAVE_PROTOTYPES\n");
#else
fprintf(outfile, "#undef HAVE_PROTOTYPES\n");
#endif
#ifdef HAVE_UNSIGNED_CHAR
fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n");
#else
fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n");
#endif
#ifdef HAVE_UNSIGNED_SHORT
fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n");
#else
fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n");
#endif
#ifdef HAVE_VOID
fprintf(outfile, "/* #define void char */\n");
#else
fprintf(outfile, "#define void char\n");
#endif
#ifdef HAVE_CONST
fprintf(outfile, "/* #define const */\n");
#else
fprintf(outfile, "#define const\n");
#endif
if (is_char_signed((int) signed_char_check))
fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n");
else
fprintf(outfile, "#define CHAR_IS_UNSIGNED\n");
#ifdef HAVE_STDDEF_H
fprintf(outfile, "#define HAVE_STDDEF_H\n");
#else
fprintf(outfile, "#undef HAVE_STDDEF_H\n");
#endif
#ifdef HAVE_STDLIB_H
fprintf(outfile, "#define HAVE_STDLIB_H\n");
#else
fprintf(outfile, "#undef HAVE_STDLIB_H\n");
#endif
#ifdef NEED_BSD_STRINGS
fprintf(outfile, "#define NEED_BSD_STRINGS\n");
#else
fprintf(outfile, "#undef NEED_BSD_STRINGS\n");
#endif
#ifdef NEED_SYS_TYPES_H
fprintf(outfile, "#define NEED_SYS_TYPES_H\n");
#else
fprintf(outfile, "#undef NEED_SYS_TYPES_H\n");
#endif
fprintf(outfile, "#undef NEED_FAR_POINTERS\n");
#ifdef NEED_SHORT_EXTERNAL_NAMES
fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n");
#else
fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n");
#endif
#ifdef INCOMPLETE_TYPES_BROKEN
fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n");
#else
fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n");
#endif
fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n");
if (is_shifting_signed(-0x7F7E80B1L))
fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n");
else
fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n");
fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n");
fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n");
fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n");
fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n");
fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n");
fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n");
fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n");
fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n");
fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n");
fprintf(outfile, "#undef DONT_USE_B_MODE\n");
fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n");
fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n");
/* Close the jconfig.h file */
fclose(outfile);
/* User report */
printf("Configuration check for Independent JPEG Group's software done.\n");
printf("\nI have written the jconfig.h file for you.\n\n");
#ifdef HAVE_PROTOTYPES
printf("You should use makefile.ansi as the starting point for your Makefile.\n");
#else
printf("You should use makefile.unix as the starting point for your Makefile.\n");
#endif
src/Source/LibJPEG/djpeg.c view on Meta::CPAN
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2009-2013 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains a command-line user interface for the JPEG decompressor.
* It should work on any system with Unix- or MS-DOS-style command lines.
*
* Two different command line styles are permitted, depending on the
* compile-time switch TWO_FILE_COMMANDLINE:
* djpeg [options] inputfile outputfile
* djpeg [options] [inputfile]
* In the second style, output is always to standard output, which you'd
* normally redirect to a file or pipe to some other program. Input is
* either from a named file or from standard input (typically redirected).
* The second style is convenient on Unix but is unhelpful on systems that
* don't support pipes. Also, you MUST use the first style if your system
* doesn't do binary I/O to stdin/stdout.
* To simplify script writing, the "-outfile" switch is provided. The syntax
* djpeg [options] -outfile outputfile inputfile
* works regardless of which command line style is used.
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "jversion.h" /* for version message */
#include <ctype.h> /* to declare isprint() */
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */
#ifdef __MWERKS__
src/Source/LibJPEG/djpeg.c view on Meta::CPAN
/*
* Argument-parsing code.
* The switch parser is designed to be useful with DOS-style command line
* syntax, ie, intermixed switches and file names, where only the switches
* to the left of a given file name affect processing of that file.
* The main program in this file doesn't actually use this capability...
*/
static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
LOCAL(void)
usage (void)
/* complain about bad command line */
{
fprintf(stderr, "usage: %s [switches] ", progname);
#ifdef TWO_FILE_COMMANDLINE
fprintf(stderr, "inputfile outputfile\n");
#else
fprintf(stderr, "[inputfile]\n");
#endif
fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -colors N Reduce image to no more than N colors\n");
fprintf(stderr, " -fast Fast, low-quality processing\n");
fprintf(stderr, " -grayscale Force grayscale output\n");
#ifdef IDCT_SCALING_SUPPORTED
fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
#endif
#ifdef BMP_SUPPORTED
src/Source/LibJPEG/djpeg.c view on Meta::CPAN
fprintf(stderr, " -dither none Don't use dithering in quantization\n");
fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n");
#ifdef QUANT_2PASS_SUPPORTED
fprintf(stderr, " -map FILE Map to colors used in named image file\n");
#endif
fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n");
#ifdef QUANT_1PASS_SUPPORTED
fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n");
#endif
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
fprintf(stderr, " -outfile name Specify name for output file\n");
fprintf(stderr, " -verbose or -debug Emit debug output\n");
exit(EXIT_FAILURE);
}
LOCAL(int)
parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
int last_file_arg_seen, boolean for_real)
/* Parse optional switches.
* Returns argv[] index of first file-name argument (== argc if none).
src/Source/LibJPEG/djpeg.c view on Meta::CPAN
* (Pass 0 for last_file_arg_seen on the first or only iteration.)
* for_real is FALSE on the first (dummy) pass; we may skip any expensive
* processing.
*/
{
int argn;
char * arg;
/* Set up default JPEG parameters. */
requested_fmt = DEFAULT_FMT; /* set default output file format */
outfilename = NULL;
cinfo->err->trace_level = 0;
/* Scan command line options, adjust parameters */
for (argn = 1; argn < argc; argn++) {
arg = argv[argn];
if (*arg != '-') {
/* Not a switch, must be a file name argument */
if (argn <= last_file_arg_seen) {
outfilename = NULL; /* -outfile applies to just one input file */
continue; /* ignore this name if previously processed */
}
break; /* else done parsing switches */
}
arg++; /* advance past switch marker character */
if (keymatch(arg, "bmp", 1)) {
/* BMP output format. */
requested_fmt = FMT_BMP;
src/Source/LibJPEG/djpeg.c view on Meta::CPAN
cinfo->do_fancy_upsampling = FALSE;
} else if (keymatch(arg, "onepass", 3)) {
/* Use fast one-pass quantization. */
cinfo->two_pass_quantize = FALSE;
} else if (keymatch(arg, "os2", 3)) {
/* BMP output format (OS/2 flavor). */
requested_fmt = FMT_OS2;
} else if (keymatch(arg, "outfile", 4)) {
/* Set output file name. */
if (++argn >= argc) /* advance to next argument */
usage();
outfilename = argv[argn]; /* save it away for later use */
} else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {
/* PPM/PGM output format. */
requested_fmt = FMT_PPM;
} else if (keymatch(arg, "rle", 1)) {
/* RLE output format. */
requested_fmt = FMT_RLE;
} else if (keymatch(arg, "scale", 1)) {
src/Source/LibJPEG/djpeg.c view on Meta::CPAN
/* It is convenient to use just one switch-parsing routine, but the switch
* values read here are ignored; we will rescan the switches after opening
* the input file.
* (Exception: tracing level set here controls verbosity for COM markers
* found during jpeg_read_header...)
*/
file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
#ifdef TWO_FILE_COMMANDLINE
/* Must have either -outfile switch or explicit output file name */
if (outfilename == NULL) {
if (file_index != argc-2) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
outfilename = argv[file_index+1];
} else {
if (file_index != argc-1) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
}
#else
/* Unix style: expect zero or one file name */
if (file_index < argc-1) {
src/Source/LibJPEG/djpeg.c view on Meta::CPAN
if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
exit(EXIT_FAILURE);
}
} else {
/* default input file is stdin */
input_file = read_stdin();
}
/* Open the output file. */
if (outfilename != NULL) {
if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
exit(EXIT_FAILURE);
}
} else {
/* default output file is stdout */
output_file = write_stdout();
}
#ifdef PROGRESS_REPORT
start_progress_monitor((j_common_ptr) &cinfo, &progress);
#endif
src/Source/LibJPEG/example.c view on Meta::CPAN
/* This struct represents a JPEG error handler. It is declared separately
* because applications often want to supply a specialized error handler
* (see the second half of this file for an example). But here we just
* take the easy way out and use the standard error handler, which will
* print a message on stderr and call exit() if compression fails.
* Note that this struct must live as long as the main JPEG parameter
* struct, to avoid dangling-pointer problems.
*/
struct jpeg_error_mgr jerr;
/* More stuff */
FILE * outfile; /* target file */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
/* Step 1: allocate and initialize JPEG compression object */
/* We have to set up the error handler first, in case the initialization
* step fails. (Unlikely, but it could happen if you are out of memory.)
* This routine fills in the contents of struct jerr, and returns jerr's
* address which we place into the link field in cinfo.
*/
src/Source/LibJPEG/example.c view on Meta::CPAN
jpeg_create_compress(&cinfo);
/* Step 2: specify data destination (eg, a file) */
/* Note: steps 2 and 3 can be done in either order. */
/* Here we use the library-supplied code to send compressed data to a
* stdio stream. You can also write your own code to do something else.
* VERY IMPORTANT: use "b" option to fopen() if you are on a machine that
* requires it in order to write binary files.
*/
if ((outfile = fopen(filename, "wb")) == NULL) {
fprintf(stderr, "can't open %s\n", filename);
exit(1);
}
jpeg_stdio_dest(&cinfo, outfile);
/* Step 3: set parameters for compression */
/* First we supply a description of the input image.
* Four fields of the cinfo struct must be filled in:
*/
cinfo.image_width = image_width; /* image width and height, in pixels */
cinfo.image_height = image_height;
cinfo.input_components = 3; /* # of color components per pixel */
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
src/Source/LibJPEG/example.c view on Meta::CPAN
* more than one scanline at a time if that's more convenient.
*/
row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
/* Step 6: Finish compression */
jpeg_finish_compress(&cinfo);
/* After finish_compress, we can close the output file. */
fclose(outfile);
/* Step 7: release JPEG compression object */
/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_compress(&cinfo);
/* And we're done! */
}
src/Source/LibJPEG/install.txt view on Meta::CPAN
of this (it's for VMS systems that have no make-like utility).
Here are comments about some specific configuration decisions you'll
need to make:
Command line style
------------------
These programs can use a Unix-like command line style which supports
redirection and piping, like this:
cjpeg inputfile >outputfile
cjpeg <inputfile >outputfile
source program | cjpeg >outputfile
The simpler "two file" command line style is just
cjpeg inputfile outputfile
You may prefer the two-file style, particularly if you don't have pipes.
You MUST use two-file style on any system that doesn't cope well with binary
data fed through stdin/stdout; this is true for some MS-DOS compilers, for
example. If you're not on a Unix system, it's safest to assume you need
two-file style. (But if your compiler provides either the Posix-standard
fdopen() library routine or a Microsoft-compatible setmode() routine, you
can safely use the Unix command line style, by defining USE_FDOPEN or
USE_SETMODE respectively.)
src/Source/LibJPEG/install.txt view on Meta::CPAN
as long should take care of that one.
If the cjpeg test run fails with "Missing Huffman code table entry", it's a
good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the
configuration step and run ckconfig.c. (This is a good plan for any other
test failure, too.)
If you are using Unix (one-file) command line style on a non-Unix system,
it's a good idea to check that binary I/O through stdin/stdout actually
works. You should get the same results from "djpeg <testorig.jpg >out.ppm"
as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all
use the latter style and therefore do not exercise stdin/stdout! If this
check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined.
If it still doesn't work, better use two-file style.
If you chose a memory manager other than jmemnobs.c, you should test that
temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg"
and make sure its output matches testimg.bmp. If you have any really large
images handy, try compressing them with -optimize and/or decompressing with
-colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large.
src/Source/LibJPEG/jdatadst.c view on Meta::CPAN
extern void * malloc JPP((size_t size));
extern void free JPP((void *ptr));
#endif
/* Expanded data destination object for stdio output */
typedef struct {
struct jpeg_destination_mgr pub; /* public fields */
FILE * outfile; /* target stream */
JOCTET * buffer; /* start of buffer */
} my_destination_mgr;
typedef my_destination_mgr * my_dest_ptr;
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
/* Expanded data destination object for memory output */
src/Source/LibJPEG/jdatadst.c view on Meta::CPAN
* indicate where the restart point will be if the current call returns FALSE.
* Data beyond this point will be regenerated after resumption, so do not
* write it out when emptying the buffer externally.
*/
METHODDEF(boolean)
empty_output_buffer (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
(size_t) OUTPUT_BUF_SIZE)
ERREXIT(cinfo, JERR_FILE_WRITE);
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
return TRUE;
}
METHODDEF(boolean)
src/Source/LibJPEG/jdatadst.c view on Meta::CPAN
*/
METHODDEF(void)
term_destination (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
/* Write any data remaining in the buffer */
if (datacount > 0) {
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
ERREXIT(cinfo, JERR_FILE_WRITE);
}
fflush(dest->outfile);
/* Make sure we wrote the output file OK */
if (ferror(dest->outfile))
ERREXIT(cinfo, JERR_FILE_WRITE);
}
METHODDEF(void)
term_mem_destination (j_compress_ptr cinfo)
{
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
*dest->outbuffer = dest->buffer;
*dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
}
/*
* Prepare for output to a stdio stream.
* The caller must have already opened the stream, and is responsible
* for closing it after finishing compression.
*/
GLOBAL(void)
jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
{
my_dest_ptr dest;
/* The destination object is made permanent so that multiple JPEG images
* can be written to the same file without re-executing jpeg_stdio_dest.
* This makes it dangerous to use this manager and a different destination
* manager serially with the same JPEG object, because their private object
* sizes may be different. Caveat programmer.
*/
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_destination_mgr));
}
dest = (my_dest_ptr) cinfo->dest;
dest->pub.init_destination = init_destination;
dest->pub.empty_output_buffer = empty_output_buffer;
dest->pub.term_destination = term_destination;
dest->outfile = outfile;
}
/*
* Prepare for output to a memory buffer.
* The caller may supply an own initial buffer with appropriate size.
* Otherwise, or when the actual data output exceeds the given size,
* the library adapts the buffer size as necessary.
* The standard library functions malloc/free are used for allocating
* larger memory, so the buffer is available to the application after
src/Source/LibJPEG/jpeglib.h view on Meta::CPAN
EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo,
int version, size_t structsize));
EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo,
int version, size_t structsize));
/* Destruction of JPEG compression objects */
EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo));
EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
/* Standard data source and destination managers: stdio streams. */
/* Caller is responsible for opening the file before and closing after. */
EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
/* Data source and destination managers: memory buffers. */
EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
unsigned char ** outbuffer,
unsigned long * outsize));
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
unsigned char * inbuffer,
unsigned long insize));
src/Source/LibJPEG/jpegtran.c view on Meta::CPAN
/*
* Argument-parsing code.
* The switch parser is designed to be useful with DOS-style command line
* syntax, ie, intermixed switches and file names, where only the switches
* to the left of a given file name affect processing of that file.
* The main program in this file doesn't actually use this capability...
*/
static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
static char * scaleoption; /* -scale switch */
static JCOPY_OPTION copyoption; /* -copy switch */
static jpeg_transform_info transformoption; /* image transformation options */
LOCAL(void)
usage (void)
/* complain about bad command line */
{
fprintf(stderr, "usage: %s [switches] ", progname);
#ifdef TWO_FILE_COMMANDLINE
fprintf(stderr, "inputfile outputfile\n");
#else
fprintf(stderr, "[inputfile]\n");
#endif
fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -copy none Copy no extra markers from source file\n");
fprintf(stderr, " -copy comments Copy only comment markers (default)\n");
fprintf(stderr, " -copy all Copy all extra markers\n");
#ifdef ENTROPY_OPT_SUPPORTED
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
#endif
#ifdef C_PROGRESSIVE_SUPPORTED
src/Source/LibJPEG/jpegtran.c view on Meta::CPAN
fprintf(stderr, " -transverse Transverse transpose image\n");
fprintf(stderr, " -trim Drop non-transformable edge blocks\n");
fprintf(stderr, " -wipe WxH+X+Y Wipe (gray out) a rectangular subarea\n");
#endif
fprintf(stderr, "Switches for advanced users:\n");
#ifdef C_ARITH_CODING_SUPPORTED
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
#endif
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
fprintf(stderr, " -outfile name Specify name for output file\n");
fprintf(stderr, " -verbose or -debug Emit debug output\n");
fprintf(stderr, "Switches for wizards:\n");
#ifdef C_MULTISCAN_FILES_SUPPORTED
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
#endif
exit(EXIT_FAILURE);
}
LOCAL(void)
src/Source/LibJPEG/jpegtran.c view on Meta::CPAN
* processing.
*/
{
int argn;
char * arg;
boolean simple_progressive;
char * scansarg = NULL; /* saves -scans parm if any */
/* Set up default JPEG parameters. */
simple_progressive = FALSE;
outfilename = NULL;
scaleoption = NULL;
copyoption = JCOPYOPT_DEFAULT;
transformoption.transform = JXFORM_NONE;
transformoption.perfect = FALSE;
transformoption.trim = FALSE;
transformoption.force_grayscale = FALSE;
transformoption.crop = FALSE;
cinfo->err->trace_level = 0;
/* Scan command line options, adjust parameters */
for (argn = 1; argn < argc; argn++) {
arg = argv[argn];
if (*arg != '-') {
/* Not a switch, must be a file name argument */
if (argn <= last_file_arg_seen) {
outfilename = NULL; /* -outfile applies to just one input file */
continue; /* ignore this name if previously processed */
}
break; /* else done parsing switches */
}
arg++; /* advance past switch marker character */
if (keymatch(arg, "arithmetic", 1)) {
/* Use arithmetic coding. */
#ifdef C_ARITH_CODING_SUPPORTED
cinfo->arith_code = TRUE;
src/Source/LibJPEG/jpegtran.c view on Meta::CPAN
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
/* Enable entropy parm optimization. */
#ifdef ENTROPY_OPT_SUPPORTED
cinfo->optimize_coding = TRUE;
#else
fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n",
progname);
exit(EXIT_FAILURE);
#endif
} else if (keymatch(arg, "outfile", 4)) {
/* Set output file name. */
if (++argn >= argc) /* advance to next argument */
usage();
outfilename = argv[argn]; /* save it away for later use */
} else if (keymatch(arg, "perfect", 2)) {
/* Fail if there is any partial edge MCUs that the transform can't
* handle. */
transformoption.perfect = TRUE;
} else if (keymatch(arg, "progressive", 2)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;
src/Source/LibJPEG/jpegtran.c view on Meta::CPAN
* opening the input file. Also note that most of the switches affect the
* destination JPEG object, so we parse into that and then copy over what
* needs to affects the source too.
*/
file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);
jsrcerr.trace_level = jdsterr.trace_level;
srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use;
#ifdef TWO_FILE_COMMANDLINE
/* Must have either -outfile switch or explicit output file name */
if (outfilename == NULL) {
if (file_index != argc-2) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
outfilename = argv[file_index+1];
} else {
if (file_index != argc-1) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
}
#else
/* Unix style: expect zero or one file name */
if (file_index < argc-1) {
src/Source/LibJPEG/jpegtran.c view on Meta::CPAN
* Note: we assume that jpeg_read_coefficients consumed all input
* until JPEG_REACHED_EOI, and that jpeg_finish_decompress will
* only consume more while (! cinfo->inputctl->eoi_reached).
* We cannot call jpeg_finish_decompress here since we still need the
* virtual arrays allocated from the source object for processing.
*/
if (fp != stdin)
fclose(fp);
/* Open the output file. */
if (outfilename != NULL) {
if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename);
exit(EXIT_FAILURE);
}
} else {
/* default output file is stdout */
fp = write_stdout();
}
/* Adjust default compression parameters by re-parsing the options */
file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
src/Source/LibJPEG/libjpeg.txt view on Meta::CPAN
2. Specify the destination for the compressed data (eg, a file).
As previously mentioned, the JPEG library delivers compressed data to a
"data destination" module. The library includes one data destination
module which knows how to write to a stdio stream. You can use your own
destination module if you want to do something else, as discussed later.
If you use the standard destination module, you must open the target stdio
stream beforehand. Typical code for this step looks like:
FILE * outfile;
...
if ((outfile = fopen(filename, "wb")) == NULL) {
fprintf(stderr, "can't open %s\n", filename);
exit(1);
}
jpeg_stdio_dest(&cinfo, outfile);
where the last line invokes the standard destination module.
WARNING: it is critical that the binary compressed data be delivered to the
output file unchanged. On non-Unix systems the stdio library may perform
newline translation or otherwise corrupt binary data. To suppress this
behavior, you may need to use a "b" option to fopen (as shown above), or use
setmode() or another routine to put the stdio stream in binary mode. See
cjpeg.c and djpeg.c for code that has been found to work on many systems.
src/Source/LibJPEG/rdjpgcom.c view on Meta::CPAN
static const char * progname; /* program name for error messages */
static void
usage (void)
/* complain about bad command line */
{
fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n");
fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname);
fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -raw Display non-printable characters in comments (unsafe)\n");
fprintf(stderr, " -verbose Also display dimensions of JPEG image\n");
exit(EXIT_FAILURE);
}
static int
src/Source/LibJPEG/usage.txt view on Meta::CPAN
On most non-Unix systems, you say:
cjpeg [switches] imagefile jpegfile
or
djpeg [switches] jpegfile imagefile
i.e., both the input and output files are named on the command line. This
style is a little more foolproof, and it loses no functionality if you don't
have pipes. (You can get this style on Unix too, if you prefer, by defining
TWO_FILE_COMMANDLINE when you compile the programs; see install.txt.)
You can also say:
cjpeg [switches] -outfile jpegfile imagefile
or
djpeg [switches] -outfile imagefile jpegfile
This syntax works on all systems, so it is useful for scripts.
The currently supported image file formats are: PPM (PBMPLUS color format),
PGM (PBMPLUS gray-scale format), BMP, Targa, and RLE (Utah Raster Toolkit
format). (RLE is supported only if the URT library is available.)
cjpeg recognizes the input image format automatically, with the exception
of some Targa-format files. You have to tell djpeg which format to generate.
JPEG files are in the defacto standard JFIF file format. There are other,
less widely used JPEG-based file formats, but we don't support them.
src/Source/LibJPEG/usage.txt view on Meta::CPAN
jpegtran works by rearranging the compressed data (DCT coefficients), without
ever fully decoding the image. Therefore, its transformations are lossless:
there is no image degradation at all, which would not be true if you used
djpeg followed by cjpeg to accomplish the same conversion. But by the same
token, jpegtran cannot perform lossy operations such as changing the image
quality.
jpegtran uses a command line syntax similar to cjpeg or djpeg.
On Unix-like systems, you say:
jpegtran [switches] [inputfile] >outputfile
On most non-Unix systems, you say:
jpegtran [switches] inputfile outputfile
where both the input and output files are JPEG files.
To specify the coded JPEG representation used in the output file,
jpegtran accepts a subset of the switches recognized by cjpeg:
-optimize Perform optimization of entropy encoding parameters.
-progressive Create progressive JPEG file.
-arithmetic Use arithmetic coding.
-restart N Emit a JPEG restart marker every N MCU rows, or every
N MCU blocks if "B" is attached to the number.
-scans file Use the scan script given in the specified text file.
src/Source/LibJPEG/usage.txt view on Meta::CPAN
comments from the source file, but discards
any other inessential (for image display) data.
-copy all Copy all extra markers. This setting preserves
miscellaneous markers found in the source file, such
as JFIF thumbnails, Exif data, and Photoshop settings.
In some files these extra markers can be sizable.
The default behavior is -copy comments. (Note: in IJG releases v6 and v6a,
jpegtran always did the equivalent of -copy none.)
Additional switches recognized by jpegtran are:
-outfile filename
-maxmemory N
-verbose
-debug
These work the same as in cjpeg or djpeg.
THE COMMENT UTILITIES
The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
Although the standard doesn't actually define what COM blocks are for, they
src/Source/LibJPEG/usage.txt view on Meta::CPAN
annotations, titles, index terms, etc to your JPEG files, and later retrieve
them as text. COM blocks do not interfere with the image stored in the JPEG
file. The maximum size of a COM block is 64K, but you can have as many of
them as you like in one JPEG file.
We provide two utility programs to display COM block contents and add COM
blocks to a JPEG file.
rdjpgcom searches a JPEG file and prints the contents of any COM blocks on
standard output. The command line syntax is
rdjpgcom [-raw] [-verbose] [inputfilename]
The switch "-raw" (or just "-r") causes rdjpgcom to also output non-printable
characters in comments, which are normally escaped for security reasons.
The switch "-verbose" (or just "-v") causes rdjpgcom to also display the JPEG
image dimensions. If you omit the input file name from the command line,
the JPEG file is read from standard input. (This may not work on some
operating systems, if binary data can't be read from stdin.)
wrjpgcom adds a COM block, containing text you provide, to a JPEG file.
Ordinarily, the COM block is added after any existing COM blocks, but you
can delete the old COM blocks if you wish. wrjpgcom produces a new JPEG
file; it does not modify the input file. DO NOT try to overwrite the input
file by directing wrjpgcom's output back into it; on most systems this will
just destroy your file.
The command line syntax for wrjpgcom is similar to cjpeg's. On Unix-like
systems, it is
wrjpgcom [switches] [inputfilename]
The output file is written to standard output. The input file comes from
the named file, or from standard input if no input file is named.
On most non-Unix systems, the syntax is
wrjpgcom [switches] inputfilename outputfilename
where both input and output file names must be given explicitly.
wrjpgcom understands three switches:
-replace Delete any existing COM blocks from the file.
-comment "Comment text" Supply new COM text on command line.
-cfile name Read text for new COM block from named file.
(Switch names can be abbreviated.) If you have only one line of comment text
to add, you can provide it on the command line with -comment. The comment
text must be surrounded with quotes so that it is treated as a single
argument. Longer comments can be read from a text file.
src/Source/LibJPEG/wrbmp.c view on Meta::CPAN
* Write the colormap.
* Windows uses BGR0 map entries; OS/2 uses BGR entries.
*/
LOCAL(void)
write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest,
int map_colors, int map_entry_size)
{
JSAMPARRAY colormap = cinfo->colormap;
int num_colors = cinfo->actual_number_of_colors;
FILE * outfile = dest->pub.output_file;
int i;
if (colormap != NULL) {
if (cinfo->out_color_components == 3) {
/* Normal case with RGB colormap */
for (i = 0; i < num_colors; i++) {
putc(GETJSAMPLE(colormap[2][i]), outfile);
putc(GETJSAMPLE(colormap[1][i]), outfile);
putc(GETJSAMPLE(colormap[0][i]), outfile);
if (map_entry_size == 4)
putc(0, outfile);
}
} else {
/* Grayscale colormap (only happens with grayscale quantization) */
for (i = 0; i < num_colors; i++) {
putc(GETJSAMPLE(colormap[0][i]), outfile);
putc(GETJSAMPLE(colormap[0][i]), outfile);
putc(GETJSAMPLE(colormap[0][i]), outfile);
if (map_entry_size == 4)
putc(0, outfile);
}
}
} else {
/* If no colormap, must be grayscale data. Generate a linear "map". */
for (i = 0; i < 256; i++) {
putc(i, outfile);
putc(i, outfile);
putc(i, outfile);
if (map_entry_size == 4)
putc(0, outfile);
}
}
/* Pad colormap with zeros to ensure specified number of colormap entries */
if (i > map_colors)
ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i);
for (; i < map_colors; i++) {
putc(0, outfile);
putc(0, outfile);
putc(0, outfile);
if (map_entry_size == 4)
putc(0, outfile);
}
}
METHODDEF(void)
finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
bmp_dest_ptr dest = (bmp_dest_ptr) dinfo;
register FILE * outfile = dest->pub.output_file;
JSAMPARRAY image_ptr;
register JSAMPROW data_ptr;
JDIMENSION row;
register JDIMENSION col;
cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
/* Write the header and colormap */
if (dest->is_os2)
write_os2_header(cinfo, dest);
else
src/Source/LibJPEG/wrbmp.c view on Meta::CPAN
for (row = cinfo->output_height; row > 0; row--) {
if (progress != NULL) {
progress->pub.pass_counter = (long) (cinfo->output_height - row);
progress->pub.pass_limit = (long) cinfo->output_height;
(*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
}
image_ptr = (*cinfo->mem->access_virt_sarray)
((j_common_ptr) cinfo, dest->whole_image, row-1, (JDIMENSION) 1, FALSE);
data_ptr = image_ptr[0];
for (col = dest->row_width; col > 0; col--) {
putc(GETJSAMPLE(*data_ptr), outfile);
data_ptr++;
}
}
if (progress != NULL)
progress->completed_extra_passes++;
/* Make sure we wrote the output file OK */
fflush(outfile);
if (ferror(outfile))
ERREXIT(cinfo, JERR_FILE_WRITE);
}
/*
* The module selection routine for BMP format output.
*/
GLOBAL(djpeg_dest_ptr)
jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
src/Source/LibJPEG/wrjpgcom.c view on Meta::CPAN
/*
* These macros are used to read the input file and write the output file.
* To reuse this code in another application, you might need to change these.
*/
static FILE * infile; /* input JPEG file */
/* Return next input byte, or EOF if no more */
#define NEXTBYTE() getc(infile)
static FILE * outfile; /* output JPEG file */
/* Emit an output byte */
#define PUTBYTE(x) putc((x), outfile)
/* Error exit handler */
#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE))
/* Read one byte, testing for EOF */
static int
read_1_byte (void)
{
src/Source/LibJPEG/wrjpgcom.c view on Meta::CPAN
static void
usage (void)
/* complain about bad command line */
{
fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n");
fprintf(stderr, "You can add to or replace any existing comment(s).\n");
fprintf(stderr, "Usage: %s [switches] ", progname);
#ifdef TWO_FILE_COMMANDLINE
fprintf(stderr, "inputfile outputfile\n");
#else
fprintf(stderr, "[inputfile]\n");
#endif
fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -replace Delete any existing comments\n");
fprintf(stderr, " -comment \"text\" Insert comment with given text\n");
fprintf(stderr, " -cfile name Read comment from named file\n");
fprintf(stderr, "Notice that you must put quotes around the comment text\n");
fprintf(stderr, "when you use -comment.\n");
fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n");
fprintf(stderr, "then the comment text is read from standard input.\n");
src/Source/LibJPEG/wrjpgcom.c view on Meta::CPAN
}
/* Open the output file. */
#ifdef TWO_FILE_COMMANDLINE
/* Must have explicit output file name */
if (argn != argc-2) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]);
exit(EXIT_FAILURE);
}
#else
/* Unix style: expect zero or one file name */
if (argn < argc-1) {
fprintf(stderr, "%s: only one input file\n", progname);
usage();
}
/* default output file is stdout */
#ifdef USE_SETMODE /* need to hack file mode? */
setmode(fileno(stdout), O_BINARY);
#endif
#ifdef USE_FDOPEN /* need to re-open in binary mode? */
if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open stdout\n", progname);
exit(EXIT_FAILURE);
}
#else
outfile = stdout;
#endif
#endif /* TWO_FILE_COMMANDLINE */
/* Collect comment text from comment_file or stdin, if necessary */
if (comment_arg == NULL) {
FILE * src_file;
int c;
comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH);
if (comment_arg == NULL)
src/Source/LibJPEG/wrtarga.c view on Meta::CPAN
/*
* Startup: write the file header.
*/
METHODDEF(void)
start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
tga_dest_ptr dest = (tga_dest_ptr) dinfo;
int num_colors, i;
FILE *outfile;
if (cinfo->out_color_space == JCS_GRAYSCALE) {
/* Targa doesn't have a mapped grayscale format, so we will */
/* demap quantized gray output. Never emit a colormap. */
write_header(cinfo, dinfo, 0);
if (cinfo->quantize_colors)
dest->pub.put_pixel_rows = put_demapped_gray;
else
dest->pub.put_pixel_rows = put_gray_rows;
} else if (cinfo->out_color_space == JCS_RGB) {
if (cinfo->quantize_colors) {
/* We only support 8-bit colormap indexes, so only 256 colors */
num_colors = cinfo->actual_number_of_colors;
if (num_colors > 256)
ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors);
write_header(cinfo, dinfo, num_colors);
/* Write the colormap. Note Targa uses BGR byte order */
outfile = dest->pub.output_file;
for (i = 0; i < num_colors; i++) {
putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile);
putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile);
putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile);
}
dest->pub.put_pixel_rows = put_gray_rows;
} else {
write_header(cinfo, dinfo, 0);
dest->pub.put_pixel_rows = put_pixel_rows;
}
} else {
ERREXIT(cinfo, JERR_TGA_COLORSPACE);
}
}
src/Source/LibJXR/LibJXR.2013.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
src/Source/LibJXR/LibJXR.2013.vcxproj.filters view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Source Files\image">
<UniqueIdentifier>{aa1c9186-741f-44c1-a8eb-a123e2b79f67}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\image\decode">
src/Source/LibOpenJPEG/LibOpenJPEG.2013.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
src/Source/LibOpenJPEG/LibOpenJPEG.2013.vcxproj.filters view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{0c3108c5-5ec7-43a4-a464-22b036977c34}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{7be8dc1e-caaa-423f-bd9c-50cc5887a179}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
/** initial precinct width */
int prcw_init[OPJ_J2K_MAXRLVLS];
/** initial precinct height */
int prch_init[OPJ_J2K_MAXRLVLS];
/**@name command line encoder parameters (not used inside the library) */
/*@{*/
/** input file name */
char infile[OPJ_PATH_LEN];
/** output file name */
char outfile[OPJ_PATH_LEN];
/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
int index_on;
/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
char index[OPJ_PATH_LEN];
/** subimage encoding: origin image offset in x direction */
int image_offset_x0;
/** subimage encoding: origin image offset in y direction */
int image_offset_y0;
/** subsampling value for dx */
int subsampling_dx;
src/Source/LibOpenJPEG/openjpeg.h view on Meta::CPAN
if != 0, then only the first "layer" layers are decoded;
if == 0 or not used, all the quality layers are decoded
*/
OPJ_UINT32 cp_layer;
/**@name command line decoder parameters (not used inside the library) */
/*@{*/
/** input file name */
char infile[OPJ_PATH_LEN];
/** output file name */
char outfile[OPJ_PATH_LEN];
/** input file format 0: J2K, 1: JP2, 2: JPT */
int decod_format;
/** output file format 0: PGX, 1: PxM, 2: BMP */
int cod_format;
/** Decoding area left boundary */
OPJ_UINT32 DA_x0;
/** Decoding area right boundary */
OPJ_UINT32 DA_x1;
/** Decoding area up boundary */
src/Source/LibPNG/LibPNG.2013.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
src/Source/LibPNG/LibPNG.2013.vcxproj.filters view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{926522ec-b3d4-40ac-b675-698e38162f26}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{ce0089ae-5e1e-4a2c-b359-88ef4dec8309}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
src/Source/LibPNG/pngtest.c view on Meta::CPAN
}
}
if (multiple == 0 && argc == 3 + verbose)
outname = argv[2 + verbose];
if ((multiple == 0 && argc > 3 + verbose) ||
(multiple != 0 && argc < 2))
{
fprintf(STDERR,
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
argv[0], argv[0]);
fprintf(STDERR,
" reads/writes one PNG file (without -m) or multiple files (-m)\n");
fprintf(STDERR,
" with -m %s is used as a temporary file\n", outname);
exit(1);
}
if (multiple != 0)
{
src/Source/LibRawLite/LibRawLite.2013.vcxproj view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
src/Source/LibRawLite/LibRawLite.2013.vcxproj.filters view on Meta::CPAN
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Source Files\internal">
<UniqueIdentifier>{ebdefd5d-9d25-4edd-9e77-3329a0979f71}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\libraw">