PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 34ms app.codeStats 1ms

/indra/llimage/llimagejpeg.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 86 lines | 44 code | 16 blank | 26 comment | 0 complexity | 3339227099f727c2947bf47e3b0a23d0 MD5 | raw file
 1/** 
 2 * @file llimagejpeg.h
 3 * @brief This class compresses and decompresses JPEG files
 4 *
 5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LLIMAGEJPEG_H
28#define LL_LLIMAGEJPEG_H
29
30#include <csetjmp>
31
32#include "llimage.h"
33
34extern "C" {
35#ifdef LL_STANDALONE
36# include <jpeglib.h>
37# include <jerror.h>
38#else
39# include "jpeglib/jpeglib.h"
40# include "jpeglib/jerror.h"
41#endif
42}
43
44class LLImageJPEG : public LLImageFormatted
45{
46protected:
47	virtual ~LLImageJPEG();
48	
49public:
50	LLImageJPEG(S32 quality = 75);
51
52	/*virtual*/ std::string getExtension() { return std::string("jpg"); }
53	/*virtual*/ BOOL updateData();
54	/*virtual*/ BOOL decode(LLImageRaw* raw_image, F32 decode_time);
55	/*virtual*/ BOOL encode(const LLImageRaw* raw_image, F32 encode_time);
56
57	void			setEncodeQuality( S32 q )	{ mEncodeQuality = q; } // on a scale from 1 to 100
58	S32				getEncodeQuality()			{ return mEncodeQuality; }
59
60	// Callbacks registered with jpeglib
61	static void		encodeInitDestination ( j_compress_ptr cinfo );
62	static boolean	encodeEmptyOutputBuffer(j_compress_ptr cinfo);
63	static void		encodeTermDestination(j_compress_ptr cinfo);
64
65	static void		decodeInitSource(j_decompress_ptr cinfo);
66	static boolean	decodeFillInputBuffer(j_decompress_ptr cinfo);
67	static void		decodeSkipInputData(j_decompress_ptr cinfo, long num_bytes);
68	static void		decodeTermSource(j_decompress_ptr cinfo);
69
70
71	static void		errorExit(j_common_ptr cinfo);
72	static void		errorEmitMessage(j_common_ptr cinfo, int msg_level);
73	static void		errorOutputMessage(j_common_ptr cinfo);
74
75	static BOOL		decompress(LLImageJPEG* imagep);
76
77protected:
78	U8*				mOutputBuffer;		// temp buffer used during encoding
79	S32				mOutputBufferSize;	// bytes in mOuputBuffer
80
81	S32				mEncodeQuality;		// on a scale from 1 to 100
82private:
83	static jmp_buf	sSetjmpBuffer;		// To allow the library to abort.
84};
85
86#endif  // LL_LLIMAGEJPEG_H