📄 jpg.h
字号:
#endif /* CDERROR_H */#endif /* JMESSAGE */#ifdef JMAKE_ENUM_LISTtypedef enum {#define JMESSAGE(code,string) code ,#endif /* JMAKE_ENUM_LIST */JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */#ifdef BMP_SUPPORTEDJMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported")JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1")JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image")JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image")JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")#endif /* BMP_SUPPORTED */#ifdef GIF_SUPPORTEDJMESSAGE(JERR_GIF_BUG, "GIF output got confused")JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d")JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB")JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file")JMESSAGE(JERR_GIF_NOT, "Not a GIF file")JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image")JMESSAGE(JTRC_GIF_BADVERSION, "Warning: unexpected GIF version number '%c%c%c'")JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x")JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input")JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file")JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring")JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image")JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")#endif /* GIF_SUPPORTED */#ifdef PPM_SUPPORTEDJMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")JMESSAGE(JERR_PPM_NOT, "Not a PPM file")JMESSAGE(JTRC_PGM, "%ux%u PGM image")JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")JMESSAGE(JTRC_PPM, "%ux%u PPM image")JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")#endif /* PPM_SUPPORTED */#ifdef RLE_SUPPORTEDJMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library")JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB")JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE")JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file")JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header")JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header")JMESSAGE(JERR_RLE_NOT, "Not an RLE file")JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE")JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup")JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file")JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d")JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file")JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d")JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d")#endif /* RLE_SUPPORTED */#ifdef TARGA_SUPPORTEDJMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB")JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image")JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image")JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image")#elseJMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled")#endif /* TARGA_SUPPORTED */JMESSAGE(JERR_BAD_CMAP_FILE, "Color map file is invalid or of unsupported format")JMESSAGE(JERR_TOO_MANY_COLORS, "Output file format cannot handle %d colormap entries")JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed")#ifdef TARGA_SUPPORTEDJMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format --- perhaps you need -targa")#elseJMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format")#endifJMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")#ifdef JMAKE_ENUM_LIST JMSG_LASTADDONCODE} ADDON_MESSAGE_CODE;#undef JMAKE_ENUM_LIST#endif /* JMAKE_ENUM_LIST *//* Zap JMESSAGE macro so that future re-inclusions do nothing by default */#undef JMESSAGE#include "../image/jpeglib.h"#ifndef JPP#define JPP(arglist) arglist#endif #ifndef EXTERN#define EXTERN(type) extern type#endif/* * These two functions are used to allocate and release small chunks of * memory. (Typically the total amount requested through jpeg_get_small is * no more than 20K or so; this will be requested in chunks of a few K each.) * Behavior should be the same as for the standard library functions malloc * and free; in particular, jpeg_get_small must return NULL on failure. * On most systems, these ARE malloc and free. jpeg_free_small is passed the * size of the object being freed, just in case it's needed. * On an 80x86 machine using small-data memory model, these manage near heap. */EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject));EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, size_t sizeofobject));/* * These two functions are used to allocate and release large chunks of * memory (up to the total free space designated by jpeg_mem_available). * The interface is the same as above, except that on an 80x86 machine, * far pointers are used. On most other machines these are identical to * the jpeg_get/free_small routines; but we keep them separate anyway, * in case a different allocation strategy is desirable for large chunks. */EXTERN(void *) jpeg_get_large JPP((j_common_ptr cinfo, size_t sizeofobject));EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void * object, size_t sizeofobject));/* * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may * be requested in a single call to jpeg_get_large (and jpeg_get_small for that * matter, but that case should never come into play). This macro is needed * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. * On those machines, we expect that jconfig.h will provide a proper value. * On machines with 32-bit flat address spaces, any large constant may be used. * * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type * size_t and will be a multiple of sizeof(align_type). */#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */#define MAX_ALLOC_CHUNK 1000000000L#endif/* * This routine computes the total space still available for allocation by * jpeg_get_large. If more space than this is needed, backing store will be * used. NOTE: any memory already allocated must not be counted. * * There is a minimum space requirement, corresponding to the minimum * feasible buffer sizes; jmemmgr.c will request that much space even if * jpeg_mem_available returns zero. The maximum space needed, enough to hold * all working storage in memory, is also passed in case it is useful. * Finally, the total space already allocated is passed. If no better * method is available, cinfo->mem->max_memory_to_use - already_allocated * is often a suitable calculation. * * It is OK for jpeg_mem_available to underestimate the space available * (that'll just lead to more backing-store access than is really necessary). * However, an overestimate will lead to failure. Hence it's wise to subtract * a slop factor from the true available space. 5% should be enough. * * On machines with lots of virtual memory, any large constant may be returned. * Conversely, zero may be returned to always use the minimum amount of memory. */EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, long min_bytes_needed, long max_bytes_needed, long already_allocated));/* * This structure holds whatever state is needed to access a single * backing-store object. The read/write/close method pointers are called * by jmemmgr.c to manipulate the backing-store object; all other fields * are private to the system-dependent backing store routines. */#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */typedef unsigned short XMSH; /* type of extended-memory handles */typedef unsigned short EMSH; /* type of expanded-memory handles */typedef union { short file_handle; /* DOS file handle if it's a temp file */ XMSH xms_handle; /* handle if it's a chunk of XMS */ EMSH ems_handle; /* handle if it's a chunk of EMS */} handle_union;#endif /* USE_MSDOS_MEMMGR */typedef struct backing_store_struct * backing_store_ptr;typedef struct backing_store_struct { /* Methods for reading/writing/closing this backing-store object */ JMETHOD(void, read_backing_store, (j_common_ptr cinfo, backing_store_ptr info, void * buffer_address, long file_offset, long byte_count)); JMETHOD(void, write_backing_store, (j_common_ptr cinfo, backing_store_ptr info, void * buffer_address, long file_offset, long byte_count)); JMETHOD(void, close_backing_store, (j_common_ptr cinfo, backing_store_ptr info)); /* Private fields for system-dependent backing-store management */#ifdef USE_MSDOS_MEMMGR /* For the MS-DOS manager (jmemdos.c), we need: */ handle_union handle; /* reference to backing-store storage object */ char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */#else /* For a typical implementation with temp files, we need: */ FILE * temp_file; /* stdio reference to temp file */ char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */#endif} backing_store_info;/* * Initial opening of a backing-store object. This must fill in the * read/write/close pointers in the object. The read/write routines * may take an error exit if the specified maximum file size is exceeded. * (If jpeg_mem_available always returns a large value, this routine can * just take an error exit.) */EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed));/* * These routines take care of any system-dependent initialization and * cleanup required. jpeg_mem_init will be called before anything is * allocated (and, therefore, nothing in cinfo is of use except the error * manager pointer). It should return a suitable default value for * max_memory_to_use; this may subsequently be overridden by the surrounding * application. (Note that max_memory_to_use is only important if * jpeg_mem_available chooses to consult it ... no one else will.) * jpeg_mem_term may assume that all requested memory has been freed and that * all opened backing-store objects have been closed. */EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo));EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo));typedef struct tagJpgInfo { unsigned char* jpg_buffer; int jpg_buffer_length; int width; int height; unsigned char* jpg_surface;}jpg_info_t;extern int unpack_jpg(jpg_info_t*);extern int destroy_jpg(jpg_info_t*);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -