diff --git a/build_linux64/libamscimglib4.linux64.a b/build_linux64/libamscimglib4.linux64.a index 10e63bb..4be89df 100644 Binary files a/build_linux64/libamscimglib4.linux64.a and b/build_linux64/libamscimglib4.linux64.a differ diff --git a/build_linux64/libamscimglib4.linux64.so b/build_linux64/libamscimglib4.linux64.so index 91609d1..8117d49 100644 Binary files a/build_linux64/libamscimglib4.linux64.so and b/build_linux64/libamscimglib4.linux64.so differ diff --git a/build_linux64/objstore/amscimglib4_image.o b/build_linux64/objstore/amscimglib4_image.o index 41bb63a..b4155d4 100644 Binary files a/build_linux64/objstore/amscimglib4_image.o and b/build_linux64/objstore/amscimglib4_image.o differ diff --git a/build_linux64/objstore/amscimglib4_util.o b/build_linux64/objstore/amscimglib4_util.o index 82b6c00..d1572b2 100644 Binary files a/build_linux64/objstore/amscimglib4_util.o and b/build_linux64/objstore/amscimglib4_util.o differ diff --git a/build_mingw64/libamscimglib4.mingw64.a b/build_mingw64/libamscimglib4.mingw64.a index 223ae18..563c58f 100644 Binary files a/build_mingw64/libamscimglib4.mingw64.a and b/build_mingw64/libamscimglib4.mingw64.a differ diff --git a/build_mingw64/libamscimglib4.mingw64.dll b/build_mingw64/libamscimglib4.mingw64.dll index 443782b..c1222b7 100644 Binary files a/build_mingw64/libamscimglib4.mingw64.dll and b/build_mingw64/libamscimglib4.mingw64.dll differ diff --git a/build_mingw64/objstore/amscimglib4_bitmap.o b/build_mingw64/objstore/amscimglib4_bitmap.o index 518a960..a14307f 100644 Binary files a/build_mingw64/objstore/amscimglib4_bitmap.o and b/build_mingw64/objstore/amscimglib4_bitmap.o differ diff --git a/build_mingw64/objstore/amscimglib4_image.o b/build_mingw64/objstore/amscimglib4_image.o index 471c986..bae49ea 100644 Binary files a/build_mingw64/objstore/amscimglib4_image.o and b/build_mingw64/objstore/amscimglib4_image.o differ diff --git a/build_mingw64/objstore/amscimglib4_jpeg.o b/build_mingw64/objstore/amscimglib4_jpeg.o index ef485ab..fb04b28 100644 Binary files a/build_mingw64/objstore/amscimglib4_jpeg.o and b/build_mingw64/objstore/amscimglib4_jpeg.o differ diff --git a/build_mingw64/objstore/amscimglib4_png.o b/build_mingw64/objstore/amscimglib4_png.o index bf6758d..545fd66 100644 Binary files a/build_mingw64/objstore/amscimglib4_png.o and b/build_mingw64/objstore/amscimglib4_png.o differ diff --git a/build_mingw64/objstore/amscimglib4_templatetest.o b/build_mingw64/objstore/amscimglib4_templatetest.o index cdaef76..2c78bb4 100644 Binary files a/build_mingw64/objstore/amscimglib4_templatetest.o and b/build_mingw64/objstore/amscimglib4_templatetest.o differ diff --git a/build_mingw64/objstore/amscimglib4_tests.o b/build_mingw64/objstore/amscimglib4_tests.o index a50e43f..1de86d1 100644 Binary files a/build_mingw64/objstore/amscimglib4_tests.o and b/build_mingw64/objstore/amscimglib4_tests.o differ diff --git a/build_mingw64/objstore/amscimglib4_util.o b/build_mingw64/objstore/amscimglib4_util.o index a34b920..fd79fb3 100644 Binary files a/build_mingw64/objstore/amscimglib4_util.o and b/build_mingw64/objstore/amscimglib4_util.o differ diff --git a/build_mingw64/tests.exe b/build_mingw64/tests.exe index 092ec74..32b0468 100644 Binary files a/build_mingw64/tests.exe and b/build_mingw64/tests.exe differ diff --git a/dependencies/winx64/include/jerror.h b/dependencies/winx64/include/jerror.h new file mode 100644 index 0000000..fc2fffe --- /dev/null +++ b/dependencies/winx64/include/jerror.h @@ -0,0 +1,291 @@ +/* + * jerror.h + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the error and message codes for the JPEG library. + * Edit this file to add new codes, or to translate the message strings to + * some other language. + * A set of error-reporting macros are defined too. Some applications using + * the JPEG library may wish to include this file to get the error codes + * and/or the macros. + */ + +/* + * To define the enum list of message codes, include this file without + * defining macro JMESSAGE. To create a message string table, include it + * again with a suitable JMESSAGE definition (see jerror.c for an example). + */ +#ifndef JMESSAGE +#ifndef JERROR_H +/* First time through, define the enum list */ +#define JMAKE_ENUM_LIST +#else +/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ +#define JMESSAGE(code,string) +#endif /* JERROR_H */ +#endif /* JMESSAGE */ + +#ifdef JMAKE_ENUM_LIST + +typedef enum { + +#define JMESSAGE(code,string) code , + +#endif /* JMAKE_ENUM_LIST */ + +JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ + +/* For maintenance convenience, list is alphabetical by message code name */ +JMESSAGE(JERR_ARITH_NOTIMPL, + "Sorry, there are legal restrictions on arithmetic coding") +JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") +JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") +JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") +JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") +JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") +JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") +JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") +JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") +JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") +JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") +JMESSAGE(JERR_BAD_LIB_VERSION, + "Wrong JPEG library version: library is %d, caller expects %d") +JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") +JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") +JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") +JMESSAGE(JERR_BAD_PROGRESSION, + "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") +JMESSAGE(JERR_BAD_PROG_SCRIPT, + "Invalid progressive parameters at scan script entry %d") +JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") +JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") +JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") +JMESSAGE(JERR_BAD_STRUCT_SIZE, + "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") +JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") +JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") +JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") +JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") +JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") +JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") +JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") +JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") +JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") +JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") +JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") +JMESSAGE(JERR_EMS_READ, "Read from EMS failed") +JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") +JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") +JMESSAGE(JERR_FILE_READ, "Input file read error") +JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") +JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") +JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") +JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") +JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") +JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") +JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") +JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, + "Cannot transcode due to multiple use of quantization table %d") +JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") +JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") +JMESSAGE(JERR_NOTIMPL, "Not implemented yet") +JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") +JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") +JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") +JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") +JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") +JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") +JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") +JMESSAGE(JERR_QUANT_COMPONENTS, + "Cannot quantize more than %d color components") +JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") +JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") +JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") +JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") +JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") +JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") +JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") +JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") +JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") +JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") +JMESSAGE(JERR_TFILE_WRITE, + "Write failed on temporary file --- out of disk space?") +JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") +JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") +JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") +JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") +JMESSAGE(JERR_XMS_READ, "Read from XMS failed") +JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") +JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) +JMESSAGE(JMSG_VERSION, JVERSION) +JMESSAGE(JTRC_16BIT_TABLES, + "Caution: quantization tables are too coarse for baseline JPEG") +JMESSAGE(JTRC_ADOBE, + "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") +JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") +JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") +JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") +JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") +JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") +JMESSAGE(JTRC_DRI, "Define Restart Interval %u") +JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") +JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") +JMESSAGE(JTRC_EOI, "End Of Image") +JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") +JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") +JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, + "Warning: thumbnail image size does not match data length %u") +JMESSAGE(JTRC_JFIF_EXTENSION, + "JFIF extension marker: type 0x%02x, length %u") +JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") +JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") +JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") +JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") +JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") +JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") +JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") +JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") +JMESSAGE(JTRC_RST, "RST%d") +JMESSAGE(JTRC_SMOOTH_NOTIMPL, + "Smoothing not supported with nonstandard sampling ratios") +JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") +JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") +JMESSAGE(JTRC_SOI, "Start of Image") +JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") +JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") +JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") +JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") +JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") +JMESSAGE(JTRC_THUMB_JPEG, + "JFIF extension marker: JPEG-compressed thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_PALETTE, + "JFIF extension marker: palette thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_RGB, + "JFIF extension marker: RGB thumbnail image, length %u") +JMESSAGE(JTRC_UNKNOWN_IDS, + "Unrecognized component IDs %d %d %d, assuming YCbCr") +JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") +JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") +JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") +JMESSAGE(JWRN_BOGUS_PROGRESSION, + "Inconsistent progression sequence for component %d coefficient %d") +JMESSAGE(JWRN_EXTRANEOUS_DATA, + "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") +JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") +JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") +JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") +JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") +JMESSAGE(JWRN_MUST_RESYNC, + "Corrupt JPEG data: found marker 0x%02x instead of RST%d") +JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") +JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") + +#ifdef JMAKE_ENUM_LIST + + JMSG_LASTMSGCODE +} J_MESSAGE_CODE; + +#undef JMAKE_ENUM_LIST +#endif /* JMAKE_ENUM_LIST */ + +/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ +#undef JMESSAGE + + +#ifndef JERROR_H +#define JERROR_H + +/* Macros to simplify using the error and trace message stuff */ +/* The first parameter is either type of cinfo pointer */ + +/* Fatal errors (print message and exit) */ +#define ERREXIT(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT3(cinfo,code,p1,p2,p3) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (cinfo)->err->msg_parm.i[3] = (p4), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXITS(cinfo,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) + +#define MAKESTMT(stuff) do { stuff } while (0) + +/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ +#define WARNMS(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) + +/* Informational/debugging messages */ +#define TRACEMS(cinfo,lvl,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS1(cinfo,lvl,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS2(cinfo,lvl,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMSS(cinfo,lvl,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) + +#endif /* JERROR_H */ diff --git a/include/amscimglib4/amscimglib4.h b/include/amscimglib4/amscimglib4.h index 3913e7c..0d53d9c 100644 --- a/include/amscimglib4/amscimglib4.h +++ b/include/amscimglib4/amscimglib4.h @@ -25,6 +25,12 @@ AMSCIMGLIB4_API int amscppdlltemplate_exportedtestfn(int a, int b); static const int amscimglib4_success = 0; static const int amscimglib4_failure = -1; +static const int amscimglib4_type_unknown = -1; +static const int amscimglib4_type_bmp = 1; +static const int amscimglib4_type_png = 2; +static const int amscimglib4_type_jpg = 3; + + // Main Dynamic Image Structure //bytebuf contans RGBARGBA information in the following order: @@ -73,8 +79,7 @@ AMSCIMGLIB4_API int amscimglib4_set_pixel(amscimglib4_image *img, int x, int y, AMSCIMGLIB4_API int amscimglib4_get_pixel(amscimglib4_image *img, int x, int y, amscimglib4_pixel *px); -AMSCIMGLIB4_API void amscimglib4_image_flipx(amscimglib4_image *img); -AMSCIMGLIB4_API void amscimglib4_image_flipy(amscimglib4_image *img); + ////////////////////////////////////////////// // Some limited image manipulation routines // @@ -83,10 +88,38 @@ AMSCIMGLIB4_API void amscimglib4_image_flipy(amscimglib4_image *img); //transposes an image AMSCIMGLIB4_API int amscimglib4_transpose_image(amscimglib4_image *img); +AMSCIMGLIB4_API void amscimglib4_image_flipx(amscimglib4_image *img); +AMSCIMGLIB4_API void amscimglib4_image_flipy(amscimglib4_image *img); + ////////////////////////////////////////////////// // Routines to load and save image file formats // ////////////////////////////////////////////////// +AMSCIMGLIB4_API int amscimglib4_magic_type(const char *fname); + +AMSCIMGLIB4_API void amscimglib4_readimage(const char *fname, amscimglib4_image *img); + +//writes an image to a file +// amscimglib4_type_bmp - write as a BMP +// amscimglib4_type_jpg - write as a JPG +// anything else - default is PNG +AMSCIMGLIB4_API void amscimglib4_writeimage_select(const char *fname, amscimglib4_image *img, int formatspec); + +//writes to a file of a given type based on filename extension +AMSCIMGLIB4_API void amscimglib4_writeimage(const char *fname, amscimglib4_image *img); + +AMSCIMGLIB4_API void amscimglib4_readimage_bmp(const char *fname, amscimglib4_image *img); +AMSCIMGLIB4_API void amscimglib4_writeimage_bmp(const char *fname, amscimglib4_image *img); + +AMSCIMGLIB4_API void amscimglib4_readimage_png(const char *fname, amscimglib4_image *img); +AMSCIMGLIB4_API void amscimglib4_writeimage_png(const char *fname, amscimglib4_image *img); + +AMSCIMGLIB4_API void amscimglib4_readimage_jpeg(const char *fname, amscimglib4_image *img); +AMSCIMGLIB4_API void amscimglib4_writeimage_jpeg(const char *fname, amscimglib4_image *img, int quality); + + + + #ifdef __cplusplus }; // end extern "C" #endif diff --git a/include/amscimglib4/amscimglib4_intl.h b/include/amscimglib4/amscimglib4_intl.h index dc8bd1a..4db1202 100644 --- a/include/amscimglib4/amscimglib4_intl.h +++ b/include/amscimglib4/amscimglib4_intl.h @@ -3,6 +3,12 @@ #include +#include +#include +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/amscimglib4/amscimglib4_bitmap.c b/src/amscimglib4/amscimglib4_bitmap.c index 477b3e3..551372c 100644 --- a/src/amscimglib4/amscimglib4_bitmap.c +++ b/src/amscimglib4/amscimglib4_bitmap.c @@ -70,7 +70,7 @@ void amscimglib4_printheader(amscimglib4_bitmapfileheader *filehead, amscimglib4 } -void amscimglib4_readimage_bmp(const char *fname, amscimglib4_image *img) +AMSCIMGLIB4_API void amscimglib4_readimage_bmp(const char *fname, amscimglib4_image *img) { FILE *fp = NULL; int I,J; @@ -192,7 +192,7 @@ void amscimglib4_readimage_bmp(const char *fname, amscimglib4_image *img) } -void amscimglib4_writeimage_bmp(const char *fname, amscimglib4_image *img) +AMSCIMGLIB4_API void amscimglib4_writeimage_bmp(const char *fname, amscimglib4_image *img) { FILE *fp = NULL; diff --git a/src/amscimglib4/amscimglib4_image.c b/src/amscimglib4/amscimglib4_image.c index 2dc6df0..2f3f772 100644 --- a/src/amscimglib4/amscimglib4_image.c +++ b/src/amscimglib4/amscimglib4_image.c @@ -333,6 +333,146 @@ AMSCIMGLIB4_API void amscimglib4_image_flipy(amscimglib4_image *img) return; } + +AMSCIMGLIB4_API void amscimglib4_readimage(const char *fname, amscimglib4_image *img) +{ + int type = amscimglib4_magic_type(fname); + + if(type==amscimglib4_type_bmp) + { + //BMP + amscimglib4_readimage_bmp(fname,img); + } + else if(type==amscimglib4_type_png) + { + //PNG + amscimglib4_readimage_png(fname,img); + } + else if(type==amscimglib4_type_jpg) + { + //JPEG + amscimglib4_readimage_jpeg(fname,img); + } + else + { + printf("amscimglib4readimage: %s: unrecognized file type!\n", fname); + } + return; +} + +AMSCIMGLIB4_API void amscimglib4_writeimage_select(const char *fname, amscimglib4_image *img, int formatspec) +{ + amscimglib4_image *zeroimg = NULL; + if(img->sizex>0&&img->sizey>0) //do not write zero size images + { + if(formatspec == amscimglib4_type_bmp) + { + amscimglib4_writeimage_bmp(fname,img); + } + else if(formatspec == amscimglib4_type_png) + { + amscimglib4_writeimage_png(fname,img); + } + else if(formatspec == amscimglib4_type_jpg) + { + amscimglib4_writeimage_jpeg(fname,img,100); + } + else + { + //default to PNG + amscimglib4_writeimage_png(fname,img); + } + + } //do not write zero size images + else + { + amscimglib4_image_new(&zeroimg,1,1); + if(formatspec == amscimglib4_type_bmp) + { + amscimglib4_writeimage_bmp(fname,zeroimg); + } + else if(formatspec == amscimglib4_type_png) + { + amscimglib4_writeimage_png(fname,zeroimg); + } + else if(formatspec == amscimglib4_type_jpg) + { + amscimglib4_writeimage_jpeg(fname,zeroimg,100); + } + else + { + //default to PNG + amscimglib4_writeimage_png(fname,zeroimg); + } + amscimglib4_image_delete(&zeroimg); + }//do not write zero size images + + return; +} + +void amscimglib4_get_extension(const char *fname, char *extension, int bufflen) +{ + int I; + int len = strlen(fname); + int ind; + + ind = 0; + for(I=len;I>=0;I--) + { + if(fname[I]=='.') + { + ind = I; + break; + } + } + + if(ind>0) + { + for(I=ind;I<(len)&&(I-ind)<(bufflen-1);I++) + { + extension[I-ind] = fname[I]; + } + extension[I-ind] = '\0'; + + } + else + { + extension[0] = '\0'; + } + + for(I=0;I