shun-iwasawa 021eef
#pragma once
shun-iwasawa 021eef
shun-iwasawa 021eef
/*------------
shun-iwasawa 021eef
 Iwa_BloomFx
shun-iwasawa 021eef
 Based on the LightBloom plugin fx by Dwango, with modifications as follows:
shun-iwasawa 021eef
 - parameters are reduced & simplified to gamma, gain and size
shun-iwasawa 021eef
 - reduced the block noise appeared especially when the gamma is with higher
shun-iwasawa 021eef
value
shun-iwasawa 021eef
 - enabled to render alpha gradation
shun-iwasawa 021eef
 - enabled to adjust size with the viewer gadget
shun-iwasawa 021eef
--------------*/
shun-iwasawa 021eef
shun-iwasawa 021eef
#ifndef IWA_BLOOMFX_H
shun-iwasawa 021eef
#define IWA_BLOOMFX_H
shun-iwasawa 021eef
shun-iwasawa 021eef
#include "stdfx.h"
shun-iwasawa 021eef
#include "tfxparam.h"
shun-iwasawa 021eef
#include <opencv2 opencv.hpp=""></opencv2>
shun-iwasawa 021eef
shun-iwasawa 021eef
class Iwa_BloomFx : public TStandardRasterFx {
shun-iwasawa 021eef
  FX_PLUGIN_DECLARATION(Iwa_BloomFx)
shun-iwasawa d76928
shun-iwasawa d76928
  enum AlphaMode { NoAlpha = 0, Light, LightAndSource };
shun-iwasawa d76928
shun-iwasawa 021eef
protected:
shun-iwasawa 021eef
  TRasterFxPort m_source;
shun-iwasawa 021eef
  TDoubleParamP m_gamma;
shun-iwasawa 481b59
  TDoubleParamP m_gammaAdjust;  // Gamma offset from the current color space
shun-iwasawa 481b59
                                // gamma (Version 3)
shun-iwasawa d76928
  TBoolParamP m_auto_gain;
shun-iwasawa d76928
  TDoubleParamP m_gain_adjust;
shun-iwasawa 021eef
  TDoubleParamP m_gain;
shun-iwasawa d76928
  TDoubleParamP m_decay;
shun-iwasawa 021eef
  TDoubleParamP m_size;
shun-iwasawa d76928
shun-iwasawa d76928
  TIntEnumParamP m_alpha_mode;    // no alpha / light / light and source
shun-iwasawa d76928
  TBoolParamP m_alpha_rendering;  // obsolete
shun-iwasawa 021eef
shun-iwasawa 021eef
  double getSizePixelAmount(const double val, const TAffine affine);
shun-iwasawa 021eef
  template <typename pixel="" raster,="" typename=""></typename>
shun-iwasawa d76928
  void setSourceTileToMat(const RASTER ras, cv::Mat &imgMat,
shun-iwasawa 021eef
                          const double gamma);
shun-iwasawa 021eef
shun-iwasawa 021eef
  template <typename pixel="" raster,="" typename=""></typename>
shun-iwasawa d76928
  void setMatToOutput(const RASTER ras, const RASTER srcRas, cv::Mat &imgMat,
shun-iwasawa 021eef
                      const double gamma, const double gain,
shun-iwasawa d76928
                      const AlphaMode alphaMode, const int margin);
shun-iwasawa d76928
shun-iwasawa d76928
  double computeAutoGain(cv::Mat &imgMat);
shun-iwasawa 021eef
shun-iwasawa 021eef
public:
shun-iwasawa 021eef
  Iwa_BloomFx();
shun-iwasawa 021eef
  void doCompute(TTile &tile, double frame,
shun-iwasawa 021eef
                 const TRenderSettings &settings) override;
shun-iwasawa 021eef
  bool doGetBBox(double frame, TRectD &bBox,
shun-iwasawa 021eef
                 const TRenderSettings &info) override;
shun-iwasawa 021eef
  bool canHandle(const TRenderSettings &info, double frame) override;
shun-iwasawa 021eef
  void getParamUIs(TParamUIConcept *&concepts, int &length) override;
shun-iwasawa d76928
  void onObsoleteParamLoaded(const std::string ¶mName) override;
shun-iwasawa 481b59
  void onFxVersionSet() override;
shun-iwasawa 481b59
  bool toBeComputedInLinearColorSpace(bool settingsIsLinear,
shun-iwasawa 481b59
                                      bool tileIsLinear) const override;
shun-iwasawa 021eef
};
shun-iwasawa 021eef
shun-iwasawa 021eef
#endif