File indexing completed on 2025-01-26 04:10:29

0001 /*
0002  * SPDX-FileCopyrightText: 2017 Boudewijn Rempt <boud@valdyas.org>
0003  * SPDX-FileCopyrightText: 2020-2021 L. E. Segovia <amy@amyspark.me>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #ifndef GMIC_H
0009 #define GMIC_H
0010 
0011 #include <QString>
0012 
0013 /**
0014  * A sham header to make it easier to handle gmic types without
0015  * needing gmic itself.
0016  */
0017 
0018 enum class OutputMode { InPlace, NewLayers, NewActiveLayers, NewImage, Unspecified = 100 };
0019 
0020 // this enum is also index in LAYER_MODE_STRINGS list
0021 enum class InputLayerMode {
0022     NoInput,
0023     Active,
0024     All,
0025     ActiveAndBelow,
0026     ActiveAndAbove,
0027     AllVisible,
0028     AllInvisible,
0029     AllVisiblesDesc_DEPRECATED, /* Removed since 2.8.2 */
0030     AllInvisiblesDesc_DEPRECATED, /* Removed since 2.8.2 */
0031     AllDesc_DEPRECATED, /* Removed since 2.8.2 */
0032     Unspecified = 100
0033 };
0034 
0035 template<typename T>
0036 struct gmic_image {
0037     unsigned int _width{0}; // Number of image columns (dimension along the X-axis).
0038     unsigned int _height{0}; // Number of image lines (dimension along the Y-axis)
0039     unsigned int _depth{1}; // Number of image slices (dimension along the Z-axis).
0040     unsigned int _spectrum{3}; // Number of image channels (dimension along the C-axis).
0041     bool _is_shared{false}; // Tells if the data buffer is shared by another structure.
0042     T *_data{nullptr}; // Pointer to the first pixel value.
0043     QString name{}; // Layer name
0044 
0045     // Destructor.
0046     ~gmic_image()
0047     {
0048         if (!_is_shared)
0049             delete[] _data;
0050     }
0051 
0052     void assign(unsigned int w, unsigned int h, unsigned int d, unsigned int s)
0053     {
0054         _width = w;
0055         _height = h;
0056         _depth = d;
0057         _spectrum = s;
0058     }
0059 };
0060 
0061 #endif // GMIC_H