Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-mrsid / include / filters / lti_colorTransformer.h @ 3539

History | View | Annotate | Download (5.09 KB)

1
/* $Id: lti_colorTransformer.h 3539 2006-01-09 12:23:20Z nacho $ */
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_COLORTRANSFORMER_H
14
#define LTI_COLORTRANSFORMER_H
15

    
16
// lt_lib_mrsid_core
17
#include "lti_imageFilter.h"
18

    
19

    
20
LT_BEGIN_NAMESPACE(LizardTech)
21

    
22
#if defined(LT_COMPILER_MS)
23
   #pragma warning(push,4)
24
#endif
25

    
26
class LTIReusableBSQBuffer;
27

    
28
/**
29
 * change the colorspace of the image
30
 *
31
 * This class changes the colorspace of the image.
32
 *
33
 * The supported color transforms are:
34
 * \li from RGB to CMYK, GRAYSCALE, or YIQ
35
 * \li from GRAYSCALE to RGB
36
 * \li from CMYK to RGB, RGBK, or YIQK
37
 * \li from YIQ to RGB
38
 * \li from YIQK to CMYK
39
 */
40
class LTIColorTransformer : public LTIImageFilter
41
{
42
public:
43
   /**
44
    * constructor
45
    *
46
    * Creates an image stage with the given colorspace.  The sample values
47
    * will undergo the requisite color transform function to map from the
48
    * input colorspace to the output colorspace.
49
    *
50
    * @note The value of \a dstNumBands image is set according to the
51
    * \a dstColorSpace, as is in the constructor for the LTIPixel class.
52
    *
53
    * @param  sourceImage    the base image
54
    * @param  dstColorSpace  the colorspace of the new image
55
    * @param  dstNumBands    the number of bands in the new image
56
    * @param  takeOwnership  set to true to have the filter delete the \a sourceImage
57
    */
58
   LTIColorTransformer(LTIImageStage* sourceImage,
59
                       LTIColorSpace dstColorSpace,
60
                       lt_uint16 dstNumBands,
61
                       bool takeOwnership);
62
   virtual ~LTIColorTransformer();
63
   virtual LT_STATUS initialize();
64

    
65
protected:
66
   LT_STATUS decodeBegin(const LTIScene& scene);
67
   LT_STATUS decodeEnd();
68
   LT_STATUS decodeStrip(LTISceneBuffer& stripBuffer, const LTIScene& stripScene);
69

    
70
protected: // these are only protected for the temporary LTIColorTransformerMultiband class
71
   LTIPixel* remapPixel(const LTIPixel& pixel);
72

    
73
   const LTIColorSpace m_dstColorSpace;
74
   const lt_uint16 m_dstNumBands;
75
   LTIColorSpace m_srcColorSpace;
76
   lt_uint16 m_srcNumBands;
77
   bool m_isIdentity;
78

    
79
   LTIReusableBSQBuffer* m_buffer;
80

    
81
private:
82
   // nope
83
   LTIColorTransformer(const LTIColorTransformer&);
84
   LTIColorTransformer& operator=(const LTIColorTransformer&);
85
};
86

    
87

    
88

    
89
/**
90
 * Extends LTIColorTransformer to change the colorspace of the image and
91
 * also remap the bands.
92
 *
93
 * This class is typically used for mapping multispectral images to known
94
 * (and often displayable) colorspaces.  For example, a 6-banded
95
 * multispectral image might be changed to an RGB colorspace using only bands
96
 * 0, 2, and 3.
97
 *
98
 * Note that the allowed remapping of bands is different than in the
99
 * LTISampleMapTransformer class.
100
 *
101
 * @note This class is likely to change in a future release.
102
 */
103
class LTIColorTransformerMultiband : public LTIColorTransformer
104
{
105
public:
106
   /**
107
   * Constructor.
108
   *
109
   * Creates an image stage with the given colorspace using the given
110
   * remapping of bands.
111
   *
112
   * The \a dstBandMap parameter is an array of band numbers.  The array
113
   * elements must be within the range of the number of bands in the input
114
   * colorspace, and the number of elements in the array must be equal to
115
   * \a dstNumBands.  A given band may be specified more than once.
116
   *
117
   * @note The value of \a dstNumBands image is set according to the
118
   * \a dstColorSpace, as is in the constructor for the LTIPixel class.
119
   *
120
   * @param  sourceImage    the base image
121
   * @param  dstColorSpace  the colorspace of the new image
122
   * @param  dstBandMap     the array of bands to map to the new colorspace
123
   * @param  dstNumBands    the number of bands in the new image
124
   * @param  takeOwnership  set to true to have the filter delete the \a sourceImage
125
   */
126
   LTIColorTransformerMultiband(LTIImageStage* sourceImage,
127
                                LTIColorSpace dstColorSpace,
128
                                lt_uint16* dstBandMap,
129
                                lt_uint16 dstNumBands,
130
                                bool takeOwnership);
131
   virtual ~LTIColorTransformerMultiband();
132
   virtual LT_STATUS initialize();
133

    
134
   LT_STATUS decodeStrip(LTISceneBuffer &stripBuffer, const LTIScene &stripScene);
135

    
136
private:
137
   typedef LTIColorTransformer Super;
138

    
139
   const lt_uint16 *m_dstBandMapCtor;
140
   lt_uint16 *m_dstBandMap;
141
   LTIColorTransformerMultiband(const LTIColorTransformerMultiband&);
142
   LTIColorTransformerMultiband& operator=(const LTIColorTransformerMultiband&);
143
};
144

    
145
LT_END_NAMESPACE(LizardTech)
146

    
147
#if defined(LT_COMPILER_MS)
148
        #pragma warning(pop)
149
#endif
150

    
151
#endif // LTI_COLORTRANSFORMER_H