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: 2025-07-11 10:11:13 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             :  * SPDX-License-Identifier: MIT
      10             :  ****************************************************************************/
      11             : 
      12             : #include "pcidsk_exception.h"
      13             : #include "segment/cpcidsklut.h"
      14             : #include <cassert>
      15             : #include <cstring>
      16             : 
      17             : using namespace PCIDSK;
      18             : 
      19             : PCIDSK_LUT::~PCIDSK_LUT() = default;
      20             : 
      21             : /************************************************************************/
      22             : /*                            CPCIDSK_LUT()                             */
      23             : /************************************************************************/
      24             : 
      25           0 : CPCIDSK_LUT::CPCIDSK_LUT( PCIDSKFile *fileIn, int segmentIn,
      26           0 :                           const char *segment_pointer )
      27           0 :         : CPCIDSKSegment( fileIn, segmentIn, segment_pointer )
      28             : 
      29             : {
      30           0 : }
      31             : 
      32             : /************************************************************************/
      33             : /*                           ~CPCIDSKGeoref()                           */
      34             : /************************************************************************/
      35             : 
      36           0 : CPCIDSK_LUT::~CPCIDSK_LUT()
      37             : 
      38             : {
      39           0 : }
      40             : 
      41             : /************************************************************************/
      42             : /*                              ReadLUT()                               */
      43             : /************************************************************************/
      44             : 
      45           0 : void CPCIDSK_LUT::ReadLUT(std::vector<unsigned char>& lut)
      46             : 
      47             : {
      48           0 :     PCIDSKBuffer seg_data;
      49             : 
      50           0 :     seg_data.SetSize(256*4);
      51             : 
      52           0 :     ReadFromFile( seg_data.buffer, 0, 256*4);
      53             : 
      54           0 :     lut.resize(256);
      55           0 :     for( int i = 0; i < 256; i++ )
      56             :     {
      57           0 :         lut[i] = (unsigned char) seg_data.GetInt(0+i*4, 4);
      58             :     }
      59           0 : }
      60             : 
      61             : /************************************************************************/
      62             : /*                              WriteLUT()                              */
      63             : /************************************************************************/
      64             : 
      65           0 : void CPCIDSK_LUT::WriteLUT(const std::vector<unsigned char>& lut)
      66             : 
      67             : {
      68           0 :     if(lut.size() != 256)
      69             :     {
      70           0 :         throw PCIDSKException("LUT must contain 256 entries (%d given)", static_cast<int>(lut.size()));
      71             :     }
      72             : 
      73           0 :     PCIDSKBuffer seg_data;
      74             : 
      75           0 :     seg_data.SetSize(256*4);
      76             : 
      77           0 :     ReadFromFile( seg_data.buffer, 0, 256*4 );
      78             : 
      79             :     int i;
      80           0 :     for( i = 0; i < 256; i++ )
      81             :     {
      82           0 :         seg_data.Put( (int) lut[i], i*4, 4);
      83             :     }
      84             : 
      85           0 :     WriteToFile( seg_data.buffer, 0, 256*4 );
      86           0 : }

Generated by: LCOV version 1.14