LCOV - code coverage report
Current view: top level - gcore - gdal_colortable.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 6 6 100.0 %
Date: 2025-10-01 17:07:58 Functions: 6 6 100.0 %

          Line data    Source code
       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             : 
      29             : /** A color table / palette. */
      30             : 
      31        2160 : class CPL_DLL GDALColorTable
      32             : {
      33             :     GDALPaletteInterp eInterp;
      34             : 
      35             :     std::vector<GDALColorEntry> aoEntries{};
      36             : 
      37             :   public:
      38             :     explicit GDALColorTable(GDALPaletteInterp = GPI_RGB);
      39             : 
      40             :     /** Copy constructor */
      41         287 :     GDALColorTable(const GDALColorTable &) = default;
      42             : 
      43             :     /** Copy assignment operator */
      44             :     GDALColorTable &operator=(const GDALColorTable &) = default;
      45             : 
      46             :     /** Move constructor */
      47             :     GDALColorTable(GDALColorTable &&) = default;
      48             : 
      49             :     /** Move assignment operator */
      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             : 
      70             :     /** Convert a GDALColorTable* to a GDALRasterBandH.
      71             :      * @since GDAL 2.3
      72             :      */
      73        2081 :     static inline GDALColorTableH ToHandle(GDALColorTable *poCT)
      74             :     {
      75        2081 :         return static_cast<GDALColorTableH>(poCT);
      76             :     }
      77             : 
      78             :     /** Convert a GDALColorTableH to a GDALColorTable*.
      79             :      * @since GDAL 2.3
      80             :      */
      81       22126 :     static inline GDALColorTable *FromHandle(GDALColorTableH hCT)
      82             :     {
      83       22126 :         return static_cast<GDALColorTable *>(hCT);
      84             :     }
      85             : };
      86             : 
      87             : #endif

Generated by: LCOV version 1.14