Toshihiro Shimizu 890ddd
#include <stdexcept> /* std::domain_error  */</stdexcept>
Shinya Kitaoka 120a6e
#include <limits>    /* std::numeric_limits */</limits>
Toshihiro Shimizu 890ddd
#include "igs_color_rgb_hls.h"
Shinya Kitaoka 120a6e
namespace {
Shinya Kitaoka 120a6e
void pixel_rgba_(const double red_in, const double gre_in, const double blu_in,
Shinya Kitaoka 120a6e
                 const double alp_in, const double hue_noise  // -0.5...0.5
Shinya Kitaoka 120a6e
                 ,
Shinya Kitaoka 120a6e
                 const double lig_noise  // -0.5...0.5
Shinya Kitaoka 120a6e
                 ,
Shinya Kitaoka 120a6e
                 const double sat_noise, const double alp_noise,
Shinya Kitaoka 120a6e
                 double &red_out, double &gre_out, double &blu_out,
Shinya Kitaoka 120a6e
                 double &alp_out) {
Shinya Kitaoka 120a6e
  double hue, lig, sat, alp;
Shinya Kitaoka 120a6e
  igs::color::rgb_to_hls(red_in, gre_in, blu_in, hue, lig, sat);
Shinya Kitaoka 120a6e
  alp = alp_in;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (0.0 != hue_noise) {
Shinya Kitaoka 120a6e
    hue += 360.0 * hue_noise;
Shinya Kitaoka 120a6e
    while (hue < 0.0) {
Shinya Kitaoka 120a6e
      hue += 360.0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    while (360.0 <= hue) {
Shinya Kitaoka 120a6e
      hue -= 360.0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (0.0 != lig_noise) {
Shinya Kitaoka 120a6e
    lig += lig_noise;
Shinya Kitaoka 120a6e
    lig = (lig < 0.0) ? 0.0 : ((1.0 < lig) ? 1.0 : lig);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (0.0 != sat_noise) {
Shinya Kitaoka 120a6e
    sat += sat_noise;
Shinya Kitaoka 120a6e
    sat = (sat < 0.0) ? 0.0 : ((1.0 < sat) ? 1.0 : sat);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (0.0 != alp_noise) {
Shinya Kitaoka 120a6e
    alp += alp_noise;
Shinya Kitaoka 120a6e
    alp = (alp < 0.0) ? 0.0 : ((1.0 < alp) ? 1.0 : alp);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  igs::color::hls_to_rgb(hue, lig, sat, red_out, gre_out, blu_out);
Shinya Kitaoka 120a6e
  alp_out = alp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka 120a6e
namespace {
Shinya Kitaoka 120a6e
class noise_ref_ {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  noise_ref_(const unsigned char *array, const int height, const int width,
Shinya Kitaoka 120a6e
             const int channels, const int bits, const int xoffset,
Shinya Kitaoka 120a6e
             const int yoffset, const int zz);
Shinya Kitaoka 120a6e
  double noise(int xx  // 0...width-1...
Shinya Kitaoka 120a6e
               ,
Shinya Kitaoka 120a6e
               int yy    // 0...height-1...
Shinya Kitaoka 120a6e
               ) const;  // return range is 0...1
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  const unsigned char *array_;
Shinya Kitaoka 120a6e
  const int height_;
Shinya Kitaoka 120a6e
  const int width_;
Shinya Kitaoka 120a6e
  const int channels_;
Shinya Kitaoka 120a6e
  const int bits_;
Shinya Kitaoka 120a6e
  const double bmax_;
Shinya Kitaoka 120a6e
  const int xoffset_;
Shinya Kitaoka 120a6e
  const int yoffset_;
Shinya Kitaoka 120a6e
  const int zz_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* copy constructorを無効化 */
Shinya Kitaoka 120a6e
  noise_ref_(const noise_ref_ &);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* 代入演算子を無効化 */
Shinya Kitaoka 120a6e
  noise_ref_ &operator=(const noise_ref_ &);
Toshihiro Shimizu 890ddd
};
Shinya Kitaoka 120a6e
noise_ref_::noise_ref_(const unsigned char *array, const int height,
Shinya Kitaoka 120a6e
                       const int width, const int channels, const int bits,
Shinya Kitaoka 120a6e
                       const int xoffset, const int yoffset, const int zz)
Shinya Kitaoka 120a6e
    : array_(array)
Shinya Kitaoka 120a6e
    , height_(height)
Shinya Kitaoka 120a6e
    , width_(width)
Shinya Kitaoka 120a6e
    , channels_(channels)
Shinya Kitaoka 120a6e
    , bits_(bits)
Shinya Kitaoka 120a6e
    , bmax_(static_cast<double>((1 << bits) - 1))</double>
Shinya Kitaoka 120a6e
    , xoffset_(xoffset)
Shinya Kitaoka 120a6e
    , yoffset_(yoffset)
Shinya Kitaoka 120a6e
    , zz_(zz) {
Shinya Kitaoka 120a6e
  if (0 == array) {
Shinya Kitaoka 120a6e
    throw std::domain_error("noise_ref_  no data");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if ((zz < 0) || (channels <= zz)) {
Shinya Kitaoka 120a6e
    throw std::domain_error("noise_ref_  bad zz");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if ((std::numeric_limits<unsigned char="">::digits != this->bits_) &&</unsigned>
Shinya Kitaoka 120a6e
      (std::numeric_limits<unsigned short="">::digits != this->bits_)) {</unsigned>
Shinya Kitaoka 120a6e
    throw std::domain_error("noise_ref_  bad bits");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Shinya Kitaoka 120a6e
double noise_ref_::noise(int xx, int yy) const {
Shinya Kitaoka 120a6e
  xx -= this->xoffset_;
Shinya Kitaoka 120a6e
  yy -= this->yoffset_;
Shinya Kitaoka 120a6e
  while (xx < 0) {
Shinya Kitaoka 120a6e
    xx += this->width_;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  while (this->width_ <= xx) {
Shinya Kitaoka 120a6e
    xx -= this->width_;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  while (yy < 0) {
Shinya Kitaoka 120a6e
    yy += this->height_;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  while (this->height_ <= yy) {
Shinya Kitaoka 120a6e
    yy -= this->height_;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (std::numeric_limits<unsigned char="">::digits == this->bits_) {</unsigned>
Shinya Kitaoka 120a6e
    return (*(this->array_ + this->channels_ * this->width_ * yy +
Shinya Kitaoka 120a6e
              this->channels_ * xx + this->zz_)) /
Shinya Kitaoka 120a6e
           this->bmax_;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return (*(reinterpret_cast<const *="" short="" unsigned="">(this->array_) +</const>
Shinya Kitaoka 120a6e
            this->channels_ * this->width_ * yy + this->channels_ * xx +
Shinya Kitaoka 120a6e
            this->zz_)) /
Shinya Kitaoka 120a6e
         this->bmax_;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Toshihiro Shimizu 890ddd
#include "igs_ifx_common.h" /* igs::image::rgba */
Toshihiro Shimizu 890ddd
#include "igs_hls_add.h"
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
/* raster画像にノイズをのせるtemplate */
Toshihiro Shimizu 890ddd
template <class class="" it,="" rt=""></class>
Toshihiro Shimizu 890ddd
void change_template_(
Shinya Kitaoka 120a6e
    IT *image_array, const int height, const int width, const int channels
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const noise_ref_ &noi
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const RT *ref /* 求める画像(out)と同じ高さ、幅、チャンネル数 */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const int ref_mode /* 0=R,1=G,2=B,3=A,4=Luminance,5=Nothing */
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const double offset, const double hue_scale, const double lig_scale,
Shinya Kitaoka 120a6e
    const double sat_scale, const double alp_scale
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const bool add_blend_sw) {
Shinya Kitaoka 120a6e
  const int t_max      = std::numeric_limits<it>::max();</it>
Shinya Kitaoka 120a6e
  const double div_val = static_cast<double>(t_max);</double>
Shinya Kitaoka 120a6e
  const double mul_val = static_cast<double>(t_max) + 0.999999;</double>
Shinya Kitaoka 120a6e
  const int r_max      = std::numeric_limits<rt>::max();</rt>
Shinya Kitaoka 120a6e
  if (igs::image::rgba::siz == channels) {
Shinya Kitaoka 120a6e
    using namespace igs::image::rgba;
Shinya Kitaoka 120a6e
    for (int yy = 0; yy < height; ++yy) {
Shinya Kitaoka 120a6e
      for (int xx = 0; xx < width; ++xx, image_array += channels) {
Shinya Kitaoka 120a6e
        /* 変化量初期値 */
Shinya Kitaoka 120a6e
        double refv = 1.0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 参照画像あればピクセル単位の画像変化量を得る */
Shinya Kitaoka 120a6e
        if (ref != 0) {
Shinya Kitaoka 120a6e
          refv *= igs::color::ref_value(ref, channels, r_max, ref_mode);
Shinya Kitaoka 120a6e
          ref += channels; /* continue;の前に行うこと */
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 加算合成で、Alpha値ゼロならRGB値を計算する必要はない */
Shinya Kitaoka 120a6e
        if (add_blend_sw && (0 == image_array[alp])) {
Shinya Kitaoka 120a6e
          continue;
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
        /* 加算合成でなくAlpha合成の時は、
Shinya Kitaoka 120a6e
Alpha値がゼロでもRGB値は存在する(してもよい) */
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* HLSAそれぞれに対するオフセット済ノイズ値 */
Shinya Kitaoka 120a6e
        refv *= (noi.noise(xx, yy) - offset);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* マスクSWがON、なら変化をMask */
Shinya Kitaoka 120a6e
        if (add_blend_sw && (image_array[alp] < t_max)) {
Shinya Kitaoka 120a6e
          refv *= static_cast<double>(image_array[alp]) / div_val;</double>
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* RGBAにHLSAノイズを加える */
Shinya Kitaoka 120a6e
        double rr, gg, bb, aa;
Shinya Kitaoka 120a6e
        pixel_rgba_(static_cast<double>(image_array[red]) / div_val,</double>
Shinya Kitaoka 120a6e
                    static_cast<double>(image_array[gre]) / div_val,</double>
Shinya Kitaoka 120a6e
                    static_cast<double>(image_array[blu]) / div_val,</double>
Shinya Kitaoka 120a6e
                    static_cast<double>(image_array[alp]) / div_val,</double>
Shinya Kitaoka 120a6e
                    refv * hue_scale, refv * lig_scale, refv * sat_scale,
Shinya Kitaoka 120a6e
                    refv * alp_scale, rr, gg, bb, aa);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 変化後の値を戻す */
Shinya Kitaoka 120a6e
        image_array[red] = static_cast<it>(rr * mul_val);</it>
Shinya Kitaoka 120a6e
        image_array[gre] = static_cast<it>(gg * mul_val);</it>
Shinya Kitaoka 120a6e
        image_array[blu] = static_cast<it>(bb * mul_val);</it>
Shinya Kitaoka 120a6e
        image_array[alp] = static_cast<it>(aa * mul_val);</it>
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  } else if (igs::image::rgb::siz == channels) {
Shinya Kitaoka 120a6e
    using namespace igs::image::rgb;
Shinya Kitaoka 120a6e
    for (int yy = 0; yy < height; ++yy) {
Shinya Kitaoka 120a6e
      for (int xx = 0; xx < width; ++xx, image_array += channels) {
Shinya Kitaoka 120a6e
        /* 変化量初期値 */
Shinya Kitaoka 120a6e
        double refv = 1.0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 参照画像あればピクセル単位の画像変化量を得る */
Shinya Kitaoka 120a6e
        if (ref != 0) {
Shinya Kitaoka 120a6e
          refv *= igs::color::ref_value(ref, channels, r_max, ref_mode);
Shinya Kitaoka 120a6e
          ref += channels; /* continue;の前に行うこと */
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* HLSそれぞれに対するオフセット済ノイズ値 */
Shinya Kitaoka 120a6e
        refv *= (noi.noise(xx, yy) - offset);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* RGBにHLSノイズを加える */
Shinya Kitaoka 120a6e
        double rr, gg, bb, aa;
Shinya Kitaoka 120a6e
        pixel_rgba_(static_cast<double>(image_array[red]) / div_val,</double>
Shinya Kitaoka 120a6e
                    static_cast<double>(image_array[gre]) / div_val,</double>
Shinya Kitaoka 120a6e
                    static_cast<double>(image_array[blu]) / div_val, 1.0,</double>
Shinya Kitaoka 120a6e
                    refv * hue_scale, refv * lig_scale, refv * sat_scale, 0.0,
Shinya Kitaoka 120a6e
                    rr, gg, bb, aa);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 変化後の値を戻す */
Shinya Kitaoka 120a6e
        image_array[red] = static_cast<it>(rr * mul_val);</it>
Shinya Kitaoka 120a6e
        image_array[gre] = static_cast<it>(gg * mul_val);</it>
Shinya Kitaoka 120a6e
        image_array[blu] = static_cast<it>(bb * mul_val);</it>
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  } else if (1 == channels) { /* grayscale */
Shinya Kitaoka 120a6e
    for (int yy = 0; yy < height; ++yy) {
Shinya Kitaoka 120a6e
      for (int xx = 0; xx < width; ++xx, ++image_array) {
Shinya Kitaoka 120a6e
        /* 変化量初期値 */
Shinya Kitaoka 120a6e
        double refv = 1.0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 参照画像あればピクセル単位の画像変化量を得る */
Shinya Kitaoka 120a6e
        if (ref != 0) {
Shinya Kitaoka 120a6e
          refv *= igs::color::ref_value(ref, channels, r_max, ref_mode);
Shinya Kitaoka 120a6e
          ref += channels; /* continue;の前に行うこと */
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* Lに対するオフセット済ノイズ値 */
Shinya Kitaoka 120a6e
        refv *= (noi.noise(xx, yy) - offset);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 変化なしなら次へ */
Shinya Kitaoka 120a6e
        if (0.0 == refv * lig_scale) {
Shinya Kitaoka 120a6e
          continue;
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* GrayscaleにLノイズを加える */
Shinya Kitaoka 120a6e
        double lig =
Shinya Kitaoka 120a6e
            static_cast<double>(image_array[0]) / div_val + refv * lig_scale;</double>
Shinya Kitaoka 120a6e
        lig = (lig < 0.0) ? 0.0 : ((1.0 < lig) ? 1.0 : lig);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        /* 変化後の値を戻す */
Shinya Kitaoka 120a6e
        image_array[0] = static_cast<it>(lig * mul_val);</it>
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void igs::hls_add::change(
Shinya Kitaoka 120a6e
    unsigned char *image_array, const int height, const int width,
Shinya Kitaoka 120a6e
    const int channels, const int bits
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const unsigned char *noi_image_array, const int noi_height,
Shinya Kitaoka 120a6e
    const int noi_width, const int noi_channels, const int noi_bits
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const unsigned char *ref /* 求める画像と同じ高、幅、channels数 */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const int ref_bits /* refがゼロのときはここもゼロ */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const int ref_mode /* 0=R,1=G,2=B,3=A,4=Luminance,5=Nothing */
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const int xoffset, const int yoffset, const int from_rgba,
Shinya Kitaoka 120a6e
    const double offset, const double hue_scale, const double lig_scale,
Shinya Kitaoka 120a6e
    const double sat_scale, const double alp_scale
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const bool add_blend_sw) {
Shinya Kitaoka 120a6e
  if ((0.0 == hue_scale) && (0.0 == lig_scale) && (0.0 == sat_scale) &&
Shinya Kitaoka 120a6e
      (0.0 == alp_scale)) {
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if ((igs::image::rgba::siz != channels) &&
Shinya Kitaoka 120a6e
      (igs::image::rgb::siz != channels) && (1 != channels) /* grayscale */
Shinya Kitaoka 120a6e
      ) {
Shinya Kitaoka 120a6e
    throw std::domain_error("Bad channels,Not rgba/rgb/grayscale");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* ノイズ参照画像を作成する */
Shinya Kitaoka 120a6e
  noise_ref_ noi(noi_image_array
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
                 ,
Shinya Kitaoka 120a6e
                 noi_height, noi_width, noi_channels, noi_bits
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
                 ,
Shinya Kitaoka 120a6e
                 xoffset, yoffset, from_rgba);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* rgb(a)画像にhls(a)でドットノイズを加える */
Shinya Kitaoka 120a6e
  if ((std::numeric_limits<unsigned char="">::digits == bits) &&</unsigned>
Shinya Kitaoka 120a6e
      ((std::numeric_limits<unsigned char="">::digits == ref_bits) ||</unsigned>
Shinya Kitaoka 120a6e
       (0 == ref_bits))) {
Shinya Kitaoka 120a6e
    change_template_(image_array, height, width, channels, noi, ref, ref_mode,
Shinya Kitaoka 120a6e
                     offset, hue_scale, lig_scale, sat_scale, alp_scale,
Shinya Kitaoka 120a6e
                     add_blend_sw);
Shinya Kitaoka 120a6e
  } else if ((std::numeric_limits<unsigned short="">::digits == bits) &&</unsigned>
Shinya Kitaoka 120a6e
             ((std::numeric_limits<unsigned char="">::digits == ref_bits) ||</unsigned>
Shinya Kitaoka 120a6e
              (0 == ref_bits))) {
Shinya Kitaoka 120a6e
    change_template_(reinterpret_cast<unsigned *="" short="">(image_array), height,</unsigned>
Shinya Kitaoka 120a6e
                     width, channels, noi, ref, ref_mode, offset, hue_scale,
Shinya Kitaoka 120a6e
                     lig_scale, sat_scale, alp_scale, add_blend_sw);
Shinya Kitaoka 120a6e
  } else if ((std::numeric_limits<unsigned short="">::digits == bits) &&</unsigned>
Shinya Kitaoka 120a6e
             (std::numeric_limits<unsigned short="">::digits == ref_bits)) {</unsigned>
Shinya Kitaoka 120a6e
    change_template_(
Shinya Kitaoka 120a6e
        reinterpret_cast<unsigned *="" short="">(image_array), height, width,</unsigned>
Shinya Kitaoka 120a6e
        channels, noi, reinterpret_cast<const *="" short="" unsigned="">(ref), ref_mode,</const>
Shinya Kitaoka 120a6e
        offset, hue_scale, lig_scale, sat_scale, alp_scale, add_blend_sw);
Shinya Kitaoka 120a6e
  } else if ((std::numeric_limits<unsigned char="">::digits == bits) &&</unsigned>
Shinya Kitaoka 120a6e
             (std::numeric_limits<unsigned short="">::digits == ref_bits)) {</unsigned>
Shinya Kitaoka 120a6e
    change_template_(image_array, height, width, channels, noi,
Shinya Kitaoka 120a6e
                     reinterpret_cast<const *="" short="" unsigned="">(ref), ref_mode,</const>
Shinya Kitaoka 120a6e
                     offset, hue_scale, lig_scale, sat_scale, alp_scale,
Shinya Kitaoka 120a6e
                     add_blend_sw);
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    throw std::domain_error("Bad bits,Not uchar/ushort");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}