Coverage Report

Created: 2025-06-13 06:29

/src/gdal/frmts/gtiff/gtiffbitmapband.cpp
Line
Count
Source (jump to first uncovered line)
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
/************************************************************************/
18
/*                           GTiffBitmapBand()                          */
19
/************************************************************************/
20
21
GTiffBitmapBand::GTiffBitmapBand(GTiffDataset *poDSIn, int nBandIn)
22
0
    : GTiffOddBitsBand(poDSIn, nBandIn)
23
24
0
{
25
0
    eDataType = GDT_Byte;
26
27
0
    if (poDSIn->m_poColorTable != nullptr)
28
0
    {
29
0
        m_poColorTable = poDSIn->m_poColorTable->Clone();
30
0
    }
31
0
    else
32
0
    {
33
#ifdef ESRI_BUILD
34
        m_poColorTable = nullptr;
35
#else
36
0
        const GDALColorEntry oWhite = {255, 255, 255, 255};
37
0
        const GDALColorEntry oBlack = {0, 0, 0, 255};
38
39
0
        m_poColorTable = new GDALColorTable();
40
41
0
        if (poDSIn->m_nPhotometric == PHOTOMETRIC_MINISWHITE)
42
0
        {
43
0
            m_poColorTable->SetColorEntry(0, &oWhite);
44
0
            m_poColorTable->SetColorEntry(1, &oBlack);
45
0
        }
46
0
        else
47
0
        {
48
0
            m_poColorTable->SetColorEntry(0, &oBlack);
49
0
            m_poColorTable->SetColorEntry(1, &oWhite);
50
0
        }
51
0
#endif  // not defined ESRI_BUILD.
52
0
    }
53
0
}
54
55
/************************************************************************/
56
/*                          ~GTiffBitmapBand()                          */
57
/************************************************************************/
58
59
GTiffBitmapBand::~GTiffBitmapBand()
60
61
0
{
62
0
    delete m_poColorTable;
63
0
}
64
65
/************************************************************************/
66
/*                       GetColorInterpretation()                       */
67
/************************************************************************/
68
69
GDALColorInterp GTiffBitmapBand::GetColorInterpretation()
70
71
0
{
72
0
    if (m_poGDS->m_bPromoteTo8Bits)
73
0
        return GCI_Undefined;
74
75
0
    return GCI_PaletteIndex;
76
0
}
77
78
/************************************************************************/
79
/*                           GetColorTable()                            */
80
/************************************************************************/
81
82
GDALColorTable *GTiffBitmapBand::GetColorTable()
83
84
0
{
85
0
    if (m_poGDS->m_bPromoteTo8Bits)
86
0
        return nullptr;
87
88
0
    return m_poColorTable;
89
0
}