1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: sjpege.c 8022 2007-06-05 22:23:38Z giles $ */
15
/* Interface routines for IJG encoding code. */
27
* Interface routines. This layer of routines exists solely to limit
28
* side-effects from using setjmp.
32
gs_jpeg_create_compress(stream_DCT_state * st)
33
{ /* Initialize error handling */
34
gs_jpeg_error_setup(st);
35
/* Establish the setjmp return context for gs_jpeg_error_exit to use. */
36
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
37
return_error(gs_jpeg_log_error(st));
39
jpeg_stream_data_common_init(st->data.compress);
40
jpeg_create_compress(&st->data.compress->cinfo);
45
gs_jpeg_set_defaults(stream_DCT_state * st)
47
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
48
return_error(gs_jpeg_log_error(st));
49
jpeg_set_defaults(&st->data.compress->cinfo);
54
gs_jpeg_set_colorspace(stream_DCT_state * st,
55
J_COLOR_SPACE colorspace)
57
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
58
return_error(gs_jpeg_log_error(st));
59
jpeg_set_colorspace(&st->data.compress->cinfo, colorspace);
64
gs_jpeg_set_linear_quality(stream_DCT_state * st,
65
int scale_factor, boolean force_baseline)
67
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
68
return_error(gs_jpeg_log_error(st));
69
jpeg_set_linear_quality(&st->data.compress->cinfo,
70
scale_factor, force_baseline);
75
gs_jpeg_set_quality(stream_DCT_state * st,
76
int quality, boolean force_baseline)
78
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
79
return_error(gs_jpeg_log_error(st));
80
jpeg_set_quality(&st->data.compress->cinfo,
81
quality, force_baseline);
86
gs_jpeg_start_compress(stream_DCT_state * st,
87
boolean write_all_tables)
89
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
90
return_error(gs_jpeg_log_error(st));
91
jpeg_start_compress(&st->data.compress->cinfo, write_all_tables);
96
gs_jpeg_write_scanlines(stream_DCT_state * st,
100
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
101
return_error(gs_jpeg_log_error(st));
102
return (int)jpeg_write_scanlines(&st->data.compress->cinfo,
103
scanlines, (JDIMENSION) num_lines);
107
gs_jpeg_finish_compress(stream_DCT_state * st)
109
if (setjmp(find_jmp_buf(st->data.common->exit_jmpbuf)))
110
return_error(gs_jpeg_log_error(st));
111
jpeg_finish_compress(&st->data.compress->cinfo);