rixmap 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/src/rixmapcore.cxx CHANGED
@@ -3,102 +3,8 @@
3
3
  * Rixmapコア実装.
4
4
  */
5
5
  #include "rixmapcore.hxx"
6
- #include "rixmap/helper.hxx"
7
-
8
- //----------------------------------------------------------------------------//
9
- // オブジェクトプール実装
10
- //----------------------------------------------------------------------------//
11
- /**
12
- * 画像形式オブジェクトプール
13
- */
14
- class RixmapModePool {/*{{{*/
15
- private: // 非公開クラスメンバ
16
- static std::map<Rixmap::Mode, VALUE> _pool;
17
-
18
- public: // 公開クラスメンバ
19
- /**
20
- * オブジェクトプールから取得します.
21
- */
22
- static inline VALUE Get(Rixmap::Mode mode) {
23
- auto found = _pool.find(mode);
24
- if (found != _pool.end()) {
25
- return found->second;
26
- } else {
27
- volatile VALUE instance = rb_obj_alloc(cRixmapMode);
28
- Rixmap::ModeData* data = rixmap_unwrap<Rixmap::ModeData>(instance);
29
- data->setMode(mode);
30
-
31
- rb_gc_register_mark_object(instance);
32
- _pool[mode] = instance;
33
-
34
- return instance;
35
- }
36
- }
37
-
38
- /**
39
- * オブジェクトプールからオブジェクトを削除します.
40
- */
41
- static inline void Remove(Rixmap::Mode mode) {
42
- auto found = _pool.find(mode);
43
- if (found != _pool.end()) {
44
- _pool.erase(found);
45
- }
46
- }
47
-
48
- private: // 非公開コンストラクタ
49
- RixmapModePool() {}
50
-
51
- public: // 仮想デストラクタ
52
- virtual ~RixmapModePool() = 0;
53
- };/*}}}*/
54
-
55
- /**
56
- * カラーオブジェクトプール
57
- */
58
- class RixmapColorPool {/*{{{*/
59
- private: // 非公開クラスメンバ
60
- static std::map<uint32_t, VALUE> _pool;
61
-
62
- public: // 公開クラスメンバ
63
- /**
64
- * オブジェクトプールから取得します.
65
- */
66
- static inline VALUE Get(const Rixmap::Color& color) {
67
- uint32_t value = color.getValue();
68
- auto found = _pool.find(value);
69
- if (found != _pool.end()) {
70
- return found->second;
71
- } else {
72
- volatile VALUE instance = rb_obj_alloc(cRixmapColor);
73
- Rixmap::ColorData* data = rixmap_unwrap<Rixmap::ColorData>(instance);
74
- *data = color;
75
- rb_gc_register_mark_object(instance);
76
- _pool[value] = instance;
77
- return instance;
78
- }
79
- }
80
-
81
- /**
82
- * オブジェクトプールから削除します.
83
- */
84
- static inline void Remove(const Rixmap::Color& color) {
85
- uint32_t value = color.getValue();
86
- auto found = _pool.find(value);
87
- if (found != _pool.end()) {
88
- _pool.erase(found);
89
- }
90
- }
91
-
92
- private: // 非公開コンストラクタ
93
- RixmapColorPool() {}
94
-
95
- public: // 仮想デストラクタ
96
- virtual ~RixmapColorPool() = 0;
97
- };/*}}}*/
98
-
99
- // プール実体定義
100
- std::map<Rixmap::Mode, VALUE> RixmapModePool::_pool;
101
- std::map<uint32_t, VALUE> RixmapColorPool::_pool;
6
+ #include "rixmappool.hxx"
7
+ #include "rixmaphelper.hxx"
102
8
 
103
9
  //----------------------------------------------------------------------------//
104
10
  // オブジェクト実体定義
@@ -1559,87 +1465,6 @@ static VALUE Palette_operatorEquals(VALUE self, VALUE argObject) {
1559
1465
  }
1560
1466
  }
1561
1467
 
1562
- /**
1563
- * パレットをバイト列へと変換します.
1564
- *
1565
- * @overload to_s(layout='RGBA')
1566
- * パレットをバイト列に変換します.
1567
- * レイアウトが指定されている場合は、色ごとに各要素をレイアウトに沿うように配置します.
1568
- * @param [String,Symbol,Array] layout バイト列の並び順. 使用可能な文字は 'R', 'G', 'B', 'A', 'L' です.
1569
- * レイアウトに含まれないチャンネルはバイト列に含まれなくなるため、
1570
- * 単色バイト列も作成できます.
1571
- * @example
1572
- * palette = Rixmap::Palette.new(256)
1573
- * palette.to_s
1574
- * #=> 1024バイト (RGBA×256) のバイト列データ
1575
- * palette.to_s('RGB')
1576
- * #=> 768バイト (RGB×256) データ
1577
- * palette.to_s(:R)
1578
- * #=> 赤要素のみの256バイトデータ
1579
- */
1580
- static VALUE Palette_toString(int argc, VALUE* argv, VALUE self) {
1581
- // 引数解析
1582
- VALUE argLayout = Qnil;
1583
- rb_scan_args(argc, argv, "01", &argLayout);
1584
-
1585
- // 対象チャンネルリスト
1586
- Rixmap::ChannelArray channels;
1587
- if (!NIL_P(argLayout)) {
1588
- if (RB_TYPE_P(argLayout, T_ARRAY)) {
1589
- long arylen = RARRAY_LEN(argLayout);
1590
- for (long i = 0; i < arylen; i++) {
1591
- VALUE item = rb_String(rb_ary_entry(argLayout, i));
1592
- item = rb_funcall(item, rb_intern("upcase"), 0);
1593
- long len = RSTRING_LEN(item);
1594
- char* ptr = StringValuePtr(item);
1595
- if (len > 0) {
1596
- // 先頭文字のみ見る
1597
- channels.push_back(static_cast<Rixmap::Channel>(ptr[0]));
1598
- }
1599
- }
1600
- } else {
1601
- VALUE objLayout = rb_funcall(rb_String(argLayout), rb_intern("upcase"), 0);
1602
- long len = RSTRING_LEN(objLayout);
1603
- char* ptr = StringValuePtr(objLayout);
1604
- for (long i = 0; i < len; i++) {
1605
- channels.push_back(static_cast<Rixmap::Channel>(ptr[i]));
1606
- }
1607
- }
1608
- }
1609
- if (channels.empty()) {
1610
- channels.push_back(Rixmap::Channel::RED);
1611
- channels.push_back(Rixmap::Channel::GREEN);
1612
- channels.push_back(Rixmap::Channel::BLUE);
1613
- channels.push_back(Rixmap::Channel::ALPHA);
1614
- }
1615
-
1616
- // バイト列へ
1617
- Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self);
1618
- Rixmap::CharBuffer bytes;
1619
- const Rixmap::ColorArray& colors = _this->getColors();
1620
- for (auto colit = colors.begin(); colit != colors.end(); colit++) {
1621
- const Rixmap::Color& color = *colit;
1622
- for (auto chit = channels.begin(); chit != channels.end(); chit++) {
1623
- Rixmap::Channel ch = *chit;
1624
- switch (ch) {
1625
- case Rixmap::Channel::RED:
1626
- case Rixmap::Channel::GREEN:
1627
- case Rixmap::Channel::BLUE:
1628
- case Rixmap::Channel::ALPHA:
1629
- case Rixmap::Channel::LUMINANCE:
1630
- bytes.push_back(color[*chit]);
1631
- break;
1632
- default:
1633
- // DO NOTHING
1634
- // TODO 存在しないチャンネルだった場合にスキップするか0x00で埋めるかのフラグを作るべきだろか
1635
- break;
1636
- }
1637
- }
1638
- }
1639
-
1640
- return rb_enc_str_new(bytes.data(), bytes.size(), rb_ascii8bit_encoding());
1641
- }
1642
-
1643
1468
  /**
1644
1469
  * パレットをカラーオブジェクト配列に変換します.
1645
1470
  *
@@ -1722,6 +1547,168 @@ static VALUE Palette_map(VALUE self) {
1722
1547
  return rb_funcall_passing_block(pal, rb_intern("map!"), 0, NULL);
1723
1548
  }
1724
1549
 
1550
+ /**
1551
+ * パレットをバイト列へと変換します.
1552
+ *
1553
+ * @overload export(layout='RGBA')
1554
+ * パレットをバイト列に変換します.
1555
+ * レイアウトが指定されている場合は、色ごとに各要素をレイアウトに沿うように配置します.
1556
+ * @param [String,Symbol,Array] layout バイト列の並び順. 使用可能な文字は 'R', 'G', 'B', 'A', 'L' です.
1557
+ * レイアウトに含まれないチャンネルはバイト列に含まれなくなるため、
1558
+ * 単色バイト列も作成できます.
1559
+ * @example
1560
+ * palette = Rixmap::Palette.new(256)
1561
+ * palette.dump
1562
+ * #=> 1024バイト (RGBA×256) のバイト列データ
1563
+ * palette.dump('RGB')
1564
+ * #=> 768バイト (RGB×256) データ
1565
+ * palette.dump(:R)
1566
+ * #=> 赤要素のみの256バイトデータ
1567
+ */
1568
+ static VALUE Palette_export(int argc, VALUE* argv, VALUE self) {
1569
+ // 引数解析
1570
+ VALUE argLayout = Qnil;
1571
+ rb_scan_args(argc, argv, "01", &argLayout);
1572
+
1573
+ // 対象チャンネルリスト
1574
+ Rixmap::ChannelArray channels;
1575
+ if (!Rixmap::Helper::LayoutChannels(argLayout, channels)) {
1576
+ channels.push_back(Rixmap::Channel::RED);
1577
+ channels.push_back(Rixmap::Channel::GREEN);
1578
+ channels.push_back(Rixmap::Channel::BLUE);
1579
+ channels.push_back(Rixmap::Channel::ALPHA);
1580
+ }
1581
+
1582
+ // バイト列へ
1583
+ Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self);
1584
+ Rixmap::CharBuffer bytes;
1585
+ const Rixmap::ColorArray& colors = _this->getColors();
1586
+ for (auto colit = colors.begin(); colit != colors.end(); colit++) {
1587
+ const Rixmap::Color& color = *colit;
1588
+ for (auto chit = channels.begin(); chit != channels.end(); chit++) {
1589
+ Rixmap::Channel ch = *chit;
1590
+ switch (ch) {
1591
+ case Rixmap::Channel::RED:
1592
+ case Rixmap::Channel::GREEN:
1593
+ case Rixmap::Channel::BLUE:
1594
+ case Rixmap::Channel::ALPHA:
1595
+ case Rixmap::Channel::LUMINANCE:
1596
+ bytes.push_back(color[*chit]);
1597
+ break;
1598
+ default:
1599
+ // DO NOTHING
1600
+ // TODO 存在しないチャンネルだった場合にスキップするか0x00で埋めるかのフラグを作るべきだろか
1601
+ break;
1602
+ }
1603
+ }
1604
+ }
1605
+
1606
+ return rb_enc_str_new(bytes.data(), bytes.size(), rb_ascii8bit_encoding());
1607
+ }
1608
+
1609
+ /**
1610
+ * バイト列データをレイアウトに従って解釈し、パレットデータを更新します.
1611
+ *
1612
+ * @overload import!(data, layout='RGBA', range=nil)
1613
+ * @param [String] data バイト列
1614
+ * @param [String,Symbol,Array] layout カラーレイアウト
1615
+ * @param [Raneg,Array] range 更新するパレットインデックス範囲. 指定されない場合は全て.
1616
+ * @return [Rixmap::Palette] selfを返します.
1617
+ */
1618
+ static VALUE Palette_importSelf(int argc, VALUE* argv, VALUE self) {
1619
+ // 引数
1620
+ VALUE argData = Qnil, argLayout = Qnil, argRange = Qnil;
1621
+ rb_scan_args(argc, argv, "12", &argData, &argLayout, &argRange);
1622
+
1623
+ // データを変換しておく
1624
+ VALUE strData = rb_String(argData);
1625
+
1626
+ // 対象チャンネルリスト
1627
+ Rixmap::ChannelArray channels;
1628
+ if (!Rixmap::Helper::LayoutChannels(argLayout, channels)) {
1629
+ channels.push_back(Rixmap::Channel::RED);
1630
+ channels.push_back(Rixmap::Channel::GREEN);
1631
+ channels.push_back(Rixmap::Channel::BLUE);
1632
+ channels.push_back(Rixmap::Channel::ALPHA);
1633
+ }
1634
+
1635
+ // バイト列へ
1636
+ Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self);
1637
+
1638
+ // 設定範囲
1639
+ long size = static_cast<long>(_this->getSize()); // FIXME size_t使いたいよねぇ
1640
+ long first = 0;
1641
+ long last = size - 1;
1642
+ if (!NIL_P(argRange)) {
1643
+ if (RTEST(rb_obj_is_kind_of(argRange, rb_cRange))) {
1644
+ // Rangeから取得
1645
+ VALUE objFirst, objLast;
1646
+ int excludeLast = 0;
1647
+ rb_range_values(argRange, &objFirst, &objLast, &excludeLast);
1648
+
1649
+ first = NUM2LONG(objFirst);
1650
+ last = NUM2LONG(objLast);
1651
+ if (excludeLast) {
1652
+ // 終端を除外
1653
+ last--;
1654
+ }
1655
+ } else {
1656
+ // Range以外は配列にする
1657
+ VALUE range = rb_Array(argRange);
1658
+ VALUE objStart = rb_ary_entry(range, 0);
1659
+ VALUE objLast = rb_ary_entry(range, 1);
1660
+
1661
+ if (!NIL_P(objStart)) {
1662
+ first = NUM2LONG(rb_Integer(objStart));
1663
+ }
1664
+ if (!NIL_P(objLast)) {
1665
+ last = NUM2LONG(rb_Integer(objLast));
1666
+ }
1667
+ }
1668
+ }
1669
+
1670
+ // 負数方向を補正
1671
+ if (first < 0) {
1672
+ first += size;
1673
+ }
1674
+ if (last < 0) {
1675
+ last += size;
1676
+ }
1677
+
1678
+ // 範囲チェック
1679
+ if (first < 0 || first >= size) {
1680
+ rb_raise(rb_eRangeError, "start of range is out of palette index range");
1681
+ }
1682
+ if (last < 0 || last >= size) {
1683
+ rb_raise(rb_eRangeError, "last of range is out of palette index range");
1684
+ }
1685
+ if (first > last) {
1686
+ rb_raise(rb_eRangeError, "first of range must be less than or equal to last of range");
1687
+ }
1688
+
1689
+ // 長さを調べる
1690
+ long count = (last - first) + 1;
1691
+ long nbyte = (count * channels.size());
1692
+ long strLength = RSTRING_LEN(strData);
1693
+ char* strValues = StringValuePtr(strData);
1694
+
1695
+ if (strLength < nbyte) {
1696
+ rb_raise(rb_eArgError, "data length shorter than target range");
1697
+ }
1698
+
1699
+ // 入れる
1700
+ long p = 0;
1701
+ for (long i = first; i <= last; i++) {
1702
+ Rixmap::Color& color = _this->get(i);
1703
+ for (auto it = channels.begin(); it != channels.end(); it++) {
1704
+ uint8_t value = static_cast<uint8_t>(strValues[p++]);
1705
+ color.set(*it, value);
1706
+ }
1707
+ }
1708
+
1709
+ return self;
1710
+ }
1711
+
1725
1712
  /**
1726
1713
  * オブジェクトとしての文字列表現を返します.
1727
1714
  *
@@ -1878,11 +1865,16 @@ static VALUE Image_initialize(int argc, VALUE* argv, VALUE self) {
1878
1865
  rb_raise(rb_eRuntimeError, "unknown error occurred");
1879
1866
  }
1880
1867
 
1881
- // オプションパラメータからパレットを拾う
1882
- VALUE optPalette = Qnil;
1868
+ // オプションパラメータを拾う
1869
+ VALUE optPalette = Qnil;
1870
+ VALUE optBackground = Qnil;
1871
+ VALUE optTransparent = Qnil;
1883
1872
  if (RB_TYPE_P(argOptions, T_HASH)) {
1884
1873
  optPalette = rb_hash_lookup(argOptions, ID2SYM(rb_intern("palette")));
1885
1874
  // TODO 型チェック
1875
+
1876
+ optBackground = rb_hash_lookup(argOptions, ID2SYM(rb_intern("background")));
1877
+ optTransparent = rb_hash_lookup(argOptions, ID2SYM(rb_intern("transparent")));
1886
1878
  }
1887
1879
 
1888
1880
  // パレットの処置
@@ -1894,6 +1886,13 @@ static VALUE Image_initialize(int argc, VALUE* argv, VALUE self) {
1894
1886
  // パレットの設定
1895
1887
  _this->setPalette(optPalette);
1896
1888
 
1889
+ // その他オプションパラメータ
1890
+ Rixmap::Helper::SetBackgroundValue(*_this, _this->getBackground(), optBackground);
1891
+ Rixmap::Helper::SetBackgroundValue(*_this, _this->getTransparent(), optTransparent);
1892
+
1893
+ // 背景色を反映
1894
+ _this->clear();
1895
+
1897
1896
  // 戻る
1898
1897
  return self;
1899
1898
  }
@@ -1970,6 +1969,58 @@ static VALUE Image_setPalette(VALUE self, VALUE argPalette) {
1970
1969
  return argPalette;
1971
1970
  }
1972
1971
 
1972
+ /**
1973
+ * 背景色を取得します.
1974
+ *
1975
+ * @return [Rixmap::Color,Integer,nil] 背景色データ.
1976
+ * 画像形式によって戻り値の型は変わります.
1977
+ * 未設定の場合はnil.
1978
+ */
1979
+ static VALUE Image_getBackground(VALUE self) {
1980
+ Rixmap::ImageData* _this = rixmap_unwrap<Rixmap::ImageData>(self);
1981
+ Rixmap::BackgroundColor& _bg = _this->getBackground();
1982
+
1983
+ return Rixmap::Helper::GetBackgroundValue(*_this, _bg);
1984
+ }
1985
+
1986
+ /**
1987
+ * 背景色を設定します.
1988
+ *
1989
+ * @param [Array,Rixmap::Color,Integer,nil] color 設定する背景色
1990
+ * @return [void] 戻り値は未定義とういことです
1991
+ */
1992
+ static VALUE Image_setBackground(VALUE self, VALUE argColor) {
1993
+ Rixmap::ImageData* _this = rixmap_unwrap<Rixmap::ImageData>(self);
1994
+ Rixmap::BackgroundColor& _bg = _this->getBackground();
1995
+ Rixmap::Helper::SetBackgroundValue(*_this, _bg, argColor);
1996
+ return argColor;
1997
+ }
1998
+
1999
+ /**
2000
+ * 透過色を取得します.
2001
+ *
2002
+ * @return [Rixmap::Color,Integer,nil] 透過色のColorオブジェクトまたはパレットインデックス.
2003
+ * 未設定の場合はnil.
2004
+ */
2005
+ static VALUE Image_getTransparent(VALUE self) {
2006
+ Rixmap::ImageData* _this = rixmap_unwrap<Rixmap::ImageData>(self);
2007
+ Rixmap::BackgroundColor& _trans = _this->getTransparent();
2008
+ return Rixmap::Helper::GetBackgroundValue(*_this, _trans);
2009
+ }
2010
+
2011
+ /**
2012
+ * 透過色を設定します.
2013
+ *
2014
+ * @param [Array,Rixmap::Color,Integer,nil] color 設定する透過色
2015
+ * @return [void] 戻り値は未定義とういことです
2016
+ */
2017
+ static VALUE Image_setTransparent(VALUE self, VALUE argColor) {
2018
+ Rixmap::ImageData* _this = rixmap_unwrap<Rixmap::ImageData>(self);
2019
+ Rixmap::BackgroundColor& _trans = _this->getTransparent();
2020
+ Rixmap::Helper::SetBackgroundValue(*_this, _trans, argColor);
2021
+ return argColor;
2022
+ }
2023
+
1973
2024
  /**
1974
2025
  * 画像サイズを配列で返します.
1975
2026
  *
@@ -2438,15 +2489,23 @@ static VALUE Image_getPixels(VALUE self) {
2438
2489
  static VALUE Image_inspect(VALUE self) {
2439
2490
  Rixmap::ImageData* _this = rixmap_unwrap<Rixmap::ImageData>(self);
2440
2491
  volatile VALUE objPalette = _this->getPalette();
2492
+ volatile VALUE objBackground = Rixmap::Helper::GetBackgroundValue(*_this, _this->getBackground());
2493
+ volatile VALUE objTransparent = Rixmap::Helper::GetBackgroundValue(*_this, _this->getTransparent());
2441
2494
  volatile VALUE paletteText = rb_inspect(objPalette);
2495
+ volatile VALUE backgroundText = rb_inspect(objBackground);
2496
+ volatile VALUE transparentText = rb_inspect(objTransparent);
2442
2497
  return rb_enc_sprintf(
2443
2498
  rb_usascii_encoding(),
2444
- "#<%s:%p mode=%s, size=(%d, %d), palette=%s>",
2499
+ "#<%s:%p mode=%s, size=(%d, %d), palette=%s, background=%s, transparent=%s>",
2500
+ //"#<%s:%p mode=%s, size=(%d, %d), palette=%s>",
2445
2501
  rb_obj_classname(self), reinterpret_cast<void*>(self),
2446
2502
  _this->getModeInfo().getName().c_str(),
2447
2503
  _this->getWidth(),
2448
2504
  _this->getHeight(),
2449
- StringValueCStr(paletteText));
2505
+ StringValueCStr(paletteText),
2506
+ StringValueCStr(backgroundText),
2507
+ StringValueCStr(transparentText)
2508
+ );
2450
2509
  }
2451
2510
 
2452
2511
  /**
@@ -2671,7 +2730,7 @@ static VALUE Image_crop(VALUE self, VALUE argLeft, VALUE argTop, VALUE argRight,
2671
2730
  int32_t newHeight = (bottom - top) + 1;
2672
2731
 
2673
2732
  // 適用先
2674
- VALUE cropOptions = _this->getMetadata();
2733
+ VALUE cropOptions = Rixmap::Helper::GetImageMetadata(*_this);
2675
2734
  VALUE croppedImage = RixmapImage_NewInstance(_this->getMode(), newWidth, newHeight, cropOptions);
2676
2735
  Rixmap::ImageData* cropped = rixmap_unwrap<Rixmap::ImageData>(croppedImage);
2677
2736
 
@@ -2745,7 +2804,7 @@ static VALUE Image_paste(VALUE self, VALUE argImage, VALUE argX, VALUE argY) {
2745
2804
  * @overload deform(deformer, *args)
2746
2805
  * 指定された{Rixmap::Deformer::BaseDeformer}インスタンスを使って変形処理を実行します.
2747
2806
  * @param [Rixmap::Deformer::BaseDeformer] deformer 変形処理実装インスタンス
2748
- * @param [Array] *args {Rixmap::Deformer::BaseDeformer#deform} に渡す追加引数
2807
+ * @param [Array] *args Rixmap::Deformer::BaseDeformer#deform に渡す追加引数
2749
2808
  * @return [Rixmap::Image] 変形後画像
2750
2809
  *
2751
2810
  * @see Rixmap::Deformer::BaseDeformer#deform
@@ -2770,7 +2829,7 @@ static VALUE Image_deform(int argc, VALUE* argv, VALUE self) {
2770
2829
  * @overload deform!(deformer, *args)
2771
2830
  * 指定された{Rixmap::Deformer::BaseDeformer}インスタンスを使って破壊的に変形処理を実行します.
2772
2831
  * @param [Rixmap::Deformer::BaseDeformer] deformer 変形処理実装インスタンス
2773
- * @param [Array] *args {Rixmap::Deformer::BaseDeformer#deform} に渡す追加引数
2832
+ * @param [Array] *args Rixmap::Deformer::BaseDeformer#deform に渡す追加引数
2774
2833
  * @return [Rixmap::Image] selfを返します.
2775
2834
  *
2776
2835
  * @see Rixmap::Deformer::BaseDeformer#deform
@@ -2798,7 +2857,7 @@ static VALUE Image_deformSelf(int argc, VALUE* argv, VALUE self) {
2798
2857
  /**
2799
2858
  * 指定方向に破壊的に反転処理を行います.
2800
2859
  *
2801
- * @param [Integer] direction 反転方向. {Rixmap::HORIZONTAL}, {Rixmap::VERTICAL}, {Rixmap::DIAGONAL}のいずれか.
2860
+ * @param [Integer] direction 反転方向. {Rixmap.HORIZONTAL}, {Rixmap.VERTICAL}, {Rixmap.DIAGONAL}のいずれか.
2802
2861
  * @return [Rixmap::Image] selfを返します.
2803
2862
  */
2804
2863
  static VALUE Image_flipSelf(VALUE self, VALUE argDirection) {
@@ -2816,7 +2875,7 @@ static VALUE Image_flipSelf(VALUE self, VALUE argDirection) {
2816
2875
  /**
2817
2876
  * 指定方向に反転を行った画像を返します.
2818
2877
  *
2819
- * @param [Integer] direction 反転方向. {Rixmap::HORIZONTAL}, {Rixmap::VERTICAL}, {Rixmap::DIAGONAL}のいずれか.
2878
+ * @param [Integer] direction 反転方向. {Rixmap.HORIZONTAL}, {Rixmap.VERTICAL}, {Rixmap.DIAGONAL}のいずれか.
2820
2879
  * @return [Rixmap::Image] 反転後の画像
2821
2880
  */
2822
2881
  static VALUE Image_flip(VALUE self, VALUE argDirection) {
@@ -3041,7 +3100,7 @@ static VALUE ImageLine_setPaletteBand(VALUE self, VALUE argBand) {
3041
3100
  /**
3042
3101
  * スキャンライン内の指定位置のピクセルデータを取得します.
3043
3102
  *
3044
- * ピクセルデータの形式は {Rixmap::Image#[]} を参照してください.
3103
+ * ピクセルデータの形式は Rixmap::Image#[] を参照してください.
3045
3104
  *
3046
3105
  * @param [Integer] offset 取得オフセット
3047
3106
  * @return [Integer,Array,nil] ピクセルデータ
@@ -3057,7 +3116,7 @@ static VALUE ImageLine_offsetGet(VALUE self, VALUE argOffset) {
3057
3116
  /**
3058
3117
  * スキャンライン内の指定位置のピクセルデータを更新します.
3059
3118
  *
3060
- * ピクセルデータの形式は {Rixmap::Image#[]=} を参照してください.
3119
+ * ピクセルデータの形式は Rixmap::Image#[]= を参照してください.
3061
3120
  *
3062
3121
  * @param [Integer] offset 更新オフセット
3063
3122
  * @param [Integer,Array,Rixmap::Color] color 更新データ
@@ -3401,12 +3460,14 @@ void RixmapCore_Init() {
3401
3460
  rb_define_method(cRixmapPalette, "[]", RUBY_METHOD_FUNC(Palette_offsetGet), 1);
3402
3461
  rb_define_method(cRixmapPalette, "[]=", RUBY_METHOD_FUNC(Palette_offsetSet), 2);
3403
3462
  rb_define_method(cRixmapPalette, "==", RUBY_METHOD_FUNC(Palette_operatorEquals), 1);
3404
- rb_define_method(cRixmapPalette, "to_s", RUBY_METHOD_FUNC(Palette_toString), -1); // バイト列への変換
3405
3463
  rb_define_method(cRixmapPalette, "to_a", RUBY_METHOD_FUNC(Palette_toArray), 0); // カラー配列への変換 (self.each.to_aでもいいかも)
3406
3464
  rb_define_method(cRixmapPalette, "each", RUBY_METHOD_FUNC(Palette_each), 0);
3407
3465
  rb_define_method(cRixmapPalette, "map", RUBY_METHOD_FUNC(Palette_map), 0);
3408
3466
  rb_define_method(cRixmapPalette, "map!", RUBY_METHOD_FUNC(Palette_mapSelf), 0);
3467
+ rb_define_method(cRixmapPalette, "export", RUBY_METHOD_FUNC(Palette_export), -1); // バイト列への変換処理
3468
+ rb_define_method(cRixmapPalette, "import!", RUBY_METHOD_FUNC(Palette_importSelf), -1); // バイト列からの更新処理
3409
3469
  rb_define_method(cRixmapPalette, "inspect", RUBY_METHOD_FUNC(Palette_inspect), 0);
3470
+ rb_alias(cRixmapPalette, rb_intern("to_s"), rb_intern("export"));
3410
3471
  rb_include_module(cRixmapPalette, rb_mEnumerable);
3411
3472
 
3412
3473
  /**
@@ -3434,26 +3495,30 @@ void RixmapCore_Init() {
3434
3495
  rb_define_alloc_func(cRixmapImage, Image_Alloc);
3435
3496
  rb_define_private_method(cRixmapImage, "initialize", RUBY_METHOD_FUNC(Image_initialize), -1);
3436
3497
  rb_define_private_method(cRixmapImage, "initialize_copy", RUBY_METHOD_FUNC(Image_initializeCopy), 1);
3437
- rb_define_method(cRixmapImage, "mode", RUBY_METHOD_FUNC(Image_getMode), 0);
3438
- rb_define_method(cRixmapImage, "width", RUBY_METHOD_FUNC(Image_getWidth), 0);
3439
- rb_define_method(cRixmapImage, "height", RUBY_METHOD_FUNC(Image_getHeight), 0);
3440
- rb_define_method(cRixmapImage, "palette", RUBY_METHOD_FUNC(Image_getPalette), 0);
3441
- rb_define_method(cRixmapImage, "palette=", RUBY_METHOD_FUNC(Image_setPalette), 1);
3442
- rb_define_method(cRixmapImage, "size", RUBY_METHOD_FUNC(Image_getSize), 0);
3443
- rb_define_method(cRixmapImage, "dimension", RUBY_METHOD_FUNC(Image_getDimension), 0);
3444
- rb_define_method(cRixmapImage, "indexed?", RUBY_METHOD_FUNC(Image_isIndexedImage), 0);
3445
- rb_define_method(cRixmapImage, "grayscale?", RUBY_METHOD_FUNC(Image_isGrayScaleImage), 0);
3446
- rb_define_method(cRixmapImage, "rgb?", RUBY_METHOD_FUNC(Image_isRGBImage), 0);
3447
- rb_define_method(cRixmapImage, "has_alpha?", RUBY_METHOD_FUNC(Image_hasAlphaChannel), 0);
3448
- rb_define_method(cRixmapImage, "[]", RUBY_METHOD_FUNC(Image_offsetGet), -1);
3449
- rb_define_method(cRixmapImage, "[]=", RUBY_METHOD_FUNC(Image_offsetSet), -1);
3450
- rb_define_method(cRixmapImage, "==", RUBY_METHOD_FUNC(Image_operatorEquals), 1);
3451
- rb_define_method(cRixmapImage, "each_line", RUBY_METHOD_FUNC(Image_eachLine), 0);
3452
- rb_define_method(cRixmapImage, "each_pixel", RUBY_METHOD_FUNC(Image_eachPixel), 0);
3453
- rb_define_method(cRixmapImage, "lines", RUBY_METHOD_FUNC(Image_getLines), 0);
3454
- rb_define_method(cRixmapImage, "pixels", RUBY_METHOD_FUNC(Image_getPixels), 0);
3455
- rb_define_method(cRixmapImage, "convert", RUBY_METHOD_FUNC(Image_convert), 1);
3456
- rb_define_method(cRixmapImage, "inspect", RUBY_METHOD_FUNC(Image_inspect), 0);
3498
+ rb_define_method(cRixmapImage, "mode", RUBY_METHOD_FUNC(Image_getMode), 0);
3499
+ rb_define_method(cRixmapImage, "width", RUBY_METHOD_FUNC(Image_getWidth), 0);
3500
+ rb_define_method(cRixmapImage, "height", RUBY_METHOD_FUNC(Image_getHeight), 0);
3501
+ rb_define_method(cRixmapImage, "palette", RUBY_METHOD_FUNC(Image_getPalette), 0);
3502
+ rb_define_method(cRixmapImage, "palette=", RUBY_METHOD_FUNC(Image_setPalette), 1);
3503
+ rb_define_method(cRixmapImage, "background", RUBY_METHOD_FUNC(Image_getBackground), 0);
3504
+ rb_define_method(cRixmapImage, "background=", RUBY_METHOD_FUNC(Image_setBackground), 1);
3505
+ rb_define_method(cRixmapImage, "transparent", RUBY_METHOD_FUNC(Image_getTransparent), 0);
3506
+ rb_define_method(cRixmapImage, "transparent=", RUBY_METHOD_FUNC(Image_setTransparent), 1);
3507
+ rb_define_method(cRixmapImage, "size", RUBY_METHOD_FUNC(Image_getSize), 0);
3508
+ rb_define_method(cRixmapImage, "dimension", RUBY_METHOD_FUNC(Image_getDimension), 0);
3509
+ rb_define_method(cRixmapImage, "indexed?", RUBY_METHOD_FUNC(Image_isIndexedImage), 0);
3510
+ rb_define_method(cRixmapImage, "grayscale?", RUBY_METHOD_FUNC(Image_isGrayScaleImage), 0);
3511
+ rb_define_method(cRixmapImage, "rgb?", RUBY_METHOD_FUNC(Image_isRGBImage), 0);
3512
+ rb_define_method(cRixmapImage, "has_alpha?", RUBY_METHOD_FUNC(Image_hasAlphaChannel), 0);
3513
+ rb_define_method(cRixmapImage, "[]", RUBY_METHOD_FUNC(Image_offsetGet), -1);
3514
+ rb_define_method(cRixmapImage, "[]=", RUBY_METHOD_FUNC(Image_offsetSet), -1);
3515
+ rb_define_method(cRixmapImage, "==", RUBY_METHOD_FUNC(Image_operatorEquals), 1);
3516
+ rb_define_method(cRixmapImage, "each_line", RUBY_METHOD_FUNC(Image_eachLine), 0);
3517
+ rb_define_method(cRixmapImage, "each_pixel", RUBY_METHOD_FUNC(Image_eachPixel), 0);
3518
+ rb_define_method(cRixmapImage, "lines", RUBY_METHOD_FUNC(Image_getLines), 0);
3519
+ rb_define_method(cRixmapImage, "pixels", RUBY_METHOD_FUNC(Image_getPixels), 0);
3520
+ rb_define_method(cRixmapImage, "convert", RUBY_METHOD_FUNC(Image_convert), 1);
3521
+ rb_define_method(cRixmapImage, "inspect", RUBY_METHOD_FUNC(Image_inspect), 0);
3457
3522
  rb_alias(cRixmapImage, rb_intern("dim"), rb_intern("dimension"));
3458
3523
 
3459
3524
  //// 画像操作系
@@ -3618,5 +3683,5 @@ VALUE RixmapImageLine_NewInstance(VALUE image, int32_t lineno) {
3618
3683
 
3619
3684
 
3620
3685
  //============================================================================//
3621
- // $Id: rixmapcore.cxx,v 753dbf70cab3 2014/05/16 16:13:38 chikuchikugonzalez $
3686
+ // $Id: rixmapcore.cxx,v 8e1a78cecea7 2014/05/30 13:50:43 chikuchikugonzalez $
3622
3687
  // vim: set sts=4 ts=4 sw=4 expandtab foldmethod=marker: