GDAL

gdal_colortable.h
1/******************************************************************************
2 *
3 * Name: gdal_colortable.h
4 * Project: GDAL Core
5 * Purpose: Declaration of GDALColorTable class
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1998, Frank Warmerdam
10 * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef GDALCOLORTABLE_H_INCLUDED
16#define GDALCOLORTABLE_H_INCLUDED
17
18#include "cpl_port.h"
19
20#include "gdal.h"
21
22#include <memory>
23#include <vector>
24
25/* ******************************************************************** */
26/* GDALColorTable */
27/* ******************************************************************** */
28
31 class CPL_DLL GDALColorTable
32{
33 GDALPaletteInterp eInterp;
34
35 std::vector<GDALColorEntry> aoEntries{};
36
37 public:
38 explicit GDALColorTable(GDALPaletteInterp = GPI_RGB);
39
41 GDALColorTable(const GDALColorTable &) = default;
42
44 GDALColorTable &operator=(const GDALColorTable &) = default;
45
47 GDALColorTable(GDALColorTable &&) = default;
48
50 GDALColorTable &operator=(GDALColorTable &&) = default;
51
52 ~GDALColorTable();
53
54 GDALColorTable *Clone() const;
55 int IsSame(const GDALColorTable *poOtherCT) const;
56
57 GDALPaletteInterp GetPaletteInterpretation() const;
58
59 int GetColorEntryCount() const;
60 const GDALColorEntry *GetColorEntry(int i) const;
61 int GetColorEntryAsRGB(int i, GDALColorEntry *poEntry) const;
62 void SetColorEntry(int i, const GDALColorEntry *poEntry);
63 int CreateColorRamp(int nStartIndex, const GDALColorEntry *psStartColor,
64 int nEndIndex, const GDALColorEntry *psEndColor);
65 bool IsIdentity() const;
66
67 static std::unique_ptr<GDALColorTable>
68 LoadFromFile(const char *pszFilename);
69
72 static inline GDALColorTableH ToHandle(GDALColorTable *poCT)
73 {
74 return static_cast<GDALColorTableH>(poCT);
75 }
76
79 static inline GDALColorTable *FromHandle(GDALColorTableH hCT)
80 {
81 return static_cast<GDALColorTable *>(hCT);
82 }
83};
84
85#endif
GDALColorTable
A color table / palette.
Definition gdal_colortable.h:32
GDALColorTable::ToHandle
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition gdal_colortable.h:72
GDALColorTable::GDALColorTable
GDALColorTable(const GDALColorTable &)=default
Copy constructor.
GDALColorTable::operator=
GDALColorTable & operator=(const GDALColorTable &)=default
Copy assignment operator.
GDALColorTable::~GDALColorTable
~GDALColorTable()
Destructor.
GDALColorTable::GDALColorTable
GDALColorTable(GDALColorTable &&)=default
Move constructor.
GDALColorTable::operator=
GDALColorTable & operator=(GDALColorTable &&)=default
Move assignment operator.
GDALColorTable::FromHandle
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition gdal_colortable.h:79
cpl_port.h
Core portability definitions for CPL.
gdal.h
Public (C callable) GDAL entry points.
GDALPaletteInterp
GDALPaletteInterp
Definition gdal.h:353
GPI_RGB
@ GPI_RGB
Definition gdal.h:355
GDALColorTableH
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition gdal_fwd.h:54
GDALColorEntry
Color tuple.
Definition gdal.h:2187