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
30
31class CPL_DLL GDALColorTable
32{
33 GDALPaletteInterp eInterp;
34
35 std::vector<GDALColorEntry> aoEntries{};
36
37 public:
39
41 GDALColorTable(const GDALColorTable &) = default;
42
45
48
51
53
54 GDALColorTable *Clone() const;
55 int IsSame(const GDALColorTable *poOtherCT) const;
56
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
73 {
74 return static_cast<GDALColorTableH>(poCT);
75 }
76
80 {
81 return static_cast<GDALColorTable *>(hCT);
82 }
83};
84
85#endif
GDALColorTable(GDALPaletteInterp=GPI_RGB)
Construct a new color table.
Definition gdalcolortable.cpp:41
int IsSame(const GDALColorTable *poOtherCT) const
Returns if the current color table is the same as another one.
Definition gdalcolortable.cpp:451
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition gdal_colortable.h:72
const GDALColorEntry * GetColorEntry(int i) const
Fetch a color entry from table.
Definition gdalcolortable.cpp:101
GDALColorTable(const GDALColorTable &)=default
Copy constructor.
static std::unique_ptr< GDALColorTable > LoadFromFile(const char *pszFilename)
Load a color table from a (text) file.
Definition gdalcolortable.cpp:562
GDALPaletteInterp GetPaletteInterpretation() const
Fetch palette interpretation.
Definition gdalcolortable.cpp:323
int GetColorEntryAsRGB(int i, GDALColorEntry *poEntry) const
Fetch a table entry in RGB format.
Definition gdalcolortable.cpp:149
void SetColorEntry(int i, const GDALColorEntry *poEntry)
Set entry in color table.
Definition gdalcolortable.cpp:198
GDALColorTable & operator=(const GDALColorTable &)=default
Copy assignment operator.
bool IsIdentity() const
Returns if the current color table is the identity, that is for each index i, colortable[i]....
Definition gdalcolortable.cpp:470
~GDALColorTable()
Destructor.
GDALColorTable(GDALColorTable &&)=default
Move constructor.
GDALColorTable & operator=(GDALColorTable &&)=default
Move assignment operator.
GDALColorTable * Clone() const
Make a copy of a color table.
Definition gdalcolortable.cpp:249
int CreateColorRamp(int nStartIndex, const GDALColorEntry *psStartColor, int nEndIndex, const GDALColorEntry *psEndColor)
Create color ramp.
Definition gdalcolortable.cpp:364
int GetColorEntryCount() const
Get number of color entries in table.
Definition gdalcolortable.cpp:285
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition gdal_colortable.h:79
Core portability definitions for CPL.
Public (C callable) GDAL entry points.
GDALPaletteInterp
Definition gdal.h:351
@ GPI_RGB
Definition gdal.h:353
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition gdal_fwd.h:54
Color tuple.
Definition gdal.h:2185