Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1994, 1998, 1999 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: sjpege.c,v 1.5 2002/02/21 22:24:54 giles Exp $ */
18
/* Interface routines for IJG encoding code. */
19
#include "stdio_.h"
20
#include "string_.h"
21
#include "jpeglib_.h"
22
#include "jerror_.h"
23
#include "gx.h"
24
#include "gserrors.h"
25
#include "strimpl.h"
26
#include "sdct.h"
27
#include "sjpeg.h"
28
 
29
/*
30
 * Interface routines.  This layer of routines exists solely to limit
31
 * side-effects from using setjmp.
32
 */
33
 
34
int
35
gs_jpeg_create_compress(stream_DCT_state * st)
36
{				/* Initialize error handling */
37
    gs_jpeg_error_setup(st);
38
    /* Establish the setjmp return context for gs_jpeg_error_exit to use. */
39
    if (setjmp(st->data.common->exit_jmpbuf))
40
	return_error(gs_jpeg_log_error(st));
41
 
42
    jpeg_stream_data_common_init(st->data.compress);
43
    jpeg_create_compress(&st->data.compress->cinfo);
44
    return 0;
45
}
46
 
47
int
48
gs_jpeg_set_defaults(stream_DCT_state * st)
49
{
50
    if (setjmp(st->data.common->exit_jmpbuf))
51
	return_error(gs_jpeg_log_error(st));
52
    jpeg_set_defaults(&st->data.compress->cinfo);
53
    return 0;
54
}
55
 
56
int
57
gs_jpeg_set_colorspace(stream_DCT_state * st,
58
		       J_COLOR_SPACE colorspace)
59
{
60
    if (setjmp(st->data.common->exit_jmpbuf))
61
	return_error(gs_jpeg_log_error(st));
62
    jpeg_set_colorspace(&st->data.compress->cinfo, colorspace);
63
    return 0;
64
}
65
 
66
int
67
gs_jpeg_set_linear_quality(stream_DCT_state * st,
68
			   int scale_factor, boolean force_baseline)
69
{
70
    if (setjmp(st->data.common->exit_jmpbuf))
71
	return_error(gs_jpeg_log_error(st));
72
    jpeg_set_linear_quality(&st->data.compress->cinfo,
73
			    scale_factor, force_baseline);
74
    return 0;
75
}
76
 
77
int
78
gs_jpeg_set_quality(stream_DCT_state * st,
79
		    int quality, boolean force_baseline)
80
{
81
    if (setjmp(st->data.common->exit_jmpbuf))
82
	return_error(gs_jpeg_log_error(st));
83
    jpeg_set_quality(&st->data.compress->cinfo,
84
		     quality, force_baseline);
85
    return 0;
86
}
87
 
88
int
89
gs_jpeg_start_compress(stream_DCT_state * st,
90
		       boolean write_all_tables)
91
{
92
    if (setjmp(st->data.common->exit_jmpbuf))
93
	return_error(gs_jpeg_log_error(st));
94
    jpeg_start_compress(&st->data.compress->cinfo, write_all_tables);
95
    return 0;
96
}
97
 
98
int
99
gs_jpeg_write_scanlines(stream_DCT_state * st,
100
			JSAMPARRAY scanlines,
101
			int num_lines)
102
{
103
    if (setjmp(st->data.common->exit_jmpbuf))
104
	return_error(gs_jpeg_log_error(st));
105
    return (int)jpeg_write_scanlines(&st->data.compress->cinfo,
106
				     scanlines, (JDIMENSION) num_lines);
107
}
108
 
109
int
110
gs_jpeg_finish_compress(stream_DCT_state * st)
111
{
112
    if (setjmp(st->data.common->exit_jmpbuf))
113
	return_error(gs_jpeg_log_error(st));
114
    jpeg_finish_compress(&st->data.compress->cinfo);
115
    return 0;
116
}