aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CImageLoaderJPG.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CImageLoaderJPG.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CImageLoaderJPG.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CImageLoaderJPG.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CImageLoaderJPG.h
new file mode 100644
index 0000000..d3d0633
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CImageLoaderJPG.h
@@ -0,0 +1,116 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_IMAGE_LOADER_JPG_H_INCLUDED__
6#define __C_IMAGE_LOADER_JPG_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9
10#ifdef _IRR_COMPILE_WITH_JPG_LOADER_
11
12#include "IImageLoader.h"
13
14#include <stdio.h> // required for jpeglib.h
15#ifdef _IRR_COMPILE_WITH_LIBJPEG_
16extern "C" {
17 #ifndef _IRR_USE_NON_SYSTEM_JPEG_LIB_
18 #include <jpeglib.h> // use system lib
19 #else
20 #include "jpeglib/jpeglib.h" // use irrlicht jpeglib
21 #endif
22 #include <setjmp.h>
23}
24#endif // _IRR_COMPILE_WITH_LIBJPEG_
25
26
27namespace irr
28{
29namespace video
30{
31
32
33//! Surface Loader for JPG images
34class CImageLoaderJPG : public IImageLoader
35{
36public:
37
38 //! constructor
39 CImageLoaderJPG();
40
41 //! destructor
42 virtual ~CImageLoaderJPG();
43
44 //! returns true if the file maybe is able to be loaded by this class
45 //! based on the file extension (e.g. ".tga")
46 virtual bool isALoadableFileExtension(const io::path& filename) const;
47
48 //! returns true if the file maybe is able to be loaded by this class
49 virtual bool isALoadableFileFormat(io::IReadFile* file) const;
50
51 //! creates a surface from the file
52 virtual IImage* loadImage(io::IReadFile* file) const;
53
54private:
55
56 #ifdef _IRR_COMPILE_WITH_LIBJPEG_
57 // several methods used via function pointers by jpeglib
58
59 /* Receives control for a fatal error. Information sufficient to
60 generate the error message has been stored in cinfo->err; call
61 output_message to display it. Control must NOT return to the caller;
62 generally this routine will exit() or longjmp() somewhere.
63 Typically you would override this routine to get rid of the exit()
64 default behavior. Note that if you continue processing, you should
65 clean up the JPEG object with jpeg_abort() or jpeg_destroy().
66 */
67 static void error_exit (j_common_ptr cinfo);
68
69 /* output error messages via Irrlicht logger. */
70 static void output_message(j_common_ptr cinfo);
71
72 /* Initialize source. This is called by jpeg_read_header() before any
73 data is actually read. Unlike init_destination(), it may leave
74 bytes_in_buffer set to 0 (in which case a fill_input_buffer() call
75 will occur immediately). */
76 static void init_source (j_decompress_ptr cinfo);
77
78 /* This is called whenever bytes_in_buffer has reached zero and more
79 data is wanted. In typical applications, it should read fresh data
80 into the buffer (ignoring the current state of next_input_byte and
81 bytes_in_buffer), reset the pointer & count to the start of the
82 buffer, and return TRUE indicating that the buffer has been reloaded.
83 It is not necessary to fill the buffer entirely, only to obtain at
84 least one more byte. bytes_in_buffer MUST be set to a positive value
85 if TRUE is returned. A FALSE return should only be used when I/O
86 suspension is desired (this mode is discussed in the next section). */
87 static boolean fill_input_buffer (j_decompress_ptr cinfo);
88
89 /* Skip num_bytes worth of data. The buffer pointer and count should
90 be advanced over num_bytes input bytes, refilling the buffer as
91 needed. This is used to skip over a potentially large amount of
92 uninteresting data (such as an APPn marker). In some applications
93 it may be possible to optimize away the reading of the skipped data,
94 but it's not clear that being smart is worth much trouble; large
95 skips are uncommon. bytes_in_buffer may be zero on return.
96 A zero or negative skip count should be treated as a no-op. */
97 static void skip_input_data (j_decompress_ptr cinfo, long num_bytes);
98
99 /* Terminate source --- called by jpeg_finish_decompress() after all
100 data has been read. Often a no-op. */
101 static void term_source (j_decompress_ptr cinfo);
102
103 // Copy filename to have it around for error-messages
104 static io::path Filename;
105
106 #endif // _IRR_COMPILE_WITH_LIBJPEG_
107};
108
109
110} // end namespace video
111} // end namespace irr
112
113
114#endif
115#endif
116