LCOV - code coverage report
Current view: top level - apps - gdalalg_raster_rgb_to_palette.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2025-06-19 12:30:01 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "raster rgb-to-palette" subcommand
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef GDALALG_RASTER_RGB_TO_PALETTE_INCLUDED
      14             : #define GDALALG_RASTER_RGB_TO_PALETTE_INCLUDED
      15             : 
      16             : #include "gdalalg_raster_pipeline.h"
      17             : 
      18             : //! @cond Doxygen_Suppress
      19             : 
      20             : /************************************************************************/
      21             : /*                    GDALRasterRGBToPaletteAlgorithm                   */
      22             : /************************************************************************/
      23             : 
      24             : class GDALRasterRGBToPaletteAlgorithm /* non final */
      25             :     : public GDALRasterPipelineNonNativelyStreamingAlgorithm
      26             : {
      27             :   public:
      28             :     static constexpr const char *NAME = "rgb-to-palette";
      29             :     static constexpr const char *DESCRIPTION =
      30             :         "Convert a RGB image into a pseudo-color / paletted image.";
      31             :     static constexpr const char *HELP_URL =
      32             :         "/programs/gdal_raster_rgb_to_palette.html";
      33             : 
      34             :     explicit GDALRasterRGBToPaletteAlgorithm(bool standaloneStep = false);
      35             : 
      36             :   private:
      37             :     bool RunStep(GDALPipelineStepRunContext &ctxt) override;
      38             : 
      39             :     int m_colorCount = 256;
      40             :     std::string m_colorMap{};
      41             : };
      42             : 
      43             : /************************************************************************/
      44             : /*                GDALRasterRGBToPaletteAlgorithmStandalone             */
      45             : /************************************************************************/
      46             : 
      47          42 : class GDALRasterRGBToPaletteAlgorithmStandalone final
      48             :     : public GDALRasterRGBToPaletteAlgorithm
      49             : {
      50             :   public:
      51          21 :     GDALRasterRGBToPaletteAlgorithmStandalone()
      52          21 :         : GDALRasterRGBToPaletteAlgorithm(/* standaloneStep = */ true)
      53             :     {
      54          21 :     }
      55             : 
      56             :     ~GDALRasterRGBToPaletteAlgorithmStandalone() override;
      57             : };
      58             : 
      59             : //! @endcond
      60             : 
      61             : #endif

Generated by: LCOV version 1.14