00001 #if !defined(_GJPEG_H_) && HAS_LIBJPEG
00002 #define _GJPEG_H_
00003
00004 #define XMD_H
00005 #undef FAR
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "jpeglib.h"
00015 #include <setjmp.h>
00016
00017
00018 class LibJpeg : public GLibrary
00019 {
00020 public:
00021 LibJpeg() :
00022 #if defined(WIN32) && defined(_DEBUG)
00023 GLibrary("libjpegd")
00024 #else
00025 GLibrary("libjpeg")
00026 #endif
00027 {
00028 #if 0
00029 char File[256];
00030 GetModuleFileName(Handle(), File, sizeof(File));
00031 LgiTrace("%s:%i - JPEG: %s\n", __FILE__, __LINE__, File);
00032 #endif
00033 }
00034
00035 DynFunc1(boolean, jpeg_finish_decompress, j_decompress_ptr, cinfo);
00036 DynFunc3(JDIMENSION, jpeg_read_scanlines, j_decompress_ptr, cinfo, JSAMPARRAY, scanlines, JDIMENSION, max_lines);
00037 DynFunc1(boolean, jpeg_start_decompress, j_decompress_ptr, cinfo);
00038 DynFunc2(int, jpeg_read_header, j_decompress_ptr, cinfo, boolean, require_image);
00039 DynFunc2(int, jpeg_stdio_src, j_decompress_ptr, cinfo, FILE*, infile);
00040 DynFunc1(int, jpeg_destroy_decompress, j_decompress_ptr, cinfo);
00041 DynFunc1(int, jpeg_finish_compress, j_compress_ptr, cinfo);
00042 DynFunc1(int, jpeg_destroy_compress, j_compress_ptr, cinfo);
00043 DynFunc3(JDIMENSION, jpeg_write_scanlines, j_compress_ptr, cinfo, JSAMPARRAY, scanlines, JDIMENSION, num_lines);
00044 DynFunc2(int, jpeg_start_compress, j_compress_ptr, cinfo, boolean, write_all_tables);
00045 DynFunc1(int, jpeg_set_defaults, j_compress_ptr, cinfo);
00046 DynFunc1(struct jpeg_error_mgr *, jpeg_std_error, struct jpeg_error_mgr *, err);
00047 DynFunc2(int, jpeg_stdio_dest, j_compress_ptr, cinfo, FILE *, outfile);
00048 DynFunc3(int, jpeg_CreateCompress, j_compress_ptr, cinfo, int, version, size_t, structsize);
00049 DynFunc3(int, jpeg_CreateDecompress, j_decompress_ptr, cinfo, int, version, size_t, structsize);
00050 DynFunc3(int, jpeg_set_quality, j_compress_ptr, cinfo, int, quality, boolean, force_baseline);
00051
00052 DynFunc3(int, jpeg_save_markers, j_decompress_ptr, cinfo, int, marker_code, unsigned int, length_limit);
00053
00054 };
00055
00056 class GdcJpeg : public GFilter, public LibJpeg
00057 {
00058 friend class GJpegOptions;
00059
00060 bool _Write(GStream *Out, GSurface *pDC, int Quality);
00061
00062 public:
00063 Format GetFormat() { return FmtJpeg; }
00064 int GetCapabilites() { return FILTER_CAP_READ | FILTER_CAP_WRITE; }
00065 bool ReadImage(GSurface *pDC, GStream *In);
00066 bool WriteImage(GStream *Out, GSurface *pDC);
00067
00068 bool GetVariant(const char *n, GVariant &v, char *a)
00069 {
00070 if (!stricmp(n, LGI_FILTER_TYPE))
00071 {
00072 v = "Jpeg";
00073 }
00074 else if (!stricmp(n, LGI_FILTER_EXTENSIONS))
00075 {
00076 v = "JPG,JPEG";
00077 }
00078 else return false;
00079
00080 return true;
00081 }
00082 };
00083
00084 #endif