Class: Rixmap::Deformer::BaseDeformer

Inherits:
Object
  • Object
show all
Defined in:
src/rixmapdeformation.cxx,
src/rixmapdeformation.cxx

Overview

画像変形処理のベースクラス.

Direct Known Subclasses

AffineDeformer

Instance Method Summary collapse

Constructor Details

#initialize(ipo = nil) (private)

変形処理ベースを初期化します.

Parameters:

  • ipo (Symbol, String, Integer, nil) (defaults to: nil)

    補間処理方法 (Default: nil)



36
37
38
39
40
41
# File 'src/rixmapdeformation.cxx', line 36

static VALUE BaseDeformer_initialize(int argc, VALUE* argv, VALUE self) {
    VALUE argIPO = Qnil;
    rb_scan_args(argc, argv, "01", &argIPO);
    rb_funcall(self, rb_intern("interpolator="), 1, argIPO);
    return self;
}

Instance Method Details

#deform(image, *args) ⇒ Rixmap::Image

変形処理を実行します.

Parameters:

Returns:



99
100
101
# File 'src/rixmapdeformation.cxx', line 99

static VALUE BaseDeformer_deform(int argc, VALUE* argv, VALUE self) {
    rb_raise(rb_eNotImpError, "%s#%s is not implemented", rb_obj_classname(self), rb_id2name(rb_frame_this_func()));
}

#inspectString

オブジェクトとしての文字列表現を返します.

Returns:

  • (String)

    文字列表現



108
109
110
111
112
113
114
115
# File 'src/rixmapdeformation.cxx', line 108

static VALUE BaseDeformer_inspect(VALUE self) {
    Rixmap::DeformerData* _this = rixmap_unwrap<Rixmap::DeformerData>(self);
    return rb_enc_sprintf(
            rb_usascii_encoding(),
            "#<%s:%p ipo=%d>",
            rb_obj_classname(self), reinterpret_cast<void*>(self),
            static_cast<int>(_this->getInterpolation()));
}

#interpolatorInteger

画素補間処理方法を返します.

Returns:

  • (Integer)

    画素補間処理方法.



48
49
50
51
52
53
54
55
56
57
# File 'src/rixmapdeformation.cxx', line 48

static VALUE BaseDeformer_getInterpolator(VALUE self) {
    Rixmap::DeformerData* _this = rixmap_unwrap<Rixmap::DeformerData>(self);
    switch (_this->getInterpolation()) {
    case Rixmap::Interpolation::BICUBIC:
        return INT2FIX(static_cast<int>(_this->getInterpolation()));

    default:
        return Qnil;
    }
}

#interpolator=(argIPO)

This method returns an undefined value.

画素補間処理方法を設定します.

Parameters:

  • ipo (Symbol, String, Integer, nil)

    画素補間処理方法.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'src/rixmapdeformation.cxx', line 65

static VALUE BaseDeformer_setInterpolator(VALUE self, VALUE argIPO) {
    Rixmap::DeformerData* _this = rixmap_unwrap<Rixmap::DeformerData>(self);
    if (NIL_P(argIPO)) {
        _this->setInterpolation(Rixmap::Interpolation::NONE);
    } else if (RB_TYPE_P(argIPO, T_FIXNUM)) {
        Rixmap::Interpolation ipo = static_cast<Rixmap::Interpolation>(FIX2INT(argIPO));
        switch (ipo) {
        case Rixmap::Interpolation::BICUBIC:
            _this->setInterpolation(ipo);
            break;

        default:
            _this->setInterpolation(Rixmap::Interpolation::NONE);
            break;
        }
    } else {
        VALUE strIPO = rb_str_new_cstr("IPO_");
        strIPO = rb_str_concat(strIPO, rb_funcall(rb_String(argIPO), rb_intern("upcase"), 0));
        if (rb_const_defined(mRixmapDeformer, rb_intern_str(strIPO))) {
            VALUE objIPO = rb_const_get(mRixmapDeformer, rb_intern_str(strIPO));
            _this->setInterpolation(static_cast<Rixmap::Interpolation>(NUM2INT(rb_Integer(objIPO))));
        } else {
            _this->setInterpolation(Rixmap::Interpolation::NONE);
        }
    }
    return argIPO;
}