LCOV - code coverage report
Current view: top level - frmts/gtiff - gtiffbitmapband.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 26 29 89.7 %
Date: 2025-10-21 22:35:35 Functions: 6 6 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             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #include "gtiffbitmapband.h"
      15             : #include "gtiffdataset.h"
      16             : 
      17             : #include "gdal_priv.h"
      18             : 
      19             : /************************************************************************/
      20             : /*                           GTiffBitmapBand()                          */
      21             : /************************************************************************/
      22             : 
      23         408 : GTiffBitmapBand::GTiffBitmapBand(GTiffDataset *poDSIn, int nBandIn)
      24         408 :     : GTiffOddBitsBand(poDSIn, nBandIn)
      25             : 
      26             : {
      27         408 :     eDataType = GDT_Byte;
      28             : 
      29         408 :     if (poDSIn->m_poColorTable != nullptr)
      30             :     {
      31          29 :         m_poColorTable = poDSIn->m_poColorTable->Clone();
      32             :     }
      33             :     else
      34             :     {
      35             : #ifdef ESRI_BUILD
      36             :         m_poColorTable = nullptr;
      37             : #else
      38         379 :         const GDALColorEntry oWhite = {255, 255, 255, 255};
      39         379 :         const GDALColorEntry oBlack = {0, 0, 0, 255};
      40             : 
      41         379 :         m_poColorTable = new GDALColorTable();
      42             : 
      43         379 :         if (poDSIn->m_nPhotometric == PHOTOMETRIC_MINISWHITE)
      44             :         {
      45           0 :             m_poColorTable->SetColorEntry(0, &oWhite);
      46           0 :             m_poColorTable->SetColorEntry(1, &oBlack);
      47             :         }
      48             :         else
      49             :         {
      50         379 :             m_poColorTable->SetColorEntry(0, &oBlack);
      51         379 :             m_poColorTable->SetColorEntry(1, &oWhite);
      52             :         }
      53             : #endif  // not defined ESRI_BUILD.
      54             :     }
      55         408 : }
      56             : 
      57             : /************************************************************************/
      58             : /*                          ~GTiffBitmapBand()                          */
      59             : /************************************************************************/
      60             : 
      61         806 : GTiffBitmapBand::~GTiffBitmapBand()
      62             : 
      63             : {
      64         408 :     delete m_poColorTable;
      65         806 : }
      66             : 
      67             : /************************************************************************/
      68             : /*                       GetColorInterpretation()                       */
      69             : /************************************************************************/
      70             : 
      71         111 : GDALColorInterp GTiffBitmapBand::GetColorInterpretation()
      72             : 
      73             : {
      74         111 :     if (m_poGDS->m_bPromoteTo8Bits)
      75          76 :         return GCI_Undefined;
      76             : 
      77          35 :     return GCI_PaletteIndex;
      78             : }
      79             : 
      80             : /************************************************************************/
      81             : /*                       SetColorInterpretation()                       */
      82             : /************************************************************************/
      83             : 
      84           2 : CPLErr GTiffBitmapBand::SetColorInterpretation(GDALColorInterp eInterp)
      85             : {
      86           2 :     if (eInterp != GetColorInterpretation())
      87             :     {
      88           1 :         CPLDebug(
      89             :             "GTiff",
      90             :             "Setting color interpration on GTiffBitmap band is not supported");
      91             :     }
      92           2 :     return CE_None;
      93             : }
      94             : 
      95             : /************************************************************************/
      96             : /*                           GetColorTable()                            */
      97             : /************************************************************************/
      98             : 
      99          34 : GDALColorTable *GTiffBitmapBand::GetColorTable()
     100             : 
     101             : {
     102          34 :     if (m_poGDS->m_bPromoteTo8Bits)
     103           0 :         return nullptr;
     104             : 
     105          34 :     return m_poColorTable;
     106             : }

Generated by: LCOV version 1.14