1 : /*****************************************************************************
2 : * $Id: IntergraphBand.h 16211 2009-01-31 22:15:18Z 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 : public:
62 : IntergraphRasterBand( IntergraphDataset *poDS,
63 : int nBand,
64 : int nBandOffset,
65 : GDALDataType eType = GDT_Unknown);
66 : ~IntergraphRasterBand();
67 :
68 : virtual double GetMinimum( int *pbSuccess = NULL );
69 : virtual double GetMaximum( int *pbSuccess = NULL );
70 : virtual GDALColorTable *GetColorTable();
71 : virtual GDALColorInterp GetColorInterpretation();
72 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
73 : virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void *pImage );
74 : virtual CPLErr SetColorTable( GDALColorTable *poColorTable );
75 : virtual CPLErr SetStatistics( double dfMin, double dfMax, double dfMean, double dfStdDev );
76 :
77 : protected:
78 : int HandleUninstantiatedTile( int nBlockXOff, int nBlockYOff, void* pImage);
79 : int LoadBlockBuf( int nBlockXOff, int nBlockYOff, int nBlockBytes, GByte *pabyBlock );
80 : void ReshapeBlock( int nBlockXOff, int nBlockYOff, int nBlockBytes, GByte *pabyBlock );
81 : void FlushBandHeader( void );
82 : void BlackWhiteCT( bool bReverse = false );
83 : };
84 :
85 : // ----------------------------------------------------------------------------
86 : // Intergraph IntergraphRGBBand
87 : // ----------------------------------------------------------------------------
88 :
89 : class IntergraphRGBBand : public IntergraphRasterBand
90 36 : {
91 : public:
92 : IntergraphRGBBand( IntergraphDataset *poDS,
93 : int nBand,
94 : int nBandOffset,
95 : int nRGorB );
96 :
97 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
98 : };
99 :
100 : // ----------------------------------------------------------------------------
101 : // Intergraph IntergraphBitmapBand
102 : // ----------------------------------------------------------------------------
103 :
104 : class IntergraphBitmapBand : public IntergraphRasterBand
105 : {
106 : friend class IntergraphDataset;
107 :
108 : private:
109 : GByte *pabyBMPBlock;
110 : uint32 nBMPSize;
111 : int nQuality;
112 : int nRGBBand;
113 :
114 : public:
115 : IntergraphBitmapBand( IntergraphDataset *poDS,
116 : int nBand,
117 : int nBandOffset,
118 : int nRGorB = 1 );
119 : ~IntergraphBitmapBand();
120 :
121 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
122 : virtual GDALColorInterp GetColorInterpretation();
123 : };
124 :
125 : // ----------------------------------------------------------------------------
126 : // Intergraph IntergraphRLEBand
127 : // ----------------------------------------------------------------------------
128 :
129 : class IntergraphRLEBand : public IntergraphRasterBand
130 : {
131 : friend class IntergraphDataset;
132 :
133 : private:
134 : GByte *pabyRLEBlock;
135 : uint32 nRLESize;
136 : int bRLEBlockLoaded;
137 : uint32 *panRLELineOffset;
138 :
139 : public:
140 : IntergraphRLEBand( IntergraphDataset *poDS,
141 : int nBand,
142 : int nBandOffset,
143 : int nRGorB = 0);
144 : ~IntergraphRLEBand();
145 :
146 : virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void *pImage );
147 : };
|