|
Toshihiro Shimizu |
890ddd |
#include <string></string>
|
|
Toshihiro Shimizu |
890ddd |
#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(
|
|
Toshihiro Shimizu |
890ddd |
/* 入出力画像 */
|
|
Toshihiro Shimizu |
890ddd |
const unsigned char *inn, unsigned char *out
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int height, const int width, const int channels, const int bits
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Pixel毎に効果の強弱 */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const unsigned char *ref /* 求める画像(out)と同じ高、幅、ch数 */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int ref_bits /* refがゼロのときはここもゼロ */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int ref_mode /* 0=R,1=G,2=B,3=A,4=Luminance,5=Nothing */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Action Geometry */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const double radius /* =1.0 0...100...DOUBLE_MAX */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const double smooth_outer_range /* =2.0 0...100...DOUBLE_MAX */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int polygon_number /* =2 2...16...INT_MAX */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const double roll_degree /* =0.0 0...360...DOUBLE_MAX */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Action Type */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const bool min_sw /* =false */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const bool alpha_rendering_sw /* =true */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const bool add_blend_sw /* =true */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* Speed up */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
const int number_of_thread /* =1 1...24...INT_MAX */
|
|
Toshihiro Shimizu |
890ddd |
)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if ((igs::image::rgba::siz != channels) &&
|
|
Toshihiro Shimizu |
890ddd |
(igs::image::rgb::siz != channels) &&
|
|
Toshihiro Shimizu |
890ddd |
(1 != channels) /* grayscale */
|
|
Toshihiro Shimizu |
890ddd |
) {
|
|
Toshihiro Shimizu |
890ddd |
throw std::domain_error("Bad channels,Not rgba/rgb/grayscale");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((std::numeric_limits<unsigned char="">::digits == bits) && ((std::numeric_limits<unsigned char="">::digits == ref_bits) || (0 == ref_bits))) {</unsigned></unsigned>
|
|
Toshihiro Shimizu |
890ddd |
igs::maxmin::multithread<
|
|
Toshihiro Shimizu |
890ddd |
unsigned char, unsigned char> mthread(inn, out, height, width, channels
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
ref, ref_mode
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
radius, smooth_outer_range, polygon_number, roll_degree, min_sw, alpha_rendering_sw, add_blend_sw, number_of_thread);
|
|
Toshihiro Shimizu |
890ddd |
mthread.run();
|
|
Toshihiro Shimizu |
890ddd |
mthread.clear();
|
|
Toshihiro Shimizu |
890ddd |
} else if ((std::numeric_limits<unsigned short="">::digits == bits) && ((std::numeric_limits<unsigned char="">::digits == ref_bits) || (0 == ref_bits))) {</unsigned></unsigned>
|
|
Toshihiro Shimizu |
890ddd |
igs::maxmin::multithread<
|
|
Toshihiro Shimizu |
890ddd |
unsigned short, unsigned char>
|
|
Toshihiro Shimizu |
890ddd |
mthread(
|
|
Toshihiro Shimizu |
890ddd |
reinterpret_cast<const *="" short="" unsigned="">(inn), reinterpret_cast<unsigned *="" short="">(out), height, width, channels</unsigned></const>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
ref, ref_mode
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
radius, smooth_outer_range, polygon_number, roll_degree, min_sw, alpha_rendering_sw, add_blend_sw, number_of_thread);
|
|
Toshihiro Shimizu |
890ddd |
mthread.run();
|
|
Toshihiro Shimizu |
890ddd |
mthread.clear();
|
|
Toshihiro Shimizu |
890ddd |
} else if ((std::numeric_limits<unsigned short="">::digits == bits) && (std::numeric_limits<unsigned short="">::digits == ref_bits)) {</unsigned></unsigned>
|
|
Toshihiro Shimizu |
890ddd |
igs::maxmin::multithread<
|
|
Toshihiro Shimizu |
890ddd |
unsigned short, unsigned short>
|
|
Toshihiro Shimizu |
890ddd |
mthread(
|
|
Toshihiro Shimizu |
890ddd |
reinterpret_cast<const *="" short="" unsigned="">(inn), reinterpret_cast<unsigned *="" short="">(out), height, width, channels</unsigned></const>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
reinterpret_cast<const *="" short="" unsigned="">(ref), ref_mode</const>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
radius, smooth_outer_range, polygon_number, roll_degree, min_sw, alpha_rendering_sw, add_blend_sw, number_of_thread);
|
|
Toshihiro Shimizu |
890ddd |
mthread.run();
|
|
Toshihiro Shimizu |
890ddd |
mthread.clear();
|
|
Toshihiro Shimizu |
890ddd |
} else if ((std::numeric_limits<unsigned char="">::digits == bits) && (std::numeric_limits<unsigned short="">::digits == ref_bits)) {</unsigned></unsigned>
|
|
Toshihiro Shimizu |
890ddd |
igs::maxmin::multithread<
|
|
Toshihiro Shimizu |
890ddd |
unsigned char, unsigned short>
|
|
Toshihiro Shimizu |
890ddd |
mthread(
|
|
Toshihiro Shimizu |
890ddd |
inn, out, height, width, channels
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
reinterpret_cast<const *="" short="" unsigned="">(ref), ref_mode</const>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
radius, smooth_outer_range, polygon_number, roll_degree, min_sw, alpha_rendering_sw, add_blend_sw, number_of_thread);
|
|
Toshihiro Shimizu |
890ddd |
mthread.run();
|
|
Toshihiro Shimizu |
890ddd |
mthread.clear();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw std::domain_error("Bad bits,Not uchar/ushort");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|