rapngasm 3.0.0 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rapngasm/rapngasm.cpp +79 -86
  3. metadata +24 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bd7622534fe5e431eaaa1ab22f413c1330b3ed0
4
- data.tar.gz: d3a28f279201bd5ad0f8b909b03cb2bba55a9bcc
3
+ metadata.gz: 1b9059697889a36b04000a804125e352b4d78004
4
+ data.tar.gz: 76316ebf184bcc8e1b879ef509b344cace3989d9
5
5
  SHA512:
6
- metadata.gz: 0022590795b1f52b58b7e7007331c51e16efd112c443110a2a7e09a5c87d2312afa96205a48f18d2d6d550b6fab9e12a5c6d9cce954aeafeedd94ed094ea0aa6
7
- data.tar.gz: 3960e22087e4c10097d43746c16b193a395f704577e051a096915152001b4c8813e7395c8b199885467d6d3e445e851d4ecf04fc572462ca976172e105b22a53
6
+ metadata.gz: 7c72c6f78f533e7e2c843b390029808c86b146cb5971e6eb07cacab616a3628d82eb4d5af812f1f05f5ba15646f6c35e0cf77250b1c4cf1caa5b24abfc9ea464
7
+ data.tar.gz: 7493e30582ea20e53c56dc2b7988db65704b45cc85de59d9f9ba1654121feb48481640228ce68877330d6708ff803c7bdb3b04fa87d640484a66a464bd80ab64
@@ -2,116 +2,109 @@
2
2
 
3
3
  #include <apngasm.h>
4
4
  #include <apngframe.h>
5
- #include "rice/Class.hpp"
6
5
  #include "rice/Data_Type.hpp"
6
+ #include "rice/Class.hpp"
7
7
  #include "rice/Constructor.hpp"
8
- #include "rice/String.hpp"
9
8
  #include "rice/Array.hpp"
10
- #include <iostream>
11
9
 
12
10
  using namespace Rice;
13
11
  using namespace apngasm;
14
12
 
15
- namespace apngasm
16
- {
17
- class RAPNGAsm : public APNGAsm
18
- {
19
- public:
20
- size_t addFrameFromFrameObject(const APNGFrame &frame)
21
- {
22
- return this->addFrame(frame);
23
- }
24
-
25
- size_t addFrameFromFile(const std::string &filePath,
26
- unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR)
27
- {
28
- return this->addFrame(filePath, delayNum, delayDen);
29
- }
30
-
31
- template<typename T>
32
- T from_ruby(Object o);
33
-
34
- template<typename T>
35
- Object to_ruby(T const & x);
36
- };
37
- }
38
-
39
- // template<>
40
- // std::vector<APNGFrame> from_ruby<std::vector<APNGFrame> >(Object o)
41
- // {
42
- // Array a(o);
43
- // std::vector<APNGFrame> v;
44
- // for(Array::iterator ai = a.begin(); ai != a.end(); ++ai)
45
- // v.push_back(from_ruby<APNGFrame> (*ai));
46
- // return v;
47
- // }
48
-
49
- template<>
50
- Object to_ruby< unsigned char* > (unsigned char* const & x)
51
- {
52
- unsigned char* const c = x;
53
- Array a;
54
- for (unsigned int i = 0; i < sizeof(c) ; i++)
55
- a.push(to_ruby<unsigned char>(c[i]));
56
- return a;
57
- }
58
-
59
13
  template<>
60
14
  Object to_ruby< std::vector<APNGFrame> > (std::vector<APNGFrame> const & x)
61
15
  {
62
16
  std::vector<APNGFrame> v = x;
63
17
  Array a;
18
+
64
19
  for (std::vector<APNGFrame>::iterator vi = v.begin(); vi != v.end(); ++vi)
65
20
  a.push(to_ruby<APNGFrame> (*vi));
21
+
66
22
  return a;
67
23
  }
68
24
 
69
25
  template<>
70
- unsigned char* from_ruby< unsigned char* > (Object o)
71
- {
26
+ rgb* from_ruby< rgb* > (Object o)
27
+ {
28
+ Array a(o);
29
+ rgb* rgbArray = (rgb*)malloc(a.size() * 3);
30
+
31
+ for (unsigned int i = 0; i < a.size(); i++)
32
+ {
33
+ Array array(a[i]);
34
+ rgb r = { from_ruby<unsigned char>(array[0]), from_ruby<unsigned char>(array[1]),
35
+ from_ruby<unsigned char>(array[2]) };
36
+ rgbArray[i] = r;
37
+ }
38
+
39
+ return rgbArray;
40
+ return NULL;
41
+ }
42
+
43
+ template<>
44
+ rgba* from_ruby< rgba* > (Object o)
45
+ {
72
46
  Array a(o);
73
- unsigned char* c = (unsigned char*)malloc(a.size());
47
+ rgba* rgbaArray = (rgba*)malloc(a.size() * 4);
48
+
74
49
  for (unsigned int i = 0; i < a.size(); i++)
75
- c[i] = from_ruby<unsigned char>(a[i]);
76
- return c;
50
+ {
51
+ Array array(a[i]);
52
+ rgba r = { from_ruby<unsigned char>(array[0]), from_ruby<unsigned char>(array[1]),
53
+ from_ruby<unsigned char>(array[2]), from_ruby<unsigned char>(array[3]) };
54
+ rgbaArray[i] = r;
55
+ }
56
+
57
+ return rgbaArray;
77
58
  }
78
59
 
60
+ //size_t APNGAsm::wrap_add_frame_rgb(Object pixels, unsigned int width, unsigned int height, Object trns_color = NULL, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR) {
61
+ // return this.addFrame(from_ruby<rgb*>(pixels), width, height, from_ruby<rgb*>(trns_color), delayNum, delayDen);
62
+ //}
63
+
79
64
  extern "C"
80
65
  void Init_rapngasm()
81
66
  {
82
- define_class<APNGFrame>("APNGFrame")
83
- //.define_constructor(Constructor<APNGFrame>())
84
- .define_constructor(Constructor<APNGFrame, const std::string, unsigned, unsigned>(),
85
- (Arg("file_path"), Arg("delay_num") = DEFAULT_FRAME_NUMERATOR, Arg("dela_den") = DEFAULT_FRAME_DENOMINATOR))
86
- .define_method("pixels", &APNGFrame::pixels, (Arg("pixels") = NULL))
87
- .define_method("width", &APNGFrame::width, (Arg("width") = 0))
88
- .define_method("height", &APNGFrame::height, (Arg("height") = 0))
89
- .define_method("color_type", &APNGFrame::colorType, (Arg("color_type") = 255))
90
- // .define_method("palette", &APNGFrame::palette, (Arg("palette") = NULL))
91
- .define_method("transparency", &APNGFrame::transparency, (Arg("transparency") = NULL))
92
- .define_method("palettes_size", &APNGFrame::paletteSize, (Arg("palettes_size") = 0))
93
- .define_method("transparency_size", &APNGFrame::transparencySize, (Arg("transparency_size") = NULL))
94
- .define_method("delay_numerator", &APNGFrame::delayNum, (Arg("delay_numerator") = 0))
95
- .define_method("delay_denominator", &APNGFrame::delayDen, (Arg("delay_denominator") = 0));
96
- // .define_method("rows", &APNGFrame::rows, (Arg("rows") = NULL));
97
-
98
- define_class<APNGAsm>("APNGAsmSuper")
99
- .define_constructor(Constructor<APNGAsm>())
100
- .define_method("assemble", &APNGAsm::assemble)
101
- .define_method("disassemble", &APNGAsm::disassemble)
102
- .define_method("load_animation_spec", &APNGAsm::loadAnimationSpec)
103
- .define_method("save_pngs", &APNGAsm::savePNGs)
104
- .define_method("save_json", &APNGAsm::saveJson)
105
- .define_method("save_xml", &APNGAsm::saveXml)
106
- //.define_method("set_apngasm_listener", &APNGAsm::setAPNGAsmListener)
107
- .define_method("get_frames", &APNGAsm::getFrames)
108
- .define_method("frame_count", &APNGAsm::frameCount)
109
- .define_method("reset", &APNGAsm::reset)
110
- .define_method("version", &APNGAsm::version);
67
+ define_class<APNGFrame>("APNGFrame")
68
+ .define_constructor(Constructor<APNGFrame>())
69
+ .define_method("pixels", &APNGFrame::pixels, (Arg("pixels") = NULL))
70
+ .define_method("width", &APNGFrame::width, (Arg("width") = 0))
71
+ .define_method("height", &APNGFrame::height, (Arg("height") = 0))
72
+ .define_method("color_type", &APNGFrame::colorType, (Arg("color_type") = 255))
73
+ .define_method("palette", &APNGFrame::palette, (Arg("palette") = NULL))
74
+ .define_method("transparency", &APNGFrame::transparency, (Arg("transparency") = NULL))
75
+ .define_method("palettes_size", &APNGFrame::paletteSize, (Arg("palettes_size") = 0))
76
+ .define_method("transparency_size", &APNGFrame::transparencySize, (Arg("transparency_size") = NULL))
77
+ .define_method("delay_numerator", &APNGFrame::delayNum, (Arg("delay_numerator") = 0))
78
+ .define_method("delay_denominator", &APNGFrame::delayDen, (Arg("delay_denominator") = 0))
79
+ .define_method("rows", &APNGFrame::rows, (Arg("rows") = NULL))
80
+ .define_method("save", &APNGFrame::save, (Arg("out_path")));
111
81
 
112
- define_class<RAPNGAsm, APNGAsm>("APNGAsm")
113
- .define_constructor(Constructor<RAPNGAsm>())
114
- .define_method("add_frame", &RAPNGAsm::addFrameFromFrameObject, Arg("frame"))
115
- .define_method("add_frame_from_file", &RAPNGAsm::addFrameFromFile,
116
- (Arg("filePath"), Arg("delayNum") = DEFAULT_FRAME_NUMERATOR, Arg("delayDen") = DEFAULT_FRAME_DENOMINATOR));
82
+ typedef size_t (APNGAsm::*add_frame_object)(const APNGFrame&);
83
+ typedef size_t (APNGAsm::*add_frame_file)(const std::string&, unsigned, unsigned);
84
+ typedef size_t (APNGAsm::*add_frame_rgb)(rgb*, unsigned int, unsigned int, rgb*, unsigned, unsigned);
85
+ typedef size_t (APNGAsm::*add_frame_rgba)(rgba*, unsigned int, unsigned int, unsigned, unsigned);
86
+ define_class<APNGAsm>("APNGAsm")
87
+ .define_constructor(Constructor<APNGAsm>())
88
+ .define_method("assemble", &APNGAsm::assemble)
89
+ .define_method("disassemble", &APNGAsm::disassemble)
90
+ .define_method("load_animation_spec", &APNGAsm::loadAnimationSpec)
91
+ .define_method("save_pngs", &APNGAsm::savePNGs)
92
+ .define_method("save_json", &APNGAsm::saveJSON)
93
+ .define_method("save_xml", &APNGAsm::saveXML)
94
+ //.define_method("set_apngasm_listener", &APNGAsm::setAPNGAsmListener)
95
+ .define_method("get_frames", &APNGAsm::getFrames)
96
+ .define_method("frame_count", &APNGAsm::frameCount)
97
+ .define_method("reset", &APNGAsm::reset)
98
+ .define_method("version", &APNGAsm::version)
99
+ .define_method("add_frame", add_frame_object(&APNGAsm::addFrame))
100
+ .define_method("add_frame_file", add_frame_file(&APNGAsm::addFrame),
101
+ (Arg("file_path"), Arg("delay_numerator") = DEFAULT_FRAME_NUMERATOR,
102
+ Arg("delay_denominator") = DEFAULT_FRAME_DENOMINATOR))
103
+ .define_method("add_frame_rgb", add_frame_rgb(&APNGAsm::addFrame),
104
+ (Arg("pixels"), Arg("width"), Arg("height"), Arg("trns_color") = NULL,
105
+ Arg("delay_numerator") = DEFAULT_FRAME_NUMERATOR,
106
+ Arg("delay_denominator") = DEFAULT_FRAME_DENOMINATOR))
107
+ .define_method("add_frame_rgba", add_frame_rgba(&APNGAsm::addFrame),
108
+ (Arg("pixels"), Arg("width"), Arg("height"),
109
+ Arg("delay_numerator") = DEFAULT_FRAME_NUMERATOR, Arg("delay_denominator") = DEFAULT_FRAME_DENOMINATOR));
117
110
  }
metadata CHANGED
@@ -1,43 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapngasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei Kagetsuki
8
+ - Rika Yoshida
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
12
+ date: 2014-05-16 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake-compiler
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ">="
18
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '0'
20
+ version: '0.9'
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.2
20
24
  type: :runtime
21
25
  prerelease: false
22
26
  version_requirements: !ruby/object:Gem::Requirement
23
27
  requirements:
24
- - - ">="
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '0.9'
31
+ - - "~>"
25
32
  - !ruby/object:Gem::Version
26
- version: '0'
33
+ version: 0.9.2
27
34
  - !ruby/object:Gem::Dependency
28
35
  name: rice
29
36
  requirement: !ruby/object:Gem::Requirement
30
37
  requirements:
31
- - - ">="
38
+ - - "~>"
32
39
  - !ruby/object:Gem::Version
33
- version: '0'
40
+ version: '1.6'
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.2
34
44
  type: :runtime
35
45
  prerelease: false
36
46
  version_requirements: !ruby/object:Gem::Requirement
37
47
  requirements:
38
- - - ">="
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '1.6'
51
+ - - "~>"
39
52
  - !ruby/object:Gem::Version
40
- version: '0'
53
+ version: 1.6.2
41
54
  description: Ruby native extension for the apngasm APNG Assembler.
42
55
  email: zero@genshin.org
43
56
  executables: []
@@ -68,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
81
  version: '0'
69
82
  requirements: []
70
83
  rubyforge_project:
71
- rubygems_version: 2.2.0
84
+ rubygems_version: 2.2.2
72
85
  signing_key:
73
86
  specification_version: 4
74
87
  summary: apngasm for Ruby