LCOV - code coverage report
Current view: directory - frmts/pcidsk/sdk/segment - cpcidskpct.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 25 25 100.0 %
Date: 2011-12-18 Functions: 7 4 57.1 %

       1                 : /******************************************************************************
       2                 :  *
       3                 :  * Purpose:  Implementation of the CPCIDSK_PCT class.
       4                 :  * 
       5                 :  ******************************************************************************
       6                 :  * Copyright (c) 2009
       7                 :  * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, 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/cpcidskpct.h"
      30                 : #include <cassert>
      31                 : #include <cstring>
      32                 : 
      33                 : using namespace PCIDSK;
      34                 : 
      35                 : /************************************************************************/
      36                 : /*                            CPCIDSK_PCT()                             */
      37                 : /************************************************************************/
      38                 : 
      39               2 : CPCIDSK_PCT::CPCIDSK_PCT( PCIDSKFile *file, int segment,
      40                 :                           const char *segment_pointer )
      41               2 :         : CPCIDSKSegment( file, segment, segment_pointer )
      42                 : 
      43                 : {
      44               2 : }
      45                 : 
      46                 : /************************************************************************/
      47                 : /*                           ~CPCIDSKGeoref()                           */
      48                 : /************************************************************************/
      49                 : 
      50               2 : CPCIDSK_PCT::~CPCIDSK_PCT()
      51                 : 
      52                 : {
      53               2 : }
      54                 : 
      55                 : /************************************************************************/
      56                 : /*                              ReadPCT()                               */
      57                 : /************************************************************************/
      58                 : 
      59               1 : void CPCIDSK_PCT::ReadPCT( unsigned char pct[768] )
      60                 : 
      61                 : {
      62               1 :     PCIDSKBuffer seg_data;
      63                 : 
      64               1 :     seg_data.SetSize( 768*4 );
      65                 : 
      66               1 :     ReadFromFile( seg_data.buffer, 0, 768*4 );
      67                 : 
      68                 :     int i;
      69             257 :     for( i = 0; i < 256; i++ )
      70                 :     {
      71             256 :         pct[  0+i] = (unsigned char) seg_data.GetInt(   0+i*4, 4 );
      72             256 :         pct[256+i] = (unsigned char) seg_data.GetInt(1024+i*4, 4 );
      73             256 :         pct[512+i] = (unsigned char) seg_data.GetInt(2048+i*4, 4 );
      74               1 :     }
      75               1 : }
      76                 : 
      77                 : /************************************************************************/
      78                 : /*                              WritePCT()                              */
      79                 : /************************************************************************/
      80                 : 
      81               1 : void CPCIDSK_PCT::WritePCT( unsigned char pct[768] )
      82                 : 
      83                 : {
      84               1 :     PCIDSKBuffer seg_data;
      85                 : 
      86               1 :     seg_data.SetSize( 768*4 );
      87                 : 
      88               1 :     ReadFromFile( seg_data.buffer, 0, 768*4 );
      89                 : 
      90                 :     int i;
      91             257 :     for( i = 0; i < 256; i++ )
      92                 :     {
      93             256 :         seg_data.Put( (int) pct[  0+i],   0+i*4, 4 );
      94             256 :         seg_data.Put( (int) pct[256+i],1024+i*4, 4 );
      95             256 :         seg_data.Put( (int) pct[512+i],2048+i*4, 4 );
      96                 :     }
      97                 : 
      98               1 :     WriteToFile( seg_data.buffer, 0, 768*4 );
      99               1 : }

Generated by: LCOV version 1.7