rapngasm 3.1.7 → 3.2.0.pre2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f62bad49972953e85ba8dab7d48939c4804e1e89
4
- data.tar.gz: 961521c383324ad26f5b1c909aea2ae29e14c08e
3
+ metadata.gz: 243d01ff7676acbe21398ff109d99cc2e018c2f3
4
+ data.tar.gz: 7215bc2b8c36528c1cc030c4ab832628b6b3a72e
5
5
  SHA512:
6
- metadata.gz: 70be502c18f5a01b72050c5a9c6dd17ed5aa3f9121de1478ee3d0fe3e154ffc5c264ab07993f69136bd70ee12c27bca106d5e62b6a5d3f45fb2cf69fb9095bef
7
- data.tar.gz: 75e175e67f81d463767c169087838a23a87d3ee3261f359e84732487c7aa715c22d90b937f37e851b6a1fa03ebdcdf49a78397a109a4efb10a1ad6ae26c7af8d
6
+ metadata.gz: a0efd4b1fb8dcacaf5edcd3465eb22e5afbecfb9a20de152e6c78fd82071a9c6247fcce68489b4637a95486d725a2e897b6fdcf1c4463f621c93a9ec17562edc
7
+ data.tar.gz: a91b62ce19216775b76ec4d0664a674599721bd5e8423b1d7bd6fe2b0d0f556142cc22b90139d5c2368c4d85808ff4ecf54dd93df00c759a22461b8bc888792b
@@ -0,0 +1,154 @@
1
+ %module APNG
2
+
3
+ // For java.
4
+ %pragma(java) jniclasscode=%{
5
+ static
6
+ {
7
+ NativeLibLoader.load();
8
+ }
9
+ %}
10
+
11
+ // For ruby.
12
+ #ifdef SWIGRUBY
13
+
14
+ // Replace init method name.
15
+ %{
16
+ #define Init_APNG Init_rapngasm
17
+ %}
18
+
19
+ // Convert array.
20
+ %typecheck(SWIG_TYPECHECK_POINTER) apngasm::rgb *pixels, apngasm::rgb *trns_color, apngasm::rgba *pixels
21
+ {
22
+ $1 = ( (TYPE($input) == T_ARRAY) && (TYPE(rb_ary_entry($input, 0)) == T_DATA) ) ? 1 : 0;
23
+ }
24
+
25
+ %typemap(in) apngasm::rgb *pixels, apngasm::rgb *trns_color, apngasm::rgba *pixels
26
+ {
27
+ Check_Type($input, T_ARRAY);
28
+ int size = RARRAY_LEN($input);
29
+ $1 = ($1_type)malloc(size*sizeof($*1_type));
30
+ for(int i = 0; i < size; ++i)
31
+ {
32
+ VALUE inst = rb_ary_entry($input, i);
33
+ Check_Type(inst, T_DATA);
34
+ $1_type element = NULL;
35
+ Data_Get_Struct(inst, $*1_type, element);
36
+ $1[i] = *element;
37
+ }
38
+ }
39
+
40
+ %typemap(freearg) apngasm::rgb *pixels, apngasm::rgb *trns_color, apngasm::rgba *pixels
41
+ {
42
+ if($1)
43
+ free($1);
44
+ }
45
+
46
+ // Rename methods.
47
+ %rename(color_type) apngasm::APNGFrame::colorType;
48
+ %rename(palette_size) apngasm::APNGFrame::paletteSize;
49
+ %rename(transparency_size) apngasm::APNGFrame::transparencySize;
50
+ %rename(delay_numerator) apngasm::APNGFrame::delayNum;
51
+ %rename(delay_denominator) apngasm::APNGFrame::delayDen;
52
+
53
+ %rename(add_frame) apngasm::APNGAsm::addFrame(const APNGFrame &frame);
54
+ %rename(add_frame_file) apngasm::APNGAsm::addFrame(const std::string &filePath, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
55
+ %rename(add_frame_rgb) apngasm::APNGAsm::addFrame(rgb *pixels, unsigned int width, unsigned int height, rgb *trns_color = NULL, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
56
+ %rename(add_frame_rgba) apngasm::APNGAsm::addFrame(rgba *pixels, unsigned int width, unsigned int height, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
57
+ %rename(save_pngs) apngasm::APNGAsm::savePNGs;
58
+ %rename(load_animation_spec) apngasm::APNGAsm::loadAnimationSpec;
59
+ %rename(save_json) apngasm::APNGAsm::saveJSON;
60
+ %rename(save_xml) apngasm::APNGAsm::saveXML;
61
+ %rename(set_loops) apngasm::APNGAsm::setLoops;
62
+ %rename(set_skip_first) apngasm::APNGAsm::setSkipFirst;
63
+ %rename(get_frames) apngasm::APNGAsm::getFrames;
64
+ %rename(get_loops) apngasm::APNGAsm::getLoops;
65
+ %rename(is_skip_first) apngasm::APNGAsm::isSkipFirst;
66
+ %rename(frame_count) apngasm::APNGAsm::frameCount;
67
+
68
+ %rename(Rgb) apngasm::rgb;
69
+ %rename(Rgba) apngasm::rgba;
70
+
71
+ #endif // SWIGRUBY
72
+
73
+
74
+
75
+ %{
76
+ #include "apngasm.h"
77
+ #include "apngframe.h"
78
+ %}
79
+
80
+
81
+
82
+ %include "std_string.i"
83
+ %include "std_vector.i"
84
+
85
+ %include "apngasm-conf.h"
86
+
87
+ namespace apngasm {
88
+ typedef struct { unsigned char r, g, b; } rgb;
89
+ typedef struct { unsigned char r, g, b, a; } rgba;
90
+
91
+ class APNGFrame
92
+ {
93
+ public:
94
+ APNGFrame();
95
+ APNGFrame(const std::string &filePath, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
96
+ // APNGFrame(rgb *pixels, unsigned int width, unsigned int height, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
97
+ // APNGFrame(rgb *pixels, unsigned int width, unsigned int height, rgb *trns_color = NULL, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
98
+ APNGFrame(rgba *pixels, unsigned int width, unsigned int height, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
99
+
100
+ unsigned char* pixels(unsigned char* setPixels = NULL);
101
+ unsigned int width(unsigned int setWidth = 0);
102
+ unsigned int height(unsigned int setHeight = 0);
103
+ unsigned char colorType(unsigned char setColorType = 255);
104
+ rgb* palette(rgb* setPalette = NULL);
105
+ unsigned char* transparency(unsigned char* setTransparency = NULL);
106
+ int paletteSize(int setPaletteSize = 0);
107
+ int transparencySize(int setTransparencySize = 0);
108
+ unsigned int delayNum(unsigned int setDelayNum = 0);
109
+ unsigned int delayDen(unsigned int setDelayDen = 0);
110
+ unsigned char** rows(unsigned char** setRows = NULL);
111
+
112
+ bool save(const std::string& outPath) const;
113
+ };
114
+
115
+ class APNGAsm
116
+ {
117
+ public:
118
+ APNGAsm(void);
119
+ APNGAsm(const std::vector<APNGFrame> &frames);
120
+ ~APNGAsm(void);
121
+
122
+ size_t addFrame(const std::string &filePath, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
123
+ size_t addFrame(const APNGFrame &frame);
124
+ size_t addFrame(rgb *pixels, unsigned int width, unsigned int height, rgb *trns_color = NULL, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
125
+ size_t addFrame(rgba *pixels, unsigned int width, unsigned int height, unsigned delayNum = DEFAULT_FRAME_NUMERATOR, unsigned delayDen = DEFAULT_FRAME_DENOMINATOR);
126
+
127
+ #ifdef APNG_WRITE_SUPPORTED
128
+ bool assemble(const std::string &outputPath);
129
+ #endif
130
+
131
+ #ifdef APNG_READ_SUPPORTED
132
+ const std::vector<APNGFrame>& disassemble(const std::string &filePath);
133
+ bool savePNGs(const std::string& outputDir) const;
134
+ #endif
135
+
136
+ #ifdef APNG_SPECS_SUPPORTED
137
+ const std::vector<APNGFrame>& loadAnimationSpec(const std::string &filePath);
138
+ bool saveJSON(const std::string& outputPath, const std::string& imageDir="") const;
139
+ bool saveXML(const std::string& outputPath, const std::string& imageDir="") const;
140
+ #endif
141
+
142
+ void setLoops(unsigned int loops=0);
143
+ void setSkipFirst(bool skipFirst);
144
+ const std::vector<APNGFrame>& getFrames() const;
145
+ unsigned int getLoops() const;
146
+ bool isSkipFirst() const;
147
+ size_t frameCount();
148
+ size_t reset();
149
+ const char* version(void) const;
150
+ };
151
+ }
152
+
153
+ // Rename stl vector.
154
+ %template(APNGFrameVector) std::vector<apngasm::APNGFrame>;