ClanLib  2.3.7
jpeg_decompressor.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
31 
32 #pragma once
33 
34 #include "../api_display.h"
35 #include "../Image/pixel_buffer.h"
36 #include "../../Core/Text/string_types.h"
37 #include <vector>
38 
39 class CL_IODevice;
40 class CL_JPEGDecompressor_Impl;
41 
46 {
49 
50 public:
51 
55  CL_JPEGDecompressor(CL_IODevice input_source);
56 
60 
61 public:
63  {
64  marker_rst0 = 0xD0,
65  marker_eoi = 0xD9,
66  marker_app0 = 0xe0,
67  marker_app1 = 0xe1, // EXIF data
68  marker_app2 = 0xe2, // FlashPix Ready data (is that a fancy word for thumbnail?)
69  marker_app3 = 0xe3,
70  marker_app4 = 0xe4,
71  marker_app5 = 0xe5,
72  marker_app6 = 0xe6,
73  marker_app7 = 0xe7,
74  marker_app8 = 0xe8,
75  marker_app9 = 0xe9,
76  marker_app10 = 0xea,
77  marker_app11 = 0xeb,
78  marker_app12 = 0xec,
79  marker_app13 = 0xed,
80  marker_app14 = 0xee,
81  marker_com = 0xfe
82  };
83 
84  struct SavedMarker
85  {
86  unsigned char marker;
87  unsigned int original_length;
88  unsigned int data_length;
89  void *data;
90  };
91 
95  int get_output_width() const;
96 
100  int get_output_height() const;
101 
105  int get_output_components() const;
106 
107  std::vector<SavedMarker> get_saved_markers() const;
108 
112 
113 public:
114 
119  void record_marker(SpecialMarker marker_code, unsigned int length_limit = 0xffff);
120 
124  void start(bool raw_data = false);
125 
126  unsigned int read_scanlines(unsigned char **data, unsigned int lines);
127 
128  unsigned int read_raw_data(const unsigned char ***data, unsigned int lines);
129 
131  void finish();
132 
136 
137 private:
138  CL_SharedPtr<CL_JPEGDecompressor_Impl> impl;
140 };
141