jpeg_compressor.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 
00038 class CL_IODevice;
00039 class CL_JPEGCompressor_Impl;
00040 
00044 class CL_API_DISPLAY CL_JPEGCompressor
00045 {
00048 
00049 public:
00050         CL_JPEGCompressor();
00051 
00055 
00056 public:
00057 
00061 
00062 public:
00063         enum ColorSpace
00064         {
00065                 grayscale,
00066                 rgb,
00067                 ycbcr,
00068                 cmyk,
00069                 ycck
00070         };
00071 
00072         enum SpecialMarker
00073         {
00074                 marker_rst0 = 0xD0,
00075                 marker_eoi  = 0xD9,
00076                 marker_app0 = 0xe0,
00077                 marker_app1 = 0xe1, // EXIF data
00078                 marker_app2 = 0xe2, // FlashPix Ready data (is that a fancy word for thumbnail?)
00079                 marker_app3 = 0xe3,
00080                 marker_app4 = 0xe4,
00081                 marker_app5 = 0xe5,
00082                 marker_app6 = 0xe6,
00083                 marker_app7 = 0xe7,
00084                 marker_app8 = 0xe8,
00085                 marker_app9 = 0xe9,
00086                 marker_app10 = 0xea,
00087                 marker_app11 = 0xeb,
00088                 marker_app12 = 0xec,
00089                 marker_app13 = 0xed,
00090                 marker_app14 = 0xee,
00091                 marker_com  = 0xfe
00092         };
00093 
00097         void set_output(CL_IODevice output_source);
00098 
00102         void set_quality(int quality);
00103 
00108         void set_size(int width, int height);
00109 
00116         void set_color_space(ColorSpace in_color_space, int in_components, ColorSpace out_color_space, int out_components);
00117 
00121         void start(bool raw_data = false);
00122 
00128         void write_marker(int marker, const void * const data, int length);
00129 
00133         void write_comment_marker(const CL_StringRef &comment);
00134 
00139         void write_scanlines(const unsigned char **data, unsigned int lines);
00140 
00145         void write_raw_data(const unsigned char ***data, unsigned int lines);
00146 
00148         void finish();
00149 
00153 
00154 private:
00155         CL_SharedPtr<CL_JPEGCompressor_Impl> impl;
00157 };
00158