]> git.ipfire.org Git - thirdparty/cups.git/blame - pstoraster/sjpege.c
Copyright update...
[thirdparty/cups.git] / pstoraster / sjpege.c
CommitLineData
caddbb58 1/*
efb2f309 2 Copyright 1993-2002 by Easy Software Products.
caddbb58 3 Copyright 1994, 1998 Aladdin Enterprises. All rights reserved.
4
8e4ff0ae 5 This file is part of GNU Ghostscript.
caddbb58 6
8e4ff0ae 7 GNU Ghostscript is distributed in the hope that it will be useful, but
caddbb58 8 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
9 to anyone for the consequences of using it or for whether it serves any
10 particular purpose or works at all, unless he says so in writing. Refer
11 to the GNU General Public License for full details.
12
8e4ff0ae 13 Everyone is granted permission to copy, modify and redistribute GNU
14 Ghostscript, but only under the conditions described in the GNU General
caddbb58 15 Public License. A copy of this license is supposed to have been given
16 to you along with GNU Ghostscript so you can know your rights and
8e4ff0ae 17 responsibilities. It should be in a file named COPYING. Among other
18 things, the copyright notice and this notice must be preserved on all
19 copies.
caddbb58 20
21 Aladdin Enterprises supports the work of the GNU Project, but is not
22 affiliated with the Free Software Foundation or the GNU Project. GNU
23 Ghostscript, as distributed by Aladdin Enterprises, does not require any
24 GNU software to build or run it.
8e4ff0ae 25*/
caddbb58 26
178c9be3 27#include <config.h>
28#ifdef HAVE_LIBJPEG
efb2f309 29/*$Id: sjpege.c,v 1.5 2002/01/02 17:59:12 mike Exp $ */
8e4ff0ae 30/* Interface routines for IJG encoding code. */
31#include "stdio_.h"
32#include "string_.h"
33#include "jpeglib.h"
34#include "jerror.h"
35#include "gx.h"
36#include "gserrors.h"
37#include "strimpl.h"
38#include "sdct.h"
39#include "sjpeg.h"
40
41/*
42 * Interface routines. This layer of routines exists solely to limit
43 * side-effects from using setjmp.
44 */
45
46int
caddbb58 47gs_jpeg_create_compress(stream_DCT_state * st)
48{ /* Initialize error handling */
49 gs_jpeg_error_setup(st);
50 /* Establish the setjmp return context for gs_jpeg_error_exit to use. */
51 if (setjmp(st->data.common->exit_jmpbuf))
52 return_error(gs_jpeg_log_error(st));
53
54 jpeg_create_compress(&st->data.compress->cinfo);
55 jpeg_stream_data_common_init(st->data.compress);
56 return 0;
57}
8e4ff0ae 58
caddbb58 59int
60gs_jpeg_set_defaults(stream_DCT_state * st)
61{
62 if (setjmp(st->data.common->exit_jmpbuf))
63 return_error(gs_jpeg_log_error(st));
64 jpeg_set_defaults(&st->data.compress->cinfo);
65 return 0;
8e4ff0ae 66}
67
68int
caddbb58 69gs_jpeg_set_colorspace(stream_DCT_state * st,
70 J_COLOR_SPACE colorspace)
71{
72 if (setjmp(st->data.common->exit_jmpbuf))
73 return_error(gs_jpeg_log_error(st));
74 jpeg_set_colorspace(&st->data.compress->cinfo, colorspace);
75 return 0;
8e4ff0ae 76}
77
78int
caddbb58 79gs_jpeg_set_linear_quality(stream_DCT_state * st,
80 int scale_factor, boolean force_baseline)
81{
82 if (setjmp(st->data.common->exit_jmpbuf))
83 return_error(gs_jpeg_log_error(st));
84 jpeg_set_linear_quality(&st->data.compress->cinfo,
85 scale_factor, force_baseline);
86 return 0;
8e4ff0ae 87}
88
89int
caddbb58 90gs_jpeg_set_quality(stream_DCT_state * st,
91 int quality, boolean force_baseline)
92{
93 if (setjmp(st->data.common->exit_jmpbuf))
94 return_error(gs_jpeg_log_error(st));
95 jpeg_set_quality(&st->data.compress->cinfo,
96 quality, force_baseline);
97 return 0;
8e4ff0ae 98}
99
100int
caddbb58 101gs_jpeg_start_compress(stream_DCT_state * st,
102 boolean write_all_tables)
103{
104 if (setjmp(st->data.common->exit_jmpbuf))
105 return_error(gs_jpeg_log_error(st));
106 jpeg_start_compress(&st->data.compress->cinfo, write_all_tables);
107 return 0;
8e4ff0ae 108}
109
110int
caddbb58 111gs_jpeg_write_scanlines(stream_DCT_state * st,
112 JSAMPARRAY scanlines,
113 int num_lines)
114{
115 if (setjmp(st->data.common->exit_jmpbuf))
116 return_error(gs_jpeg_log_error(st));
117 return (int)jpeg_write_scanlines(&st->data.compress->cinfo,
118 scanlines, (JDIMENSION) num_lines);
8e4ff0ae 119}
120
121int
caddbb58 122gs_jpeg_finish_compress(stream_DCT_state * st)
123{
124 if (setjmp(st->data.common->exit_jmpbuf))
125 return_error(gs_jpeg_log_error(st));
126 jpeg_finish_compress(&st->data.compress->cinfo);
127 return 0;
8e4ff0ae 128}
caddbb58 129#endif /* HAVE_LIBJPEG */