Reformat: apply reformattin on .h files (#128)
[openjpeg.git] / src / bin / wx / OPJViewer / source / imagjpeg2000.h
1 /*
2  * The copyright in this software is being made available under the 2-clauses
3  * BSD License, included below. This software may be subject to other third
4  * party and contributor rights, including patent rights, and no such rights
5  * are granted under this license.
6  *
7  * Copyright (c) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 /////////////////////////////////////////////////////////////////////////////
32 // Name:        imagalljpeg2000.h
33 // Purpose:     wxImage JPEG 2000 family file format handler
34 // Author:      G. Baruffa - based on imagjpeg.h, Vaclav Slavik
35 // RCS-ID:      $Id: imagalljpeg2000.h,v 0.0 2008/01/31 11:22:00 VZ Exp $
36 // Copyright:   (c) Giuseppe Baruffa
37 // Licence:     wxWindows licence
38 /////////////////////////////////////////////////////////////////////////////
39
40 #ifndef _WX_IMAGJPEG2000_H_
41 #define _WX_IMAGJPEG2000_H_
42
43 #include "wx/defs.h"
44
45 //-----------------------------------------------------------------------------
46 // wxJPEG2000Handler
47 //-----------------------------------------------------------------------------
48
49 #if wxUSE_LIBOPENJPEG
50
51 #include "wx/image.h"
52 #include "openjp2/openjpeg.h"
53 #include "jp2/index.h"
54
55 #define wxBITMAP_TYPE_JPEG2000  50
56
57 class WXDLLEXPORT wxJPEG2000Handler: public wxImageHandler
58 {
59 public:
60     inline wxJPEG2000Handler()
61     {
62         m_name = wxT("JPEG 2000 family file format");
63         m_extension = wxT("mj2");
64         m_type = wxBITMAP_TYPE_JPEG2000;
65         m_mime = wxT("image/mj2");
66
67         /* decoding */
68         m_reducefactor = 0;
69         m_qualitylayers = 0;
70         m_components = 0;
71 #ifdef USE_JPWL
72         m_enablejpwl = true;
73         m_expcomps = JPWL_EXPECTED_COMPONENTS;
74         m_maxtiles = JPWL_MAXIMUM_TILES;
75 #endif // USE_JPWL
76
77         /* encoding */
78         m_subsampling = wxT("1,1");
79         m_origin = wxT("0,0");
80         m_rates = wxT("20,10,5");
81         m_quality = wxT("30,35,40");
82         m_enablequality = false;
83         m_multicomp = false;
84         m_irreversible = false;
85         m_resolutions = 6;
86         m_progression = 0;
87         m_cbsize = wxT("32,32");
88         m_prsize = wxT("[128,128],[128,128]");
89         m_tsize = wxT("");
90         m_torigin = wxT("0,0");
91         /*m_progression
92         m_resilience*/
93         m_enablesop = false;
94         m_enableeph = false;
95         m_enablereset = false;
96         m_enablesegmark = false;
97         m_enablevsc = false;
98         m_enablerestart = false;
99         m_enableerterm = false;
100         m_enablebypass = false;
101         /*m_roicompo
102         m_roiup
103         m_indexfname*/
104         m_enableidx = false;
105         m_index = wxT("index.txt");
106         m_enablepoc = false;
107         m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
108         m_enablecomm = true;
109
110 #if defined __WXMSW__
111         m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG  version ");
112 #elif defined __WXGTK__
113         m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
114 #else
115         m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
116 #endif
117
118 #ifdef USE_JPWL
119         m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
120 #else
121         m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
122 #endif
123
124     }
125
126     // decoding engine parameters
127     int m_reducefactor, m_qualitylayers, m_components, m_framenum;
128 #ifdef USE_JPWL
129     bool m_enablejpwl;
130     int m_expcomps, m_maxtiles;
131 #endif // USE_JPWL
132
133     // encoding engine parameters
134     wxString m_subsampling;
135     wxString m_origin;
136     wxString m_rates;
137     wxString m_quality;
138     bool m_enablequality;
139     bool m_multicomp;
140     bool m_irreversible;
141     int m_resolutions;
142     int m_progression;
143     wxString m_cbsize;
144     wxString m_prsize;
145     wxString m_tsize;
146     wxString m_torigin;
147     /*m_progression
148     m_resilience*/
149     bool m_enablesop;
150     bool m_enableeph;
151     bool m_enablebypass;
152     bool m_enableerterm;
153     bool m_enablerestart;
154     bool m_enablereset;
155     bool m_enablesegmark;
156     bool m_enablevsc;
157     /*m_roicompo
158     m_roiup
159     m_indexfname*/
160     bool m_enableidx;
161     wxString m_index;
162     bool m_enablecomm;
163     wxString m_comment;
164     bool m_enablepoc;
165     wxString m_poc;
166
167 #if wxUSE_STREAMS
168     virtual bool LoadFile(wxImage *image, wxInputStream& stream,
169                           bool verbose = true, int index = -1);
170     virtual bool SaveFile(wxImage *image, wxOutputStream& stream,
171                           bool verbose = true);
172 protected:
173     virtual bool DoCanRead(wxInputStream& stream);
174 #endif
175
176 private:
177     OPJ_PROG_ORDER give_progression(char progression[4]);
178     DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
179 };
180
181 #endif // wxUSE_LIBOPENJPEG
182
183 #endif // _WX_IMAGJPEG2000_H_
184