OpenShot Library | libopenshot  0.5.0
ColorMap.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2025 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_COLORMAP_EFFECT_H
14 #define OPENSHOT_COLORMAP_EFFECT_H
15 
16 #include "../EffectBase.h"
17 #include "../Json.h"
18 #include "../KeyFrame.h"
19 #include <QString>
20 #include <QFile>
21 #include <QTextStream>
22 #include <vector>
23 #include <string>
24 #include <array>
25 
26 namespace openshot
27 {
28 
35  class ColorMap : public EffectBase
36  {
37  private:
38  enum class LUTType { None, LUT1D, LUT3D };
39 
40  std::string lut_path;
41  int lut_size;
42  std::vector<float> lut_data;
43  LUTType lut_type;
44  bool needs_refresh;
45  std::array<float, 3> lut_domain_min;
46  std::array<float, 3> lut_domain_max;
47 
49  void init_effect_details();
50 
52  void load_cube_file();
53 
54  public:
59 
61  ColorMap();
62 
72  ColorMap(const std::string &path,
73  const Keyframe &i = Keyframe(1.0),
74  const Keyframe &iR = Keyframe(1.0),
75  const Keyframe &iG = Keyframe(1.0),
76  const Keyframe &iB = Keyframe(1.0));
77 
79  std::shared_ptr<openshot::Frame>
80  GetFrame(int64_t frame_number) override
81  { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
82 
84  std::shared_ptr<openshot::Frame>
85  GetFrame(std::shared_ptr<openshot::Frame> frame,
86  int64_t frame_number) override;
87 
88  // JSON serialization
89  std::string Json() const override;
90  Json::Value JsonValue() const override;
91  void SetJson(const std::string value) override;
92  void SetJsonValue(const Json::Value root) override;
93 
95  std::string PropertiesJSON(int64_t requested_frame) const override;
96  };
97 
98 } // namespace openshot
99 
100 #endif // OPENSHOT_COLORMAP_EFFECT_H
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:53
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::ColorMap::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
Apply effect to a new frame.
Definition: ColorMap.h:80
openshot::ColorMap::ColorMap
ColorMap()
Blank constructor (used by JSON loader)
Definition: ColorMap.cpp:149
openshot::ColorMap::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: ColorMap.cpp:326
openshot::ColorMap::intensity
Keyframe intensity
Overall intensity 0–1 (affects all channels)
Definition: ColorMap.h:55
openshot::ColorMap::intensity_g
Keyframe intensity_g
Blend 0–1 for green channel.
Definition: ColorMap.h:57
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:53
openshot::ColorMap::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: ColorMap.cpp:349
openshot::ColorMap::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: ColorMap.cpp:338
openshot::ColorMap
Applies a 1D or 3D LUT (.cube) color transform to each frame.
Definition: ColorMap.h:35
path
path
Definition: FFmpegWriter.cpp:1469
openshot::ColorMap::Json
std::string Json() const override
Generate JSON string of this object.
Definition: ColorMap.cpp:321
openshot::ColorMap::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Expose properties (for UI)
Definition: ColorMap.cpp:367
openshot::ColorMap::intensity_b
Keyframe intensity_b
Blend 0–1 for blue channel.
Definition: ColorMap.h:58
openshot::ColorMap::intensity_r
Keyframe intensity_r
Blend 0–1 for red channel.
Definition: ColorMap.h:56