2 * Copyright (c) 2007, Digital Signal Processing Laboratory, Universit� degli studi di Perugia (UPG), Italy
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
8 * 1. Redistributions of source code must retain the above copyright
\r
9 * notice, this list of conditions and the following disclaimer.
\r
10 * 2. Redistributions in binary form must reproduce the above copyright
\r
11 * notice, this list of conditions and the following disclaimer in the
\r
12 * documentation and/or other materials provided with the distribution.
\r
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
\r
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
24 * POSSIBILITY OF SUCH DAMAGE.
\r
26 /////////////////////////////////////////////////////////////////////////////
\r
28 // Purpose: wxImage JPEG 2000 raw codestream handler
\r
29 // Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
\r
30 // RCS-ID: $Id: imagj2k.h,v 0.0 2007/02/08 23:45:00 VZ Exp $
\r
31 // Copyright: (c) Giuseppe Baruffa
\r
32 // Licence: wxWindows licence
\r
33 /////////////////////////////////////////////////////////////////////////////
\r
35 #ifndef _WX_IMAGJ2K_H_
\r
36 #define _WX_IMAGJ2K_H_
\r
38 #include "wx/defs.h"
\r
40 //-----------------------------------------------------------------------------
\r
42 //-----------------------------------------------------------------------------
\r
44 #if wxUSE_LIBOPENJPEG
\r
46 #include "wx/image.h"
\r
47 #include "libopenjpeg/openjpeg.h"
\r
49 #define wxBITMAP_TYPE_J2K 47
\r
51 #define wxIMAGE_OPTION_REDUCEFACTOR wxString(_T("reducefactor"))
\r
52 #define wxIMAGE_OPTION_QUALITYLAYERS wxString(_T("qualitylayers"))
\r
53 #define wxIMAGE_OPTION_MAXCOMPS wxString(_T("maxcomps"))
\r
55 #define wxIMAGE_OPTION_ENABLEJPWL wxString(_T("enablejpwl"))
\r
56 #define wxIMAGE_OPTION_EXPCOMPS wxString(_T("expcomps"))
\r
57 #define wxIMAGE_OPTION_MAXTILES wxString(_T("maxtiles"))
\r
60 class WXDLLEXPORT wxJ2KHandler: public wxImageHandler
\r
63 inline wxJ2KHandler()
\r
65 m_name = wxT("JPEG 2000 codestream file");
\r
66 m_extension = wxT("j2k");
\r
67 m_type = wxBITMAP_TYPE_J2K;
\r
68 m_mime = wxT("image/j2k");
\r
72 m_qualitylayers = 0;
\r
75 m_enablejpwl = true;
\r
76 m_expcomps = JPWL_EXPECTED_COMPONENTS;
\r
77 m_maxtiles = JPWL_MAXIMUM_TILES;
\r
81 m_subsampling = wxT("1,1");
\r
82 m_origin = wxT("0,0");
\r
83 m_rates = wxT("20,10,5");
\r
84 m_quality = wxT("30,35,40");
\r
85 m_irreversible = false;
\r
87 m_cbsize = wxT("32,32");
\r
88 m_prsize = wxT("[128,128],[128,128]");
\r
90 m_torigin = wxT("0,0");
\r
93 m_enablesop = false;
\r
94 m_enableeph = false;
\r
98 m_enableidx = false;
\r
99 m_index = wxT("index.txt");
\r
100 m_enablecomm = true;
\r
102 #if defined __WXMSW__
\r
103 m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
\r
104 #elif defined __WXGTK__
\r
105 m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
\r
107 m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
\r
111 m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
\r
113 m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
\r
118 // decoding engine parameters
\r
119 int m_reducefactor, m_qualitylayers, m_components;
\r
122 int m_expcomps, m_maxtiles;
\r
125 // encoding engine parameters
\r
126 wxString m_subsampling;
\r
129 wxString m_quality;
\r
130 bool m_irreversible;
\r
135 wxString m_torigin;
\r
146 wxString m_comment;
\r
148 bool write_index_file(opj_codestream_info_t *cstr_info, char *index);
\r
151 virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
\r
152 virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true );
\r
154 virtual bool DoCanRead( wxInputStream& stream );
\r
158 DECLARE_DYNAMIC_CLASS(wxJ2KHandler)
\r
161 #endif // wxUSE_LIBOPENJPEG
\r
163 #endif // _WX_IMAGJ2K_H_
\r