jpeg_decompressor.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_display.h"
00035 #include "../Image/pixel_buffer.h"
00036 #include "../../Core/Text/string_types.h"
00037 #include <vector>
00038 
00039 class CL_IODevice;
00040 class CL_JPEGDecompressor_Impl;
00041 
00045 class CL_API_DISPLAY CL_JPEGDecompressor
00046 {
00049 
00050 public:
00051 
00055         CL_JPEGDecompressor(CL_IODevice input_source);
00056 
00060 
00061 public:
00062         enum SpecialMarker
00063         {
00064                 marker_rst0 = 0xD0,
00065                 marker_eoi  = 0xD9,
00066                 marker_app0 = 0xe0,
00067                 marker_app1 = 0xe1, // EXIF data
00068                 marker_app2 = 0xe2, // FlashPix Ready data (is that a fancy word for thumbnail?)
00069                 marker_app3 = 0xe3,
00070                 marker_app4 = 0xe4,
00071                 marker_app5 = 0xe5,
00072                 marker_app6 = 0xe6,
00073                 marker_app7 = 0xe7,
00074                 marker_app8 = 0xe8,
00075                 marker_app9 = 0xe9,
00076                 marker_app10 = 0xea,
00077                 marker_app11 = 0xeb,
00078                 marker_app12 = 0xec,
00079                 marker_app13 = 0xed,
00080                 marker_app14 = 0xee,
00081                 marker_com  = 0xfe
00082         };
00083 
00084         struct SavedMarker
00085         {
00086                 unsigned char marker;
00087                 unsigned int original_length;
00088                 unsigned int data_length;
00089                 void *data;
00090         };
00091 
00095         int get_output_width() const;
00096 
00100         int get_output_height() const;
00101 
00105         int get_output_components() const;
00106 
00107         std::vector<SavedMarker> get_saved_markers() const;
00108 
00112 
00113 public:
00114 
00119         void record_marker(SpecialMarker marker_code, unsigned int length_limit = 0xffff);
00120 
00124         void start(bool raw_data = false);
00125 
00126         unsigned int read_scanlines(unsigned char **data, unsigned int lines);
00127 
00128         unsigned int read_raw_data(const unsigned char ***data, unsigned int lines);
00129 
00131         void finish();
00132 
00136 
00137 private:
00138         CL_SharedPtr<CL_JPEGDecompressor_Impl> impl;
00140 };
00141