jpeglib.h
来自「Windows 图形编程 书籍」· C头文件 代码 · 共 1,055 行 · 第 1/3 页
H
1,055 行
virtual void output_message(void);
// Format a message string for the most recent JPEG error or message
virtual void format_message(char * buffer);
// Reset error state variables at start of a new image
virtual void reset_error_mgr(void);
#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
/* The message ID code and any parameters are saved here.
* A message can have one string parameter or up to 8 int parameters.
*/
int msg_code;
#define JMSG_STR_PARM_MAX 80
union {
int i[8];
char s[JMSG_STR_PARM_MAX];
} msg_parm;
/* Standard state variables for error facility */
int trace_level; /* max msg_level that will be displayed */
private:
/* For recoverable corrupt-data errors, we emit a warning message,
* but keep going unless emit_message chooses to abort. emit_message
* should count warnings in num_warnings. The surrounding application
* can check for bad data by seeing if num_warnings is nonzero at the
* end of processing.
*/
long num_warnings; /* number of corrupt-data warnings */
/* These fields point to the table(s) of error message strings.
* An application can change the table pointer to switch to a different
* message list (typically, to change the language in which errors are
* reported). Some applications may wish to add additional error codes
* that will be handled by the JPEG library error mechanism; the second
* table pointer is used for this purpose.
*
* First table includes all errors generated by JPEG library itself.
* Error code 0 is reserved for a "no such error string" message.
*/
const char * const * jpeg_message_table; /* Library errors */
int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
/* Second table can be added by application (see cjpeg/djpeg for example).
* It contains strings numbered first_addon_message..last_addon_message.
*/
const char * const * addon_message_table; /* Non-library errors */
int first_addon_message; /* code for first string in addon table */
int last_addon_message; /* code for last string in addon table */
};
/* Progress monitor object */
struct jpeg_progress_mgr {
JMETHOD(void, progress_monitor, (j_common_ptr cinfo));
long pass_counter; /* work units completed in this pass */
long pass_limit; /* total number of work units in this pass */
int completed_passes; /* passes completed so far */
int total_passes; /* total number of passes expected */
};
/* Data destination object for compression */
struct jpeg_destination_mgr {
JOCTET * next_output_byte; /* => next byte to write in buffer */
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
JMETHOD(void, init_destination, (j_compress_ptr cinfo));
JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo));
JMETHOD(void, term_destination, (j_compress_ptr cinfo));
};
// Generic Data source object for decompression
class jpeg_source_mgr
{
public:
const JOCTET * next_input_byte; /* => next byte to read from buffer */
size_t bytes_in_buffer; /* # of bytes remaining in buffer */
virtual void init_source(j_decompress_ptr cinfo);
virtual boolean fill_input_buffer(j_decompress_ptr cinfo);
virtual void skip_input_data(j_decompress_ptr cinfo, long num_bytes);
virtual boolean resync_to_restart(j_decompress_ptr cinfo, int desired);
virtual void term_source(j_decompress_ptr cinfo);
};
/* Memory manager object.
* Allocates "small" objects (a few K total), "large" objects (tens of K),
* and "really big" objects (virtual arrays with backing store if needed).
* The memory manager does not allow individual objects to be freed; rather,
* each created object is assigned to a pool, and whole pools can be freed
* at once. This is faster and more convenient than remembering exactly what
* to free, especially where malloc()/free() are not too speedy.
* NB: alloc routines never return NULL. They exit to error_exit if not
* successful.
*/
#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
#define JPOOL_NUMPOOLS 2
typedef struct jvirt_sarray_control * jvirt_sarray_ptr;
typedef struct jvirt_barray_control * jvirt_barray_ptr;
class jpeg_memory_mgr
{
/* Method pointers */
public:
virtual ~jpeg_memory_mgr()
{
}
virtual void * alloc_small(int pool_id, size_t sizeofobject) = 0;
virtual void * alloc_large(int pool_id, size_t sizeofobject) = 0;
virtual JSAMPARRAY alloc_sarray(int pool_id, JDIMENSION samplesperrow, JDIMENSION numrows) = 0;
virtual JBLOCKARRAY alloc_barray(int pool_id, JDIMENSION blocksperrow, JDIMENSION numrows) = 0;
virtual jvirt_sarray_ptr request_virt_sarray(
int pool_id,
boolean pre_zero,
JDIMENSION samplesperrow,
JDIMENSION numrows,
JDIMENSION maxaccess) = 0;
virtual jvirt_barray_ptr request_virt_barray(
int pool_id,
boolean pre_zero,
JDIMENSION blocksperrow,
JDIMENSION numrows,
JDIMENSION maxaccess) = 0;
virtual void realize_virt_arrays(void) = 0;
virtual JSAMPARRAY access_virt_sarray(
jvirt_sarray_ptr ptr,
JDIMENSION start_row,
JDIMENSION num_rows,
boolean writable) = 0;
virtual JBLOCKARRAY access_virt_barray(
jvirt_barray_ptr ptr,
JDIMENSION start_row,
JDIMENSION num_rows,
boolean writable) = 0;
virtual void free_pool(int pool_id) = 0;
/* Limit on memory allocation for this JPEG object. (Note that this is
* merely advisory, not a guaranteed maximum; it only affects the space
* used for virtual-array buffers.) May be changed by outer application
* after creating the JPEG object.
*/
long max_memory_to_use;
/* Maximum allocation request accepted by alloc_large. */
long max_alloc_chunk;
};
/* Routine signature for application-supplied marker processing methods.
* Need not pass marker code since it is stored in cinfo->unread_marker.
*/
typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
/* Short forms of external names for systems with brain-damaged linkers.
* We shorten external names to be unique in the first six letters, which
* is good enough for all known systems.
* (If your compiler itself needs names to be unique in less than 15
* characters, you are out of luck. Get a better compiler.)
*/
/* Initialization of JPEG compression objects.
* jpeg_create_compress() and jpeg_create_decompress() are the exported
* names that applications should call. These expand to calls on
* jpeg_CreateCompress and jpeg_CreateDecompress with additional information
* passed for version mismatch checking.
* NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
*/
#define jpeg_create_compress(cinfo) \
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
(size_t) sizeof(jpeg_compress_struct))
void jpeg_CreateCompress (j_compress_ptr cinfo,
int version, size_t structsize);
/* Destruction of JPEG compression objects */
void jpeg_destroy_compress (j_compress_ptr cinfo);
/* Standard data source and destination managers: stdio streams. */
/* Caller is responsible for opening the file before and closing after. */
void jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile);
void jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile);
void jpeg_const_src (j_decompress_ptr cinfo, const unsigned char * buffer, int len);
/* Default parameter setup for compression */
void jpeg_set_defaults (j_compress_ptr cinfo);
/* Compression parameter setup aids */
void jpeg_set_colorspace (j_compress_ptr cinfo,
J_COLOR_SPACE colorspace);
void jpeg_default_colorspace (j_compress_ptr cinfo);
void jpeg_set_quality (j_compress_ptr cinfo, int quality,
boolean force_baseline);
void jpeg_set_linear_quality (j_compress_ptr cinfo,
int scale_factor,
boolean force_baseline);
void jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
int scale_factor,
boolean force_baseline);
int jpeg_quality_scaling (int quality);
void jpeg_simple_progression (j_compress_ptr cinfo);
void jpeg_suppress_tables (j_compress_ptr cinfo,
boolean suppress);
JQUANT_TBL * jpeg_alloc_quant_table (j_common_ptr cinfo);
JHUFF_TBL * jpeg_alloc_huff_table (j_common_ptr cinfo);
/* Main entry points for compression */
void jpeg_start_compress (j_compress_ptr cinfo,
boolean write_all_tables);
JDIMENSION jpeg_write_scanlines (j_compress_ptr cinfo,
JSAMPARRAY scanlines,
JDIMENSION num_lines);
void jpeg_finish_compress (j_compress_ptr cinfo);
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
JDIMENSION jpeg_write_raw_data (j_compress_ptr cinfo,
JSAMPIMAGE data,
JDIMENSION num_lines);
/* Write a special marker. See libjpeg.doc concerning safe usage. */
void jpeg_write_marker
(j_compress_ptr cinfo, int marker,
const JOCTET * dataptr, unsigned int datalen);
/* Same, but piecemeal. */
void jpeg_write_m_header
(j_compress_ptr cinfo, int marker, unsigned int datalen);
void jpeg_write_m_byte
(j_compress_ptr cinfo, int val);
/* Alternate compression function: just write an abbreviated table file */
void jpeg_write_tables (j_compress_ptr cinfo);
/* Decompression startup: read start of JPEG datastream to see what's there */
/* Return value is one of: */
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
/* If you pass require_image = TRUE (normal case), you need not check for
* a TABLES_ONLY return code; an abbreviated file will cause an error exit.
* JPEG_SUSPENDED is only possible if you use a data source module that can
* give a suspension return (the stdio source module doesn't).
*/
/* Main entry points for decompression */
/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
JDIMENSION jpeg_read_raw_data (j_decompress_ptr cinfo,
JSAMPIMAGE data,
JDIMENSION max_lines);
/* Additional entry points for buffered-image mode. */
boolean jpeg_start_output (j_decompress_ptr cinfo,
int scan_number);
boolean jpeg_finish_output (j_decompress_ptr cinfo);
void jpeg_new_colormap (j_decompress_ptr cinfo);
/* Return value is one of: */
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
#define JPEG_REACHED_EOI 2 /* Reached end of image */
#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
/* Precalculate output dimensions for current decompression parameters. */
void jpeg_calc_output_dimensions (j_decompress_ptr cinfo);
/* Control saving of COM and APPn markers into marker_list. */
void jpeg_save_markers
(j_decompress_ptr cinfo, int marker_code,
unsigned int length_limit);
/* Install a special processing method for COM or APPn markers. */
void jpeg_set_marker_processor
(j_decompress_ptr cinfo, int marker_code,
jpeg_marker_parser_method routine);
/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
jvirt_barray_ptr * jpeg_read_coefficients (j_decompress_ptr cinfo);
void jpeg_write_coefficients (j_compress_ptr cinfo,
jvirt_barray_ptr * coef_arrays);
void jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
j_compress_ptr dstinfo);
/* If you choose to abort compression or decompression before completing
* jpeg_finish_(de)compress, then you need to clean up to release memory,
* temporary files, etc. You can just call jpeg_destroy_(de)compress
* if you're done with the JPEG object, but if you want to clean it up and
* reuse it, call this:
*/
void jpeg_abort_compress (j_compress_ptr cinfo);
/* Generic versions of jpeg_abort and jpeg_destroy that work on either
* flavor of JPEG object. These may be more convenient in some places.
*/
void jpeg_abort (j_common_ptr cinfo);
/* Default restart-marker-resync procedure for use by data source modules */
boolean jpeg_resync_to_restart (j_decompress_ptr cinfo,
int desired);
/* These marker codes are exported since applications and data source modules
* are likely to want to use them.
*/
#define JPEG_RST0 0xD0 /* RST0 marker code */
#define JPEG_EOI 0xD9 /* EOI marker code */
#define JPEG_APP0 0xE0 /* APP0 marker code */
#define JPEG_COM 0xFE /* COM marker code */
/*
* The JPEG library modules define JPEG_INTERNALS before including this file.
* The internal structure declarations are read only when that is true.
* Applications using the library should not include jpegint.h, but may wish
* to include jerror.h.
*/
#ifdef JPEG_INTERNALS
#include "jpegint.h" /* fetch private declarations */
#include "jerror.h" /* fetch error codes too */
#endif
#endif /* JPEGLIB_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?