Toshihiro Shimizu 890ddd
#include <string></string>
Shinya Kitaoka 120a6e
#include <limits>    /* std::numeric_limits */</limits>
Toshihiro Shimizu 890ddd
#include <stdexcept> /* std::domain_error(-) */</stdexcept>
Toshihiro Shimizu 890ddd
#include "igs_maxmin_getput.h"
Toshihiro Shimizu 890ddd
#include "igs_maxmin_multithread.h"
Toshihiro Shimizu 890ddd
#include "igs_maxmin.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void igs::maxmin::convert(
Shinya Kitaoka 120a6e
    /* 入出力画像 */
Shinya Kitaoka 120a6e
    const unsigned char *inn, unsigned char *out
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    ,
shun-iwasawa 481b59
    const int height, const int width, const int channels,
shun-iwasawa 481b59
    const int bits
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    /* Pixel毎に効果の強弱 */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const unsigned char *ref /* 求める画像(out)と同じ高、幅、ch数 */
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 */
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    /* Action Geometry */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const double radius /* =1.0	 0...100...DOUBLE_MAX */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const double smooth_outer_range /* =2.0  0...100...DOUBLE_MAX */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const int polygon_number /* =2    2...16...INT_MAX */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const double roll_degree /* =0.0  0...360...DOUBLE_MAX */
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    /* Action Type */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const bool min_sw /* =false */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const bool alpha_rendering_sw /* =true  */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const bool add_blend_sw /* =true  */
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    /* Speed up */
Shinya Kitaoka 120a6e
    ,
Shinya Kitaoka 120a6e
    const int number_of_thread /* =1    1...24...INT_MAX */
shun-iwasawa 481b59
) {
Shinya Kitaoka 120a6e
  if ((igs::image::rgba::siz != channels) &&
Shinya Kitaoka 120a6e
      (igs::image::rgb::siz != channels) && (1 != channels) /* grayscale */
shun-iwasawa 481b59
  ) {
Shinya Kitaoka 120a6e
    throw std::domain_error("Bad channels,Not rgba/rgb/grayscale");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
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
    igs::maxmin::multithread<unsigned char="" char,="" unsigned=""> mthread(</unsigned>
Shinya Kitaoka 120a6e
        inn, out, height, width, channels
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        ref, ref_mode
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        radius, smooth_outer_range, polygon_number, roll_degree, min_sw,
Shinya Kitaoka 120a6e
        alpha_rendering_sw, add_blend_sw, number_of_thread);
Shinya Kitaoka 120a6e
    mthread.run();
Shinya Kitaoka 120a6e
    mthread.clear();
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
    igs::maxmin::multithread<unsigned char="" short,="" unsigned=""> mthread(</unsigned>
Shinya Kitaoka 120a6e
        reinterpret_cast<const *="" short="" unsigned="">(inn),</const>
Shinya Kitaoka 120a6e
        reinterpret_cast<unsigned *="" short="">(out), height, width, channels</unsigned>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        ref, ref_mode
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        radius, smooth_outer_range, polygon_number, roll_degree, min_sw,
Shinya Kitaoka 120a6e
        alpha_rendering_sw, add_blend_sw, number_of_thread);
Shinya Kitaoka 120a6e
    mthread.run();
Shinya Kitaoka 120a6e
    mthread.clear();
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
    igs::maxmin::multithread<unsigned short="" short,="" unsigned=""> mthread(</unsigned>
Shinya Kitaoka 120a6e
        reinterpret_cast<const *="" short="" unsigned="">(inn),</const>
Shinya Kitaoka 120a6e
        reinterpret_cast<unsigned *="" short="">(out), height, width, channels</unsigned>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        reinterpret_cast<const *="" short="" unsigned="">(ref), ref_mode</const>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        radius, smooth_outer_range, polygon_number, roll_degree, min_sw,
Shinya Kitaoka 120a6e
        alpha_rendering_sw, add_blend_sw, number_of_thread);
Shinya Kitaoka 120a6e
    mthread.run();
Shinya Kitaoka 120a6e
    mthread.clear();
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
    igs::maxmin::multithread<unsigned char,="" short="" unsigned=""> mthread(</unsigned>
Shinya Kitaoka 120a6e
        inn, out, height, width, channels
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        reinterpret_cast<const *="" short="" unsigned="">(ref), ref_mode</const>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
        ,
Shinya Kitaoka 120a6e
        radius, smooth_outer_range, polygon_number, roll_degree, min_sw,
Shinya Kitaoka 120a6e
        alpha_rendering_sw, add_blend_sw, number_of_thread);
Shinya Kitaoka 120a6e
    mthread.run();
Shinya Kitaoka 120a6e
    mthread.clear();
shun-iwasawa 481b59
  } else if ((std::numeric_limits<float>::digits == bits) &&</float>
shun-iwasawa 481b59
             ((std::numeric_limits<float>::digits == ref_bits) ||</float>
shun-iwasawa 481b59
              (0 == ref_bits))) {
shun-iwasawa 481b59
    igs::maxmin::multithread<float, float=""> mthread(</float,>
shun-iwasawa 481b59
        reinterpret_cast<const *="" float="">(inn), reinterpret_cast<float *="">(out),</float></const>
shun-iwasawa 481b59
        height, width, channels, reinterpret_cast<const *="" float="">(ref), ref_mode,</const>
shun-iwasawa 481b59
        radius, smooth_outer_range, polygon_number, roll_degree, min_sw,
shun-iwasawa 481b59
        alpha_rendering_sw, add_blend_sw, number_of_thread);
shun-iwasawa 481b59
    mthread.run();
shun-iwasawa 481b59
    mthread.clear();
Shinya Kitaoka 120a6e
  } else {
shun-iwasawa 481b59
    throw std::domain_error("Bad bits,Not uchar/ushort/float");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}