Coverage Report

Created: 2025-11-16 06:25

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
0
    : GTiffOddBitsBand(poDSIn, nBandIn)
25
26
0
{
27
0
    eDataType = GDT_Byte;
28
29
0
    if (poDSIn->m_poColorTable != nullptr)
30
0
    {
31
0
        m_poColorTable = poDSIn->m_poColorTable->Clone();
32
0
    }
33
0
    else
34
0
    {
35
#ifdef ESRI_BUILD
36
        m_poColorTable = nullptr;
37
#else
38
0
        const GDALColorEntry oWhite = {255, 255, 255, 255};
39
0
        const GDALColorEntry oBlack = {0, 0, 0, 255};
40
41
0
        m_poColorTable = new GDALColorTable();
42
43
0
        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
0
        else
49
0
        {
50
0
            m_poColorTable->SetColorEntry(0, &oBlack);
51
0
            m_poColorTable->SetColorEntry(1, &oWhite);
52
0
        }
53
0
#endif  // not defined ESRI_BUILD.
54
0
    }
55
0
}
56
57
/************************************************************************/
58
/*                          ~GTiffBitmapBand()                          */
59
/************************************************************************/
60
61
GTiffBitmapBand::~GTiffBitmapBand()
62
63
0
{
64
0
    delete m_poColorTable;
65
0
}
66
67
/************************************************************************/
68
/*                       GetColorInterpretation()                       */
69
/************************************************************************/
70
71
GDALColorInterp GTiffBitmapBand::GetColorInterpretation()
72
73
0
{
74
0
    if (m_poGDS->m_bPromoteTo8Bits)
75
0
        return GCI_Undefined;
76
77
0
    return GCI_PaletteIndex;
78
0
}
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
0
{
102
0
    if (m_poGDS->m_bPromoteTo8Bits)
103
0
        return nullptr;
104
105
0
    return m_poColorTable;
106
0
}