LCOV - code coverage report
Current view: top level - frmts/gtiff - gtiffbitmapband.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 22 25 88.0 %
Date: 2024-05-18 15:15:27 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GeoTIFF Driver
       4             :  * Purpose:  GDAL GeoTIFF support.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 1998, 2002, Frank Warmerdam <warmerdam@pobox.com>
       9             :  * Copyright (c) 2007-2015, Even Rouault <even dot rouault at spatialys dot com>
      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 "gtiffbitmapband.h"
      31             : #include "gtiffdataset.h"
      32             : 
      33             : /************************************************************************/
      34             : /*                           GTiffBitmapBand()                          */
      35             : /************************************************************************/
      36             : 
      37         332 : GTiffBitmapBand::GTiffBitmapBand(GTiffDataset *poDSIn, int nBandIn)
      38         332 :     : GTiffOddBitsBand(poDSIn, nBandIn)
      39             : 
      40             : {
      41         332 :     eDataType = GDT_Byte;
      42             : 
      43         332 :     if (poDSIn->m_poColorTable != nullptr)
      44             :     {
      45          29 :         m_poColorTable = poDSIn->m_poColorTable->Clone();
      46             :     }
      47             :     else
      48             :     {
      49             : #ifdef ESRI_BUILD
      50             :         m_poColorTable = nullptr;
      51             : #else
      52         303 :         const GDALColorEntry oWhite = {255, 255, 255, 255};
      53         303 :         const GDALColorEntry oBlack = {0, 0, 0, 255};
      54             : 
      55         303 :         m_poColorTable = new GDALColorTable();
      56             : 
      57         303 :         if (poDSIn->m_nPhotometric == PHOTOMETRIC_MINISWHITE)
      58             :         {
      59           0 :             m_poColorTable->SetColorEntry(0, &oWhite);
      60           0 :             m_poColorTable->SetColorEntry(1, &oBlack);
      61             :         }
      62             :         else
      63             :         {
      64         303 :             m_poColorTable->SetColorEntry(0, &oBlack);
      65         303 :             m_poColorTable->SetColorEntry(1, &oWhite);
      66             :         }
      67             : #endif  // not defined ESRI_BUILD.
      68             :     }
      69         332 : }
      70             : 
      71             : /************************************************************************/
      72             : /*                          ~GTiffBitmapBand()                          */
      73             : /************************************************************************/
      74             : 
      75         654 : GTiffBitmapBand::~GTiffBitmapBand()
      76             : 
      77             : {
      78         332 :     delete m_poColorTable;
      79         654 : }
      80             : 
      81             : /************************************************************************/
      82             : /*                       GetColorInterpretation()                       */
      83             : /************************************************************************/
      84             : 
      85          83 : GDALColorInterp GTiffBitmapBand::GetColorInterpretation()
      86             : 
      87             : {
      88          83 :     if (m_poGDS->m_bPromoteTo8Bits)
      89          48 :         return GCI_Undefined;
      90             : 
      91          35 :     return GCI_PaletteIndex;
      92             : }
      93             : 
      94             : /************************************************************************/
      95             : /*                           GetColorTable()                            */
      96             : /************************************************************************/
      97             : 
      98          34 : GDALColorTable *GTiffBitmapBand::GetColorTable()
      99             : 
     100             : {
     101          34 :     if (m_poGDS->m_bPromoteTo8Bits)
     102           0 :         return nullptr;
     103             : 
     104          34 :     return m_poColorTable;
     105             : }

Generated by: LCOV version 1.14