lilimg 0.0.7 → 0.0.8
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 +4 -4
- data/ext/lilimg/lilimg.c +9 -10
- data/lilimg.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce074a06e27e4c1af28781cb5d650b426cec12239d6df43df8c07f9f8f367035
|
4
|
+
data.tar.gz: 88a75be93c92cf03eb86bf6a79b1bc9dda5d57b6bc46c9adb39140be036eba90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70919b3d9efac337eac40c0b840906fa12160d6d6bc355a02b1cca6dba1eb88e85fcada7a839e99c2fffad03cbf686d16ac34b98a54c13a67140b5697b86da6b
|
7
|
+
data.tar.gz: 6e2cd74fbd469963759e4691f20b64b0807a578c9e1df29f94d14c69f20525af72dcfb1bb8a525f7c82bbfa5a18e5f9a3d53292678a35ebf20daf6a80369c232
|
data/ext/lilimg/lilimg.c
CHANGED
@@ -8,8 +8,7 @@
|
|
8
8
|
|
9
9
|
unsigned char * rgb_to_rgba(unsigned char * buf, int w, int h) {
|
10
10
|
int newsize = 4 * w * h;
|
11
|
-
unsigned char * dest;
|
12
|
-
dest = malloc(newsize);
|
11
|
+
unsigned char * dest = (unsigned char *)malloc(newsize);
|
13
12
|
int s = 0, d = 0;
|
14
13
|
while (d < newsize) {
|
15
14
|
dest[d++] = buf[s++];
|
@@ -21,10 +20,10 @@ unsigned char * rgb_to_rgba(unsigned char * buf, int w, int h) {
|
|
21
20
|
return dest;
|
22
21
|
}
|
23
22
|
|
24
|
-
static VALUE jpeg_to_gif(VALUE self, VALUE buf) {
|
23
|
+
static VALUE jpeg_to_gif(VALUE self, VALUE buf, VALUE max_colors) {
|
25
24
|
rb_check_type(buf, T_STRING);
|
26
25
|
|
27
|
-
int maxColors =
|
26
|
+
int maxColors = INT2NUM(max_colors);
|
28
27
|
int size = RSTRING_LEN(buf);
|
29
28
|
unsigned char * jpeg = (unsigned char *)StringValuePtr(buf);
|
30
29
|
|
@@ -36,15 +35,14 @@ static VALUE jpeg_to_gif(VALUE self, VALUE buf) {
|
|
36
35
|
njInit();
|
37
36
|
|
38
37
|
if (njDecode(jpeg, size)) {
|
39
|
-
free(
|
38
|
+
free(jpeg);
|
40
39
|
rb_raise(rb_eRuntimeError, "Error decoding input file (size %d)", size);
|
41
40
|
return Qnil;
|
42
41
|
}
|
43
42
|
|
44
|
-
free((void*)jpeg);
|
45
|
-
|
46
43
|
unsigned char * pixels = njGetImage();
|
47
44
|
if (!pixels) {
|
45
|
+
free(jpeg);
|
48
46
|
rb_raise(rb_eRuntimeError, "Couldn't decode image.");
|
49
47
|
return Qnil;
|
50
48
|
}
|
@@ -55,6 +53,7 @@ static VALUE jpeg_to_gif(VALUE self, VALUE buf) {
|
|
55
53
|
// FILE * fp = fopen("output.gif", "wb");
|
56
54
|
|
57
55
|
if (!fp) {
|
56
|
+
free(jpeg);
|
58
57
|
rb_raise(rb_eRuntimeError, "Cannot initialize memstream");
|
59
58
|
return Qnil;
|
60
59
|
}
|
@@ -64,9 +63,9 @@ static VALUE jpeg_to_gif(VALUE self, VALUE buf) {
|
|
64
63
|
jo_gif_frame(&gif, rgba, 0, 0);
|
65
64
|
jo_gif_end(&gif);
|
66
65
|
|
67
|
-
VALUE rstr;
|
68
|
-
rstr = rb_str_new(out, bufsize);
|
66
|
+
VALUE rstr = rb_str_new(out, bufsize);
|
69
67
|
|
68
|
+
free(jpeg);
|
70
69
|
free(rgba);
|
71
70
|
free(out);
|
72
71
|
njDone();
|
@@ -78,5 +77,5 @@ VALUE Lilimg = Qnil;
|
|
78
77
|
|
79
78
|
void Init_lilimg() {
|
80
79
|
Lilimg = rb_define_module("Lilimg");
|
81
|
-
rb_define_module_function(Lilimg, "jpeg_to_gif", jpeg_to_gif,
|
80
|
+
rb_define_module_function(Lilimg, "jpeg_to_gif", jpeg_to_gif, 2);
|
82
81
|
}
|
data/lilimg.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lilimg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Pollak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- ".gitignore"
|
22
22
|
- Rakefile
|
23
23
|
- example/build.sh
|
24
|
+
- example/label.jpg
|
24
25
|
- example/test.c
|
25
26
|
- example/test.rb
|
26
27
|
- ext/lilimg/extconf.rb
|