00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef header_provider_jpeg_generic
00018 #define header_provider_jpeg_generic
00019
00020 #ifdef WIN32
00021 #define XMD_H
00022 #endif
00023
00024 #include <stdio.h>
00025 extern "C"
00026 {
00027 #include <jpeglib.h>
00028 }
00029
00030 #include "API/core.h"
00031 #include "API/Display/Display/pixelformat.h"
00032 #include "API/Core/System/clanstring.h"
00033
00034 class CL_Surface;
00035 class CL_InputSourceProvider;
00036 class CL_Palette;
00037
00038 class CL_JPEGProvider_Generic
00039
00040 {
00041 public:
00042 CL_JPEGProvider_Generic(
00043 CL_String name,
00044 CL_InputSourceProvider *provider = NULL,
00045 bool transparent=true,
00046 bool ignore_alphachannel=false);
00047
00055
00056 ~CL_JPEGProvider_Generic();
00057
00058 unsigned int get_pitch() const { return pitch; }
00059
00060
00061 unsigned int get_width() const { return width; }
00062
00063
00064 unsigned int get_height() const { return height; }
00065
00066
00067 unsigned int get_num_frames() const { return 1; }
00068
00069
00070 EPixelFormat get_pixel_format() const { return RGB888; }
00071
00072
00073 CL_Palette *get_palette() const { return NULL; }
00074
00075
00076 unsigned int get_src_colorkey() const { return 0; }
00077
00078
00079 bool uses_src_colorkey() const { return false; }
00080
00081
00082 bool is_indexed() const { return false; }
00083
00084
00085 unsigned int get_red_mask() const;
00086
00087
00088 unsigned int get_green_mask() const;
00089
00090
00091 unsigned int get_blue_mask() const;
00092
00093
00094 unsigned int get_alpha_mask() const;
00095
00096
00097 void *get_data() const;
00098
00099
00100 void perform_lock();
00101
00102
00103 void perform_unlock();
00104
00105
00106 private:
00107 CL_String filename;
00108 int locked;
00109
00110 unsigned char *image;
00111
00112 int pitch;
00113 int width, height;
00114
00115 int bpp;
00116
00117 bool transparent, ignore_alphachannel, use_alphapixels;
00118
00119 unsigned char trans_redcol, trans_greencol, trans_bluecol;
00120
00121 int pos;
00122
00123 typedef struct
00124 {
00125 struct jpeg_source_mgr pub;
00126 CL_JPEGProvider_Generic* jpeg_provider;
00127 JOCTET * buffer;
00128 boolean start_of_file;
00129 } InputSource_source_mgr;
00130
00131 typedef InputSource_source_mgr* InputSource_src_ptr;
00132
00133
00134 static void jpeg_InputSource_src (j_decompress_ptr cinfo, CL_JPEGProvider_Generic* prov);
00135 static void init_source (j_decompress_ptr cinfo);
00136 static boolean fill_input_buffer (j_decompress_ptr cinfo);
00137 static void skip_input_data (j_decompress_ptr cinfo, long num_bytes);
00138 static void term_source (j_decompress_ptr cinfo);
00139
00140 CL_InputSourceProvider* input_provider;
00141 CL_InputSource* input_source;
00142 };
00143
00144 #endif