1 : /*****************************************************************************
2 : * $Id: IntergraphBand.h 25785 2013-03-23 11:34:53Z rouault $
3 : *
4 : * Project: Intergraph Raster Format support
5 : * Purpose: Read selected types of Intergraph Raster Format
6 : * Author: Ivan Lucena [ivan.lucena@pmldnet.com]
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2007, Ivan Lucena
10 : *
11 : * Permission is hereby granted, free of charge, to any person obtaining a
12 : * copy of this software and associated documentation files ( the "Software" ),
13 : * to deal in the Software without restriction, including without limitation
14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 : * and/or sell copies of the Software, and to permit persons to whom the
16 : * Software is furnished to do so, subject to the following conditions:
17 : *
18 : * The above copyright notice and this permission notice shall be included
19 : * in all copies or substantial portions of the Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 : * DEALINGS IN THE SOFTWARE.
28 : *****************************************************************************/
29 :
30 : #include "IngrTypes.h"
31 :
32 : // ----------------------------------------------------------------------------
33 : // Intergraph IntergraphRasterBand
34 : // ----------------------------------------------------------------------------
35 :
36 : class IntergraphRasterBand : public GDALPamRasterBand
37 : {
38 : friend class IntergraphDataset;
39 :
40 : protected:
41 : GDALColorTable *poColorTable;
42 : uint32 nDataOffset;
43 : uint32 nBlockBufSize;
44 : uint32 nBandStart;
45 : uint8 nRGBIndex;
46 :
47 : INGR_Format eFormat;
48 : bool bTiled;
49 : int nFullBlocksX;
50 : int nFullBlocksY;
51 :
52 : GByte *pabyBlockBuf;
53 : uint32 nTiles;
54 :
55 : INGR_TileItem *pahTiles;
56 :
57 : INGR_HeaderOne hHeaderOne;
58 : INGR_HeaderTwoA hHeaderTwo;
59 : INGR_TileHeader hTileDir;
60 :
61 : int nRLEOffset;
62 :
63 : public:
64 : IntergraphRasterBand( IntergraphDataset *poDS,
65 : int nBand,
66 : int nBandOffset,
67 : GDALDataType eType = GDT_Unknown);
68 : ~IntergraphRasterBand();
69 :
70 : virtual double GetMinimum( int *pbSuccess = NULL );
71 : virtual double GetMaximum( int *pbSuccess = NULL );
72 : virtual GDALColorTable *GetColorTable();
73 : virtual GDALColorInterp GetColorInterpretation();
74 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
75 : virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void *pImage );
76 : virtual CPLErr SetColorTable( GDALColorTable *poColorTable );
77 : virtual CPLErr SetStatistics( double dfMin, double dfMax, double dfMean, double dfStdDev );
78 :
79 : protected:
80 : int HandleUninstantiatedTile( int nBlockXOff, int nBlockYOff, void* pImage);
81 : int LoadBlockBuf( int nBlockXOff, int nBlockYOff, int nBlockBytes, GByte *pabyBlock );
82 : void ReshapeBlock( int nBlockXOff, int nBlockYOff, int nBlockBytes, GByte *pabyBlock );
83 : void FlushBandHeader( void );
84 : void BlackWhiteCT( bool bReverse = false );
85 : };
86 :
87 : // ----------------------------------------------------------------------------
88 : // Intergraph IntergraphRGBBand
89 : // ----------------------------------------------------------------------------
90 :
91 : class IntergraphRGBBand : public IntergraphRasterBand
92 18 : {
93 : public:
94 : IntergraphRGBBand( IntergraphDataset *poDS,
95 : int nBand,
96 : int nBandOffset,
97 : int nRGorB );
98 :
99 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
100 : };
101 :
102 : // ----------------------------------------------------------------------------
103 : // Intergraph IntergraphBitmapBand
104 : // ----------------------------------------------------------------------------
105 :
106 : class IntergraphBitmapBand : public IntergraphRasterBand
107 : {
108 : friend class IntergraphDataset;
109 :
110 : private:
111 : GByte *pabyBMPBlock;
112 : uint32 nBMPSize;
113 : int nQuality;
114 : int nRGBBand;
115 :
116 : public:
117 : IntergraphBitmapBand( IntergraphDataset *poDS,
118 : int nBand,
119 : int nBandOffset,
120 : int nRGorB = 1 );
121 : ~IntergraphBitmapBand();
122 :
123 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
124 : virtual GDALColorInterp GetColorInterpretation();
125 : };
126 :
127 : // ----------------------------------------------------------------------------
128 : // Intergraph IntergraphRLEBand
129 : // ----------------------------------------------------------------------------
130 :
131 : class IntergraphRLEBand : public IntergraphRasterBand
132 : {
133 : friend class IntergraphDataset;
134 :
135 : private:
136 : GByte *pabyRLEBlock;
137 : uint32 nRLESize;
138 : int bRLEBlockLoaded;
139 : uint32 *panRLELineOffset;
140 :
141 : public:
142 : IntergraphRLEBand( IntergraphDataset *poDS,
143 : int nBand,
144 : int nBandOffset,
145 : int nRGorB = 0);
146 : ~IntergraphRLEBand();
147 :
148 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
149 : };
|