aboutsummaryrefslogtreecommitdiffstats
path: root/libsgl/images/fpdfemb_ext.h
blob: d82c4df37c5281108d9165c38de6799d1c4977b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifdef __cplusplus
extern "C" {
#endif

/** Extended interfaces for JPEG, JPEG2000 and JBIG2 decoders **/
typedef struct
{
	/** Initialize the decoding context, with memory allocator provided by FPDFEMB.
	   Implementation should return a pointer to the decoding context.
	*/
	void*	(*Init)(void* (*alloc_func)(unsigned int), void (*free_func)(void*));

	/** Finish with the decoding. */
	void	(*Finish)(void* pContext);

	/** Input JPEG encoded data from the source.
		This function may be called multiple times during decoding progress.
	*/
	void	(*Input)(void* pContext, const unsigned char* src_buf, unsigned long src_size);

	/** Read the header information. Return non-zero for success, 0 for failure */
	int		(*ReadHeader)(void* pContext);

	/** Get info from the decoder, including image width, height and number of components */
	void	(*GetInfo)(void* pContext, int* width, int* height, int* nComps);

	/** Read one scanline from decoded image */
	int		(*ReadScanline)(void* pContext, unsigned char* dest_buf);

	/** Get number of available source bytes left in the input stream */
	unsigned long	(*GetAvailInput)(void* pContext);
} FPDFEMB_JPEG_DECODER;

void FPDFEMB_SetJpegDecoder(FPDFEMB_JPEG_DECODER* pDecoder);

typedef struct 
{
	/** Initialize the decoder with the full source data.
		Implementation should return a pointer to the context.
	*/
	void*	(*Init)(const unsigned char* src_buf, unsigned long src_size);

	/** Destroy the context */
	void	(*Finish)(void* context);

	/** Get image info from the context, including width, height, number of components
		in original codestream, and number of components in output image. For some
		particular type of encoded image, like paletted image, these two numbers of 
		components may vary.
	*/
	void	(*GetInfo)(void* context, unsigned long* width, unsigned long* height, 
				unsigned long* codestream_nComps, unsigned long* output_nComps);

	/** Do the real data decoding, output to a pre-allocated buffer.
		bTranslateColor indicates whether the decoder should use JPEG2000 embedded
		color space info to translate image into sRGB color space.
		"offsets" array describes the byte order of all components. For example,
		{2,1,0} means the first components is output to last byte.
	*/
	void	(*Decode)(void* context, unsigned char* dest_buf, int pitch, 
				int bTranslateColor, unsigned char* offsets);
} FPDFEMB_JPEG2000_DECODER;

void FPDFEMB_SetJpeg2000Decoder(FPDFEMB_JPEG2000_DECODER* pDecoder);

typedef struct
{
	/** Do the whole decoding process. Supplied parameters include width, height, source image
		data and size, global data and size (can be shared among different images), destination
		buffer and scanline pitch in dest buffer.
	*/
	void	(*Decode)(unsigned long width, unsigned long height, const unsigned char* src_buf,
				unsigned long src_size, const unsigned char* global_buf, unsigned long global_size, 
				unsigned char* dest_buf, int dest_pitch);
} FPDFEMB_JBIG2_DECODER;

void FPDFEMB_SetJbig2Decoder(FPDFEMB_JBIG2_DECODER* pDecoder);

#ifdef __cplusplus
};
#endif