// Borland C++ Builder
// Copyright (c) 1995, 1998 by Borland International
// All rights reserved

// (DO NOT EDIT: machine generated header) 'jpeglib.pas' rev: 3.00

#ifndef jpeglibHPP
#define jpeglibHPP
#include <SysUtils.hpp>
#include <Dialogs.hpp>
#include <SysInit.hpp>
#include <System.hpp>

//-- user supplied -----------------------------------------------------------

namespace Jpeglib
{
//-- type declarations -------------------------------------------------------
typedef int Int;

typedef int *int_ptr;

typedef int size_t;

typedef Cardinal uInt;

typedef Cardinal *uint_ptr;

typedef short Short;

typedef Word ushort;

typedef int Long;

typedef int int8array[8];

typedef Byte JSAMPLE;

typedef short JCOEF;

typedef short *JCOEF_PTR;

typedef Byte JOCTET;

typedef Byte *JOCTET_PTR;

typedef Byte UINT8;

typedef Word UINT16;

typedef Shortint INT16;

typedef int INT32;

typedef int *INT32PTR;

typedef Cardinal JDIMENSION;

typedef Byte *JSAMPROW;

typedef JSAMPROW *JSAMPARRAY;

typedef JSAMPARRAY *JSAMPIMAGE;

typedef short JBLOCK[64];

typedef JBLOCK *JBLOCKROW;

typedef JBLOCKROW *JBLOCKARRAY;

typedef JBLOCKARRAY *JBLOCKIMAGE;

typedef short *JCOEFPTR;

struct JQUANT_TBL;
typedef JQUANT_TBL *JQUANT_TBL_PTR;

#pragma pack(push, 1)
struct JQUANT_TBL
{
	Word quantval[64];
	bool sent_table;
} ;
#pragma pack(pop)

struct JHUFF_TBL;
typedef JHUFF_TBL *JHUFF_TBL_PTR;

#pragma pack(push, 1)
struct JHUFF_TBL
{
	Byte bits[17];
	Byte huffval[256];
	bool sent_table;
} ;
#pragma pack(pop)

struct jpeg_component_info;
typedef jpeg_component_info *jpeg_component_info_ptr;

#pragma pack(push, 1)
struct jpeg_component_info
{
	int component_id;
	int component_index;
	int h_samp_factor;
	int v_samp_factor;
	int quant_tbl_no;
	int dc_tbl_no;
	int ac_tbl_no;
	Cardinal width_in_blocks;
	Cardinal height_in_blocks;
	int DCT_scaled_size;
	Cardinal downsampled_width;
	Cardinal downsampled_height;
	bool component_needed;
	int MCU_width;
	int MCU_height;
	int MCU_blocks;
	int MCU_sample_width;
	int last_col_width;
	int last_row_height;
	JQUANT_TBL *quant_table;
	void *dct_table;
} ;
#pragma pack(pop)

struct jpeg_scan_info;
typedef jpeg_scan_info *jpeg_scan_info_ptr;

#pragma pack(push, 1)
struct jpeg_scan_info
{
	int comps_in_scan;
	int component_index[4];
	int Ss;
	int Se;
	int Ah;
	int Al;
} ;
#pragma pack(pop)

enum J_COLOR_SPACE { JCS_UNKNOWN, JCS_GRAYSCALE, JCS_RGB, JCS_YCbCr, JCS_CMYK, JCS_YCCK };

enum J_DCT_METHOD { JDCT_ISLOW, JDCT_IFAST, JDCT_FLOAT };

enum J_DITHER_MODE { JDITHER_NONE, JDITHER_ORDERED, JDITHER_FS };

struct jpeg_error_mgr;
typedef jpeg_error_mgr *jpeg_error_mgr_ptr;

struct jpeg_memory_mgr;
typedef jpeg_memory_mgr *jpeg_memory_mgr_ptr;

struct jpeg_progress_mgr;
typedef jpeg_progress_mgr *jpeg_progress_mgr_ptr;

struct jpeg_destination_mgr;
typedef jpeg_destination_mgr *jpeg_destination_mgr_ptr;

struct jpeg_source_mgr;
typedef jpeg_source_mgr *jpeg_source_mgr_ptr;

struct jpeg_common_struct;
typedef jpeg_common_struct *j_common_ptr;

struct jpeg_compress_struct;
typedef jpeg_compress_struct *j_compress_ptr;

struct jpeg_decompress_struct;
typedef jpeg_decompress_struct *j_decompress_ptr;

#pragma pack(push, 1)
struct jpeg_common_struct
{
	System::TObject* UserRef;
	jpeg_error_mgr *err;
	jpeg_memory_mgr *mem;
	jpeg_progress_mgr *progress;
	bool is_decompressor;
	int global_state;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct jpeg_compress_struct
{
	jpeg_common_struct common_fields;
	jpeg_destination_mgr *dest;
	Cardinal image_width;
	Cardinal image_height;
	int input_components;
	J_COLOR_SPACE in_color_space;
	double input_gamma;
	int data_precision;
	int num_components;
	J_COLOR_SPACE jpeg_color_space;
	jpeg_component_info *comp_info;
	JQUANT_TBL *quant_tbl_ptrs[4];
	JHUFF_TBL *dc_huff_tbl_ptrs[4];
	JHUFF_TBL *ac_huff_tbl_ptrs[4];
	Byte arith_dc_L[16];
	Byte arith_dc_U[16];
	Byte arith_ac_K[16];
	int num_scans;
	jpeg_scan_info *scan_info;
	bool raw_data_in;
	bool arith_code;
	bool optimize_coding;
	bool CCIR601_sampling;
	int smoothing_factor;
	J_DCT_METHOD dct_method;
	Cardinal restart_interval;
	int restart_in_rows;
	bool write_JFIF_header;
	Byte density_unit;
	Word X_density;
	Word Y_density;
	bool write_Adobe_marker;
	Cardinal next_scanline;
	bool progressive_mode;
	int max_h_samp_factor;
	int max_v_samp_factor;
	Cardinal total_iMCU_rows;
	int comps_in_scan;
	jpeg_component_info *cur_comp_info[4];
	Cardinal MCUs_per_row;
	Cardinal MCU_rows_in_scan;
	int blocks_in_MCU;
	int MCU_membership[10];
	int Ss;
	int Se;
	int Ah;
	int Al;
	void *master;
	void *main;
	void *prep;
	void *coef;
	void *marker;
	void *cconvert;
	void *downsample;
	void *fdct;
	void *entropy;
} ;
#pragma pack(pop)

typedef int coef_bits_field[64];

typedef coef_bits_field *coef_bits_ptr;

typedef int coef_bits_ptrfield[4][64];

typedef coef_bits_ptrfield *coef_bits_ptrrow;

typedef Byte range_limit_table[1408];

typedef range_limit_table *range_limit_table_ptr;

#pragma pack(push, 1)
struct jpeg_decompress_struct
{
	jpeg_common_struct common_fields;
	jpeg_source_mgr *src;
	Cardinal image_width;
	Cardinal image_height;
	int num_components;
	J_COLOR_SPACE jpeg_color_space;
	J_COLOR_SPACE out_color_space;
	Cardinal scale_num;
	Cardinal scale_denom;
	double output_gamma;
	bool buffered_image;
	bool raw_data_out;
	J_DCT_METHOD dct_method;
	bool do_fancy_upsampling;
	bool do_block_smoothing;
	bool quantize_colors;
	J_DITHER_MODE dither_mode;
	bool two_pass_quantize;
	int desired_number_of_colors;
	bool enable_1pass_quant;
	bool enable_external_quant;
	bool enable_2pass_quant;
	Cardinal output_width;
	Cardinal output_height;
	int out_color_components;
	int output_components;
	int rec_outbuf_height;
	int actual_number_of_colors;
	JSAMPROW *colormap;
	Cardinal output_scanline;
	int input_scan_number;
	Cardinal input_iMCU_row;
	int output_scan_number;
	int output_iMCU_row;
	coef_bits_field *coef_bits;
	JQUANT_TBL *quant_tbl_ptrs[4];
	JHUFF_TBL *dc_huff_tbl_ptrs[4];
	JHUFF_TBL *ac_huff_tbl_ptrs[4];
	int data_precision;
	jpeg_component_info *comp_info;
	bool progressive_mode;
	bool arith_code;
	Byte arith_dc_L[16];
	Byte arith_dc_U[16];
	Byte arith_ac_K[16];
	Cardinal restart_interval;
	bool saw_JFIF_marker;
	Byte density_unit;
	Word X_density;
	Word Y_density;
	bool saw_Adobe_marker;
	Byte Adobe_transform;
	bool CCIR601_sampling;
	int max_h_samp_factor;
	int max_v_samp_factor;
	int min_DCT_scaled_size;
	Cardinal total_iMCU_rows;
	range_limit_table *sample_range_limit;
	int comps_in_scan;
	jpeg_component_info *cur_comp_info[4];
	Cardinal MCUs_per_row;
	Cardinal MCU_rows_in_scan;
	Cardinal blocks_in_MCU;
	int MCU_membership[10];
	int Ss;
	int Se;
	int Ah;
	int Al;
	int unread_marker;
	void *master;
	void *main;
	void *coef;
	void *post;
	void *inputctl;
	void *marker;
	void *entropy;
	void *idct;
	void *upsample;
	void *cconvert;
	void *cquantize;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct jpeglib__1
{
	
	union
	{
		char s[80];
		int i[8];
		
	};
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct jpeg_error_mgr
{
	void __stdcall (*error_exit)(j_common_ptr cinfo);
	void __stdcall (*emit_message)(j_common_ptr cinfo, int msg_level);
	void __stdcall (*output_message)(j_common_ptr cinfo);
	void __stdcall (*format_message)(j_common_ptr cinfo, char * buffer);
	void __stdcall (*reset_error_mgr)(j_common_ptr cinfo);
	int msg_code;
	jpeglib__1 msg_parm;
	int trace_level;
	int num_warnings;
	void *jpeg_message_table;
	int last_jpeg_message;
	void *addon_message_table;
	int first_addon_message;
	int last_addon_message;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct jpeg_progress_mgr
{
	void __stdcall (*progress_monitor)(j_common_ptr cinfo);
	int pass_counter;
	int pass_limit;
	int completed_passes;
	int total_passes;
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct jpeg_destination_mgr
{
	Byte *next_output_byte;
	int free_in_buffer;
	void __stdcall (*init_destination)(j_compress_ptr cinfo);
	bool __stdcall (*empty_output_buffer)(j_compress_ptr cinfo);
	void __stdcall (*term_destination)(j_compress_ptr cinfo);
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct jpeg_source_mgr
{
	Byte *next_input_byte;
	int bytes_in_buffer;
	void __stdcall (*init_source)(j_decompress_ptr cinfo);
	bool __stdcall (*fill_input_buffer)(j_decompress_ptr cinfo);
	void __stdcall (*skip_input_data)(j_decompress_ptr cinfo, int num_bytes);
	bool __stdcall (*resync_to_restart)(j_decompress_ptr cinfo, int desired);
	void __stdcall (*term_source)(j_decompress_ptr cinfo);
} ;
#pragma pack(pop)

typedef void *jvirt_sarray_ptr;

typedef void *jvirt_barray_ptr;

#pragma pack(push, 1)
struct jpeg_memory_mgr
{
	void * __stdcall (*alloc_small)(j_common_ptr cinfo, int pool_id, int sizeofobject);
	void * __stdcall (*alloc_large)(j_common_ptr cinfo, int pool_id, int sizeofobject);
	JSAMPARRAY __stdcall (*alloc_sarray)(j_common_ptr cinfo, int pool_id, Cardinal samplesperrow, Cardinal 
		numrows);
	JBLOCKARRAY __stdcall (*alloc_barray)(j_common_ptr cinfo, int pool_id, Cardinal blocksperrow, Cardinal 
		numrows);
	void * __stdcall (*request_virt_sarray)(j_common_ptr cinfo, int pool_id, bool pre_zero, Cardinal samplesperrow
		, Cardinal numrows, Cardinal maxaccess);
	void * __stdcall (*request_virt_barray)(j_common_ptr cinfo, int pool_id, bool pre_zero, Cardinal blocksperrow
		, Cardinal numrows, Cardinal maxaccess);
	void __stdcall (*realize_virt_arrays)(j_common_ptr cinfo);
	JSAMPARRAY __stdcall (*access_virt_sarray)(j_common_ptr cinfo, void * ptr, Cardinal start_row, Cardinal 
		num_rows, bool writable);
	JBLOCKARRAY __stdcall (*access_virt_barray)(j_common_ptr cinfo, void * ptr, Cardinal start_row, Cardinal 
		num_rows, bool writable);
	void __stdcall (*free_pool)(j_common_ptr cinfo, int pool_id);
	void __stdcall (*self_destruct)(j_common_ptr cinfo);
	int max_memory_to_use;
} ;
#pragma pack(pop)

typedef bool __stdcall (*jpeg_marker_parser_method)(j_decompress_ptr cinfo);

//-- var, const, procedure ---------------------------------------------------
#define MAX_COMPONENTS (Byte)(10)
#define MAXJSAMPLE (Byte)(255)
#define CENTERJSAMPLE (Byte)(128)
#define JPEG_MAX_DIMENSION (int)(65500)
#define JPEG_LIB_VERSION (Byte)(61)
#define JMSG_STR_PARM_MAX (Byte)(80)
#define JMSG_LENGTH_MAX (Byte)(200)
#define DCTSIZE (Byte)(8)
#define DCTSIZE2 (Byte)(64)
#define NUM_QUANT_TBLS (Byte)(4)
#define NUM_HUFF_TBLS (Byte)(4)
#define NUM_ARITH_TBLS (Byte)(16)
#define MAX_COMPS_IN_SCAN (Byte)(4)
#define MAX_SAMP_FACTOR (Byte)(4)
#define C_MAX_BLOCKS_IN_MCU (Byte)(10)
#define D_MAX_BLOCKS_IN_MCU (Byte)(10)
#define JDCT_DEFAULT (J_DCT_METHOD)(0)
#define JDCT_FASTEST (J_DCT_METHOD)(1)
#define JPOOL_PERMANENT (Byte)(0)
#define JPOOL_IMAGE (Byte)(1)
#define JPOOL_NUMPOOLS (Byte)(2)
#define JPEG_SUSPENDED (Byte)(0)
#define JPEG_HEADER_OK (Byte)(1)
#define JPEG_HEADER_TABLES_ONLY (Byte)(2)
#define JPEG_REACHED_SOS (Byte)(1)
#define JPEG_REACHED_EOI (Byte)(2)
#define JPEG_ROW_COMPLETED (Byte)(3)
#define JPEG_SCAN_COMPLETED (Byte)(4)
#define JPEG_RST0 (Byte)(208)
#define JPEG_EOI (Byte)(217)
#define JPEG_APP0 (Byte)(224)
#define JPEG_COM (Byte)(254)
extern "C" void __stdcall jpeg_destroy_compress(j_compress_ptr cinfo);
extern "C" void __stdcall jpeg_destroy_decompress(j_decompress_ptr cinfo);
extern "C" void __stdcall jpeg_set_defaults(j_compress_ptr cinfo);
extern "C" void __stdcall jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace);
extern "C" void __stdcall jpeg_default_colorspace(j_compress_ptr cinfo);
extern "C" void __stdcall jpeg_set_quality(j_compress_ptr cinfo, int quality, bool force_baseline);
extern "C" void __stdcall jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor, bool force_baseline
	);
extern "C" void __stdcall jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl, const uint_ptr basic_table
	, int scale_factor, bool force_baseline);
extern "C" int __stdcall jpeg_quality_scaling(int quality);
extern "C" void __stdcall jpeg_simple_progression(j_compress_ptr cinfo);
extern "C" void __stdcall jpeg_suppress_tables(j_compress_ptr cinfo, bool suppress);
extern "C" JQUANT_TBL_PTR __stdcall jpeg_alloc_quant_table(const jpeg_common_struct cinfo);
extern "C" JHUFF_TBL_PTR __stdcall jpeg_alloc_huff_table(const jpeg_common_struct cinfo);
extern "C" void __stdcall jpeg_start_compress(j_compress_ptr cinfo, bool write_all_tables);
extern "C" Cardinal __stdcall jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, Cardinal 
	num_lines);
extern "C" void __stdcall jpeg_finish_compress(j_compress_ptr cinfo);
extern "C" Cardinal __stdcall jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data, Cardinal num_lines
	);
extern "C" void __stdcall jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET_PTR dataptr
	, Cardinal datalen);
extern "C" void __stdcall jpeg_write_tables(j_compress_ptr cinfo);
extern "C" int __stdcall jpeg_read_header(j_decompress_ptr cinfo, bool require_image);
extern "C" bool __stdcall jpeg_start_decompress(j_decompress_ptr cinfo);
extern "C" Cardinal __stdcall jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, Cardinal 
	max_lines);
extern "C" bool __stdcall jpeg_finish_decompress(j_decompress_ptr cinfo);
extern "C" Cardinal __stdcall jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data, Cardinal max_lines
	);
extern "C" bool __stdcall jpeg_has_multiple_scans(j_decompress_ptr cinfo);
extern "C" bool __stdcall jpeg_start_output(j_decompress_ptr cinfo, int scan_number);
extern "C" bool __stdcall jpeg_finish_output(j_decompress_ptr cinfo);
extern "C" bool __stdcall jpeg_input_complete(j_decompress_ptr cinfo);
extern "C" void __stdcall jpeg_new_colormap(j_decompress_ptr cinfo);
extern "C" int __stdcall jpeg_consume_input(j_decompress_ptr cinfo);
extern "C" void __stdcall jpeg_calc_output_dimensions(j_decompress_ptr cinfo);
extern "C" void __stdcall jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code, jpeg_marker_parser_method 
	routine);
extern "C" void __stdcall jpeg_abort_compress(j_compress_ptr cinfo);
extern "C" void __stdcall jpeg_abort_decompress(j_decompress_ptr cinfo);
extern "C" void __stdcall jpeg_abort(j_common_ptr cinfo);
extern "C" void __stdcall jpeg_destroy(j_common_ptr cinfo);
extern "C" bool __stdcall jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired);
extern "C" jpeg_error_mgr_ptr __stdcall jpeg_std_error(jpeg_error_mgr_ptr err);
extern PACKAGE void __fastcall jpeg_Create_Compress(j_compress_ptr cinfo);
extern PACKAGE void __fastcall jpeg_Create_Decompress(j_decompress_ptr cinfo);

}	/* namespace Jpeglib */
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Jpeglib;
#endif
//-- end unit ----------------------------------------------------------------
#endif	// jpeglib
