svn-gvsig-desktop / tags / v2_0_0_prep_before_2001 / libraries / libjni-mrsid-macosx / include / base / lti_imageWriter.h @ 44480
History | View | Annotate | Download (8.13 KB)
1 |
/* $Id: lti_imageWriter.h 9099 2006-11-29 12:16:22Z mija $ */
|
---|---|
2 |
/* //////////////////////////////////////////////////////////////////////////
|
3 |
// //
|
4 |
// This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
|
5 |
// Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
|
6 |
// prohibited. Access to and use of this code is permitted only under //
|
7 |
// license from LizardTech, Inc. Portions of the code are protected by //
|
8 |
// US and foreign patents and other filings. All Rights Reserved. //
|
9 |
// //
|
10 |
////////////////////////////////////////////////////////////////////////// */
|
11 |
/* PUBLIC */
|
12 |
|
13 |
#ifndef LTI_IMAGEWRITER_H
|
14 |
#define LTI_IMAGEWRITER_H
|
15 |
|
16 |
// lt_lib_base
|
17 |
#include "lt_base.h" |
18 |
|
19 |
// lt_lib_mrsid_core
|
20 |
#include "lti_imageFilter.h" |
21 |
|
22 |
LT_BEGIN_NAMESPACE(LizardTech) |
23 |
|
24 |
#if defined(LT_COMPILER_MS)
|
25 |
#pragma warning(push,4) |
26 |
#endif
|
27 |
|
28 |
class LTIReusableBSQBuffer; |
29 |
class LTIProgressDelegate; |
30 |
class LTIInterruptDelegate; |
31 |
|
32 |
|
33 |
/**
|
34 |
* abstract class for implementing an image writer
|
35 |
*
|
36 |
* The LTIImageWriter abstract class is used to output pixels from an image
|
37 |
* pipeline to an actual image format. The classes MG3ImageWriter,
|
38 |
* TIFFImageWriter, etc, derive from this class.
|
39 |
*/
|
40 |
class LTIImageWriter |
41 |
{ |
42 |
public:
|
43 |
/**
|
44 |
* constructor
|
45 |
*
|
46 |
* This constructor creates an abstract image writer for the given
|
47 |
* image stage.
|
48 |
*
|
49 |
* Note that the pointer to the input image stage may not be NULL.
|
50 |
* The writer does not take ownership of the image stage.
|
51 |
*
|
52 |
* @param image the source of image data to be written
|
53 |
*/
|
54 |
LTIImageWriter(LTIImageStage* image); |
55 |
|
56 |
/**
|
57 |
* destructor
|
58 |
*/
|
59 |
virtual ~LTIImageWriter(); |
60 |
|
61 |
/**
|
62 |
* initialization function
|
63 |
*/
|
64 |
virtual LT_STATUS initialize(); |
65 |
|
66 |
/**
|
67 |
* write (encode) a scene to the output format
|
68 |
*
|
69 |
* This function writes the given scene to the implemented image format.
|
70 |
*
|
71 |
* The write() function just calls writeBegin() for the given scene(),
|
72 |
* then calls writeStrip() repeatedly for each strip in the scene(), then
|
73 |
* calls writeEnd().
|
74 |
*
|
75 |
* A derived classes should not override this function, unless it has
|
76 |
* special requirements for interacting with the rest of the image
|
77 |
* pipeline.
|
78 |
*
|
79 |
* @param scene the scene to decode and output
|
80 |
* @return status code indicating success or failure
|
81 |
*/
|
82 |
virtual LT_STATUS write(const LTIScene& scene);
|
83 |
|
84 |
/**
|
85 |
* begin an encode (write) operation
|
86 |
*
|
87 |
* This function implements the logic for beginning the encoding of the
|
88 |
* given scene.
|
89 |
*
|
90 |
* The scene must be a valid scene for the underlying image pipeline.
|
91 |
*
|
92 |
* This function is called by write(). Derived classes must implement
|
93 |
* this function.
|
94 |
*
|
95 |
* @param scene the scene to decode and output
|
96 |
* @return status code indicating success or failure
|
97 |
*/
|
98 |
virtual LT_STATUS writeBegin(const LTIScene& scene) =0; |
99 |
|
100 |
/**
|
101 |
* encode one strip of the scene
|
102 |
*
|
103 |
* This function implements the logic for actually encoding a given strip
|
104 |
* of the given scene.
|
105 |
*
|
106 |
* This function is called by write(). Derived classes must implement
|
107 |
* this function.
|
108 |
*
|
109 |
* @param stripBuffer the pixels for the current strip
|
110 |
* @param stripScene the scene representing the strip being written
|
111 |
* @return status code indicating success or failure
|
112 |
*/
|
113 |
virtual LT_STATUS writeStrip(LTISceneBuffer& stripBuffer, |
114 |
const LTIScene& stripScene) =0; |
115 |
|
116 |
/**
|
117 |
* complete an encode (write) operation
|
118 |
*
|
119 |
* This function implements the logic for completing the encoding of the
|
120 |
* given scene.
|
121 |
*
|
122 |
* This function is called by write(). Derived classes must implement
|
123 |
* this function.
|
124 |
*
|
125 |
* @return status code indicating success or failure
|
126 |
*/
|
127 |
virtual LT_STATUS writeEnd() =0;
|
128 |
|
129 |
/**
|
130 |
* set the stripheight for the encode
|
131 |
*
|
132 |
* This function sets the stripheight to be used when encoding a scene,
|
133 |
* i.e. the number of rows to process at one time. This value is used
|
134 |
* to control the decode requests from the image pipeline.
|
135 |
*
|
136 |
* @param stripHeight the number of rows to encode at one time
|
137 |
* @return status code indicating success or failure
|
138 |
*/
|
139 |
virtual LT_STATUS setStripHeight(lt_uint32 stripHeight); |
140 |
|
141 |
/**
|
142 |
* get the stripheight for the encode
|
143 |
*
|
144 |
* Returns the number of rows which will be encoded at a time.
|
145 |
*
|
146 |
* @return the stripheight setting of the encoder
|
147 |
*/
|
148 |
virtual lt_uint32 getStripHeight() const;
|
149 |
|
150 |
/**
|
151 |
* get the preferred stripheight for the encode
|
152 |
*
|
153 |
* Returns the preferred stripheight for the encoder. By default, this is
|
154 |
* just the stripheight of the underlying image pipeline. A derived class
|
155 |
* may override this to reflect specific needs of an encoder
|
156 |
* implementation, however.
|
157 |
*
|
158 |
* @return the preferred stripheight setting of the encoder
|
159 |
*/
|
160 |
virtual lt_uint32 getDefaultStripHeight() const;
|
161 |
|
162 |
/**
|
163 |
* get the cost to encode the scene
|
164 |
*
|
165 |
* Returns the cost to encode this scene, for application using the usage
|
166 |
* metering system. See LTIImageStage::getEncodingCost() for details.
|
167 |
*
|
168 |
* @param scene the scene to determine the cost for
|
169 |
* @return the cost for the scene
|
170 |
*/
|
171 |
virtual lt_int64 getEncodingCost(const LTIScene& scene) const; |
172 |
|
173 |
/**
|
174 |
* set progress delegate
|
175 |
*
|
176 |
* This function sets the progress delegate, which is used in a callback-like
|
177 |
* fashion to report percent-complete of a write() operation back to the
|
178 |
* calling application.
|
179 |
*
|
180 |
* Passing NULL to this function should remove the LTIImageWriter's current delegate,
|
181 |
* if any.
|
182 |
*
|
183 |
* Note this function does not take ownership of the delegate object.
|
184 |
*
|
185 |
* @param delegate a pointer to the delegate object to be used by the image writer
|
186 |
*/
|
187 |
virtual void setProgressDelegate(LTIProgressDelegate* delegate);
|
188 |
|
189 |
/**
|
190 |
* set interrupt delegate
|
191 |
*
|
192 |
* This function sets the interrupt delegate, which is used in a callback-like
|
193 |
* fashion by the calling application to asynchronously indicate that a write()
|
194 |
* operation should be halted without completing.
|
195 |
*
|
196 |
* Passing NULL to this function should remove the LTIImageWriter's current delegate,
|
197 |
* if any.
|
198 |
*
|
199 |
* Note this function does not take ownership of the delegate object.
|
200 |
*
|
201 |
* @param delegate a pointer to the delegate object to be used by the image writer
|
202 |
*/
|
203 |
virtual void setInterruptDelegate(LTIInterruptDelegate* delegate);
|
204 |
|
205 |
protected:
|
206 |
/**
|
207 |
* get progress delegate
|
208 |
*
|
209 |
* This function returns the object's progress delegate.
|
210 |
*
|
211 |
* The function will return NULL if no delegate has been set.
|
212 |
*
|
213 |
* Derived classes should call this method from within their write()
|
214 |
* methods so that they can inform the user of the progress of the write
|
215 |
* operation.
|
216 |
*
|
217 |
* @return a pointer to the delegate object (or NULL if no delegate has been set)
|
218 |
*/
|
219 |
virtual LTIProgressDelegate* getProgressDelegate() const;
|
220 |
|
221 |
/**
|
222 |
* get interrupt delegate
|
223 |
*
|
224 |
* This function returns the object's interrupt delegate.
|
225 |
*
|
226 |
* The function will return NULL if no delegate has been set.
|
227 |
*
|
228 |
* Derived classes should call this method from within their write()
|
229 |
* methods so that they can determine if the user has requested that the write
|
230 |
* operation should be aborted.
|
231 |
*
|
232 |
* @return a pointer to the delegate object (or NULL if no delegate has been set)
|
233 |
*/
|
234 |
virtual LTIInterruptDelegate* getInterruptDelegate() const;
|
235 |
|
236 |
LTIImageStage* m_image; |
237 |
|
238 |
private:
|
239 |
LT_STATUS checkDelegates(const LTIScene& fullScene,
|
240 |
const LTIScene* currScene,
|
241 |
bool atEnd);
|
242 |
|
243 |
lt_uint32 m_stripHeight; |
244 |
LTIReusableBSQBuffer* m_buffer; |
245 |
|
246 |
LTIProgressDelegate* m_progressDelegate; |
247 |
LTIInterruptDelegate* m_interruptDelegate; |
248 |
|
249 |
// nope
|
250 |
LTIImageWriter(); |
251 |
LTIImageWriter(LTIImageWriter&); |
252 |
LTIImageWriter& operator=(const LTIImageWriter&);
|
253 |
}; |
254 |
|
255 |
|
256 |
LT_END_NAMESPACE(LizardTech) |
257 |
|
258 |
#if defined(LT_COMPILER_MS)
|
259 |
#pragma warning(pop)
|
260 |
#endif
|
261 |
|
262 |
#endif // LTI_IMAGEWRITER_H |