Changeset 14749
- Timestamp:
- 06/21/08 20:17:46 (5 months ago)
- Files:
-
- branches/1.5/gdal/frmts/hfa/hfacompress.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/gdal/frmts/hfa/hfacompress.cpp
r10645 r14749 39 39 m_nDataTypeNumBits = HFAGetDataTypeBits( m_nDataType ); 40 40 m_nBlockSize = nBlockSize; 41 m_nBlockCount = nBlockSize / ( m_nDataTypeNumBits / 8 );41 m_nBlockCount = (nBlockSize * 8) / m_nDataTypeNumBits; 42 42 43 43 /* Allocate some memory for the count and values - probably too big */ 44 44 /* About right for worst case scenario tho */ 45 m_pCounts = (GByte*)CPLMalloc( m_nBlock Size+ sizeof(GUInt32) );45 m_pCounts = (GByte*)CPLMalloc( m_nBlockCount + sizeof(GUInt32) ); 46 46 m_nSizeCounts = 0; 47 47 48 m_pValues = (GByte*)CPLMalloc( m_nBlock Size+ sizeof(GUInt32) );48 m_pValues = (GByte*)CPLMalloc( m_nBlockCount + sizeof(GUInt32) ); 49 49 m_nSizeValues = 0; 50 50 … … 79 79 80 80 /* Gets the value from the uncompressed block as a GUInt32 no matter the data type */ 81 GUInt32 HFACompress::valueAsUInt32( GUInt32 i ndex)82 { 83 GUInt32 val = 0;81 GUInt32 HFACompress::valueAsUInt32( GUInt32 iPixel ) 82 { 83 GUInt32 val = 0; 84 84 85 85 if( m_nDataTypeNumBits == 8 ) 86 86 { 87 val = ((GByte*)m_pData)[i ndex];87 val = ((GByte*)m_pData)[iPixel]; 88 88 } 89 89 else if( m_nDataTypeNumBits == 16 ) 90 90 { 91 val = ((GUInt16*)m_pData)[i ndex];91 val = ((GUInt16*)m_pData)[iPixel]; 92 92 } 93 93 else if( m_nDataTypeNumBits == 32 ) 94 94 { 95 val = ((GUInt32*)m_pData)[index]; 95 val = ((GUInt32*)m_pData)[iPixel]; 96 } 97 else if( m_nDataTypeNumBits == 4 ) 98 { 99 if( iPixel % 2 == 0 ) 100 val = ((GByte*)m_pData)[iPixel/2] & 0x0f; 101 else 102 val = (((GByte*)m_pData)[iPixel/2] & 0xf0) >> 4; 103 } 104 else if( m_nDataTypeNumBits == 2 ) 105 { 106 if( iPixel % 2 == 0 ) 107 val = ((GByte*)m_pData)[iPixel/4] & 0x03; 108 else if( iPixel % 2 == 1 ) 109 val = (((GByte*)m_pData)[iPixel/4] & 0x0c) >> 2; 110 else if( iPixel % 2 == 2 ) 111 val = (((GByte*)m_pData)[iPixel/4] & 0x30) >> 4; 112 else 113 val = (((GByte*)m_pData)[iPixel/4] & 0xc0) >> 6; 114 } 115 else if( m_nDataTypeNumBits == 1 ) 116 { 117 if( ((GByte*)m_pData)[iPixel >> 3] & (0x1 << (iPixel & 0x07)) ) 118 val = 1; 119 else 120 val = 0; 96 121 } 97 122 else … … 272 297 int nBits = HFAGetDataTypeBits( nHFADataType ); 273 298 274 return ( nBits == 8 ) || ( nBits == 16 ) || ( nBits == 32 ); 275 } 276 299 return ( nBits == 8 ) || ( nBits == 16 ) || ( nBits == 32 ) || (nBits == 4) 300 || (nBits == 2) || (nBits == 1); 301 } 302
