Coverage Report

Created: 2026-11-12 08:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/gtiff/gtiffbitmapband.cpp
Line
Count
Source
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
GTiffBitmapBand::GTiffBitmapBand(GTiffDataset *poDSIn, int nBandIn)
24
127k
    : GTiffOddBitsBand(poDSIn, nBandIn)
25
26
127k
{
27
127k
    eDataType = GDT_UInt8;
28
29
127k
    if (poDSIn->m_poColorTable != nullptr)
30
3.24k
    {
31
3.24k
        m_poColorTable = poDSIn->m_poColorTable->Clone();
32
3.24k
    }
33
124k
    else
34
124k
    {
35
#ifdef ESRI_BUILD
36
        m_poColorTable = nullptr;
37
#else
38
124k
        const GDALColorEntry oWhite = {255, 255, 255, 255};
39
124k
        const GDALColorEntry oBlack = {0, 0, 0, 255};
40
41
124k
        m_poColorTable = new GDALColorTable();
42
43
124k
        if (poDSIn->m_nPhotometric == PHOTOMETRIC_MINISWHITE)
44
0
        {
45
0
            m_poColorTable->SetColorEntry(0, &oWhite);
46
0
            m_poColorTable->SetColorEntry(1, &oBlack);
47
0
        }
48
124k
        else
49
124k
        {
50
124k
            m_poColorTable->SetColorEntry(0, &oBlack);
51
124k
            m_poColorTable->SetColorEntry(1, &oWhite);
52
124k
        }
53
124k
#endif  // not defined ESRI_BUILD.
54
124k
    }
55
127k
}
56
57
/************************************************************************/
58
/*                          ~GTiffBitmapBand()                          */
59
/************************************************************************/
60
61
GTiffBitmapBand::~GTiffBitmapBand()
62
63
127k
{
64
127k
    delete m_poColorTable;
65
127k
}
66
67
/************************************************************************/
68
/*                       GetColorInterpretation()                       */
69
/************************************************************************/
70
71
GDALColorInterp GTiffBitmapBand::GetColorInterpretation()
72
73
51.6k
{
74
51.6k
    if (m_poGDS->m_bPromoteTo8Bits)
75
0
        return GCI_Undefined;
76
77
51.6k
    return GCI_PaletteIndex;
78
51.6k
}
79
80
/************************************************************************/
81
/*                       SetColorInterpretation()                       */
82
/************************************************************************/
83
84
CPLErr GTiffBitmapBand::SetColorInterpretation(GDALColorInterp eInterp)
85
0
{
86
0
    if (eInterp != GetColorInterpretation())
87
0
    {
88
0
        CPLDebug(
89
0
            "GTiff",
90
0
            "Setting color interpration on GTiffBitmap band is not supported");
91
0
    }
92
0
    return CE_None;
93
0
}
94
95
/************************************************************************/
96
/*                           GetColorTable()                            */
97
/************************************************************************/
98
99
GDALColorTable *GTiffBitmapBand::GetColorTable()
100
101
44.3k
{
102
44.3k
    if (m_poGDS->m_bPromoteTo8Bits)
103
0
        return nullptr;
104
105
44.3k
    return m_poColorTable;
106
44.3k
}