LCOV - code coverage report
Current view: top level - frmts/pcidsk/sdk/segment - cpcidsklut.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 24 0.0 %
Date: 2024-04-27 17:22:41 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Purpose:  Implementation of the CPCIDSK_LUT class.
       4             :  *
       5             :  ******************************************************************************
       6             :  * Copyright (c) 2015
       7             :  * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada.
       8             :  *
       9             :  * Permission is hereby granted, free of charge, to any person obtaining a
      10             :  * copy of this software and associated documentation files (the "Software"),
      11             :  * to deal in the Software without restriction, including without limitation
      12             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      13             :  * and/or sell copies of the Software, and to permit persons to whom the
      14             :  * Software is furnished to do so, subject to the following conditions:
      15             :  *
      16             :  * The above copyright notice and this permission notice shall be included
      17             :  * in all copies or substantial portions of the Software.
      18             :  *
      19             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      20             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      21             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      22             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      23             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      24             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      25             :  * DEALINGS IN THE SOFTWARE.
      26             :  ****************************************************************************/
      27             : 
      28             : #include "pcidsk_exception.h"
      29             : #include "segment/cpcidsklut.h"
      30             : #include <cassert>
      31             : #include <cstring>
      32             : 
      33             : using namespace PCIDSK;
      34             : 
      35             : /************************************************************************/
      36             : /*                            CPCIDSK_LUT()                             */
      37             : /************************************************************************/
      38             : 
      39           0 : CPCIDSK_LUT::CPCIDSK_LUT( PCIDSKFile *fileIn, int segmentIn,
      40           0 :                           const char *segment_pointer )
      41           0 :         : CPCIDSKSegment( fileIn, segmentIn, segment_pointer )
      42             : 
      43             : {
      44           0 : }
      45             : 
      46             : /************************************************************************/
      47             : /*                           ~CPCIDSKGeoref()                           */
      48             : /************************************************************************/
      49             : 
      50           0 : CPCIDSK_LUT::~CPCIDSK_LUT()
      51             : 
      52             : {
      53           0 : }
      54             : 
      55             : /************************************************************************/
      56             : /*                              ReadLUT()                               */
      57             : /************************************************************************/
      58             : 
      59           0 : void CPCIDSK_LUT::ReadLUT(std::vector<unsigned char>& lut)
      60             : 
      61             : {
      62           0 :     PCIDSKBuffer seg_data;
      63             : 
      64           0 :     seg_data.SetSize(256*4);
      65             : 
      66           0 :     ReadFromFile( seg_data.buffer, 0, 256*4);
      67             : 
      68           0 :     lut.resize(256);
      69           0 :     for( int i = 0; i < 256; i++ )
      70             :     {
      71           0 :         lut[i] = (unsigned char) seg_data.GetInt(0+i*4, 4);
      72             :     }
      73           0 : }
      74             : 
      75             : /************************************************************************/
      76             : /*                              WriteLUT()                              */
      77             : /************************************************************************/
      78             : 
      79           0 : void CPCIDSK_LUT::WriteLUT(const std::vector<unsigned char>& lut)
      80             : 
      81             : {
      82           0 :     if(lut.size() != 256)
      83             :     {
      84           0 :         throw PCIDSKException("LUT must contain 256 entries (%d given)", static_cast<int>(lut.size()));
      85             :     }
      86             : 
      87           0 :     PCIDSKBuffer seg_data;
      88             : 
      89           0 :     seg_data.SetSize(256*4);
      90             : 
      91           0 :     ReadFromFile( seg_data.buffer, 0, 256*4 );
      92             : 
      93             :     int i;
      94           0 :     for( i = 0; i < 256; i++ )
      95             :     {
      96           0 :         seg_data.Put( (int) lut[i], i*4, 4);
      97             :     }
      98             : 
      99           0 :     WriteToFile( seg_data.buffer, 0, 256*4 );
     100           0 : }

Generated by: LCOV version 1.14