ruby-libgd 0.1.1 → 0.1.2
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/gd/circle.c +2 -8
- data/ext/gd/circle.o +0 -0
- data/ext/gd/draw_line.c +1 -5
- data/ext/gd/draw_line.o +0 -0
- data/ext/gd/encode.c +2 -12
- data/ext/gd/encode.o +0 -0
- data/ext/gd/fill.c +10 -6
- data/ext/gd/fill.o +0 -0
- data/ext/gd/gd.so +0 -0
- data/ext/gd/image.c +11 -2
- data/ext/gd/image.o +0 -0
- data/ext/gd/pixel.c +15 -11
- data/ext/gd/pixel.o +0 -0
- data/ext/gd/rectangle.c +2 -10
- data/ext/gd/rectangle.o +0 -0
- data/ext/gd/text.c +1 -5
- data/ext/gd/text.o +0 -0
- data/lib/gd/gd.so +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9eeb38f45f5b10901ca181a764eaa2674ace08857e5f0e8abd780992e0bed0fd
|
|
4
|
+
data.tar.gz: 9b9c340d1062ac114b96e5866d8d4644da1fa1d2f423f813d3b91ae48043008a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8f6e6c75657ec17d591bb3122732432f66720a46efac1076a29faeda7035d16cbf5d3d62a0d14a2736d8a388729747882b350b4a19720c39f70013fcf35d518
|
|
7
|
+
data.tar.gz: 9a5baf51987aa6bfacbb2896f35a3f590cd2ce8cdf9067b57a25afcbb3a08bd5225ce81c7161d38417c8d772267992e4f8fbe05ee6adad76dd75f3ac9c7d253f
|
data/ext/gd/circle.c
CHANGED
|
@@ -4,10 +4,7 @@ static VALUE gd_image_circle(VALUE self, VALUE cx, VALUE cy, VALUE r, VALUE colo
|
|
|
4
4
|
gd_image_wrapper *wrap;
|
|
5
5
|
TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
|
|
6
6
|
|
|
7
|
-
int
|
|
8
|
-
int green = NUM2INT(rb_ary_entry(color, 1));
|
|
9
|
-
int blue = NUM2INT(rb_ary_entry(color, 2));
|
|
10
|
-
int c = gdImageColorAllocate(wrap->img, red, green, blue);
|
|
7
|
+
int c = color_to_gd(wrap->img, color);
|
|
11
8
|
|
|
12
9
|
gdImageArc(wrap->img,
|
|
13
10
|
NUM2INT(cx), NUM2INT(cy),
|
|
@@ -21,10 +18,7 @@ static VALUE gd_image_filled_circle(VALUE self, VALUE cx, VALUE cy, VALUE r, VAL
|
|
|
21
18
|
gd_image_wrapper *wrap;
|
|
22
19
|
TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
|
|
23
20
|
|
|
24
|
-
int
|
|
25
|
-
int green = NUM2INT(rb_ary_entry(color, 1));
|
|
26
|
-
int blue = NUM2INT(rb_ary_entry(color, 2));
|
|
27
|
-
int c = gdImageColorAllocate(wrap->img, red, green, blue);
|
|
21
|
+
int c = color_to_gd(wrap->img, color);
|
|
28
22
|
|
|
29
23
|
gdImageFilledEllipse(wrap->img,
|
|
30
24
|
NUM2INT(cx), NUM2INT(cy),
|
data/ext/gd/circle.o
CHANGED
|
Binary file
|
data/ext/gd/draw_line.c
CHANGED
|
@@ -38,11 +38,7 @@ static VALUE gd_image_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, V
|
|
|
38
38
|
rb_raise(rb_eArgError, "color must be [r,g,b]");
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
int
|
|
42
|
-
int g = NUM2INT(rb_ary_entry(color, 1));
|
|
43
|
-
int b = NUM2INT(rb_ary_entry(color, 2));
|
|
44
|
-
|
|
45
|
-
int c = gdImageColorAllocate(wrap->img, r, g, b);
|
|
41
|
+
int c = color_to_gd(wrap->img, color);
|
|
46
42
|
gdImageLine(wrap->img, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), c);
|
|
47
43
|
|
|
48
44
|
return Qnil;
|
data/ext/gd/draw_line.o
CHANGED
|
Binary file
|
data/ext/gd/encode.c
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
#include "ruby_gd.h"
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
- [ ] imagegif — Output image to browser or file
|
|
5
|
-
- [x] imagewbmp — Output image to browser or file
|
|
6
|
-
- [x] imagewebp — Output a WebP image to browser or file
|
|
7
|
-
- [ ] imagexbm — Output an XBM image to browser or file
|
|
8
|
-
- [x] imagepng — Output a PNG image to either the browser or a file
|
|
9
|
-
- [x] imagejpeg — Output image to browser or file
|
|
10
|
-
- [ ] imagegd — Output GD image to browser or file
|
|
11
|
-
- [ ] imagegd2 — Output GD2 image to browser or file
|
|
12
|
-
- [ ] imageavif — Output image to browser or file
|
|
13
|
-
- [ ] imagebmp — Output a BMP image to browser or file
|
|
14
|
-
**/
|
|
15
3
|
static VALUE gd_image_save(int argc, VALUE *argv, VALUE self) {
|
|
16
4
|
VALUE path, opts;
|
|
17
5
|
rb_scan_args(argc, argv, "11", &path, &opts);
|
|
@@ -28,6 +16,8 @@ static VALUE gd_image_save(int argc, VALUE *argv, VALUE self) {
|
|
|
28
16
|
if (!f) rb_sys_fail(filename);
|
|
29
17
|
|
|
30
18
|
if (strcmp(ext, ".png") == 0) {
|
|
19
|
+
gdImageSaveAlpha(wrap->img, 1);
|
|
20
|
+
gdImageAlphaBlending(wrap->img, 0);
|
|
31
21
|
gdImagePng(wrap->img, f);
|
|
32
22
|
} else if (strcmp(ext, ".jpg") == 0 || strcmp(ext, ".jpeg") == 0) {
|
|
33
23
|
int quality = 90;
|
data/ext/gd/encode.o
CHANGED
|
Binary file
|
data/ext/gd/fill.c
CHANGED
|
@@ -10,13 +10,17 @@ static VALUE gd_image_fill(VALUE self, VALUE color) {
|
|
|
10
10
|
if (!wrap || !wrap->img)
|
|
11
11
|
rb_raise(rb_eRuntimeError, "uninitialized GD::Image");
|
|
12
12
|
|
|
13
|
-
int
|
|
14
|
-
int g = NUM2INT(rb_ary_entry(color,1));
|
|
15
|
-
int b = NUM2INT(rb_ary_entry(color,2));
|
|
16
|
-
int c = gdImageColorAllocate(wrap->img,r,g,b);
|
|
13
|
+
int c = color_to_gd(wrap->img, color);
|
|
17
14
|
|
|
18
|
-
gdImageFilledRectangle(
|
|
19
|
-
|
|
15
|
+
gdImageFilledRectangle(
|
|
16
|
+
wrap->img,
|
|
17
|
+
0, 0,
|
|
18
|
+
gdImageSX(wrap->img) - 1,
|
|
19
|
+
gdImageSY(wrap->img) - 1,
|
|
20
|
+
c
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return self;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
void gd_define_fill(VALUE cGDImage) {
|
data/ext/gd/fill.o
CHANGED
|
Binary file
|
data/ext/gd/gd.so
CHANGED
|
Binary file
|
data/ext/gd/image.c
CHANGED
|
@@ -19,6 +19,12 @@ static VALUE gd_image_initialize(int argc, VALUE *argv, VALUE self) {
|
|
|
19
19
|
rb_raise(rb_eArgError, "width and height must be positive");
|
|
20
20
|
|
|
21
21
|
wrap->img = gdImageCreateTrueColor(w, h);
|
|
22
|
+
gdImageSaveAlpha(wrap->img, 1);
|
|
23
|
+
gdImageAlphaBlending(wrap->img, 0);
|
|
24
|
+
|
|
25
|
+
int t = gdTrueColorAlpha(0,0,0,127);
|
|
26
|
+
gdImageFilledRectangle(wrap->img, 0, 0, w-1, h-1, t);
|
|
27
|
+
|
|
22
28
|
if (!wrap->img)
|
|
23
29
|
rb_raise(rb_eRuntimeError, "gdImageCreateTrueColor failed");
|
|
24
30
|
|
|
@@ -52,8 +58,11 @@ static VALUE gd_image_initialize_true_color(VALUE self, VALUE width, VALUE heigh
|
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
// Opcional: desactivar el fondo transparente si no lo necesitas
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
gdImageSaveAlpha(wrap->img, 1);
|
|
62
|
+
gdImageAlphaBlending(wrap->img, 0);
|
|
63
|
+
|
|
64
|
+
int t = gdTrueColorAlpha(0,0,0,127);
|
|
65
|
+
gdImageFilledRectangle(wrap->img, 0,0, w-1, h-1, t);
|
|
57
66
|
|
|
58
67
|
return self;
|
|
59
68
|
}
|
data/ext/gd/image.o
CHANGED
|
Binary file
|
data/ext/gd/pixel.c
CHANGED
|
@@ -4,35 +4,39 @@ static VALUE gd_image_set_pixel(VALUE self, VALUE x, VALUE y, VALUE color) {
|
|
|
4
4
|
gd_image_wrapper *wrap;
|
|
5
5
|
TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
|
|
6
6
|
|
|
7
|
-
int
|
|
8
|
-
int g = NUM2INT(rb_ary_entry(color,1));
|
|
9
|
-
int b = NUM2INT(rb_ary_entry(color,2));
|
|
10
|
-
|
|
11
|
-
int c = gdImageColorAllocate(wrap->img, r, g, b);
|
|
7
|
+
int c = color_to_gd(wrap->img, color);
|
|
12
8
|
|
|
13
9
|
gdImageSetPixel(wrap->img, NUM2INT(x), NUM2INT(y), c);
|
|
14
10
|
|
|
15
11
|
return Qnil;
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
static VALUE gd_image_get_pixel(VALUE self, VALUE
|
|
14
|
+
static VALUE gd_image_get_pixel(VALUE self, VALUE vx, VALUE vy) {
|
|
19
15
|
gd_image_wrapper *wrap;
|
|
20
16
|
TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
|
|
21
17
|
|
|
22
|
-
int
|
|
18
|
+
int x = NUM2INT(vx);
|
|
19
|
+
int y = NUM2INT(vy);
|
|
20
|
+
|
|
21
|
+
if (!wrap || !wrap->img) rb_raise(rb_eRuntimeError, "uninitialized GD::Image");
|
|
23
22
|
|
|
24
|
-
int
|
|
25
|
-
int g = gdImageGreen(wrap->img, c);
|
|
26
|
-
int b = gdImageBlue(wrap->img, c);
|
|
23
|
+
int p = gdImageGetTrueColorPixel(wrap->img, x, y);
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
int r = gdTrueColorGetRed(p);
|
|
26
|
+
int g = gdTrueColorGetGreen(p);
|
|
27
|
+
int b = gdTrueColorGetBlue(p);
|
|
28
|
+
int a = gdTrueColorGetAlpha(p);
|
|
29
|
+
|
|
30
|
+
VALUE ary = rb_ary_new_capa(4);
|
|
29
31
|
rb_ary_push(ary, INT2NUM(r));
|
|
30
32
|
rb_ary_push(ary, INT2NUM(g));
|
|
31
33
|
rb_ary_push(ary, INT2NUM(b));
|
|
34
|
+
rb_ary_push(ary, INT2NUM(a));
|
|
32
35
|
|
|
33
36
|
return ary;
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
|
|
36
40
|
void gd_define_pixel(VALUE cGDImage) {
|
|
37
41
|
rb_define_method(cGDImage, "set_pixel", gd_image_set_pixel, 3);
|
|
38
42
|
rb_define_method(cGDImage, "get_pixel", gd_image_get_pixel, 2);
|
data/ext/gd/pixel.o
CHANGED
|
Binary file
|
data/ext/gd/rectangle.c
CHANGED
|
@@ -7,11 +7,7 @@ static VALUE gd_image_rect(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, V
|
|
|
7
7
|
gd_image_wrapper *wrap;
|
|
8
8
|
TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
|
|
9
9
|
|
|
10
|
-
int
|
|
11
|
-
int g = NUM2INT(rb_ary_entry(color, 1));
|
|
12
|
-
int b = NUM2INT(rb_ary_entry(color, 2));
|
|
13
|
-
|
|
14
|
-
int c = gdImageColorAllocate(wrap->img, r, g, b);
|
|
10
|
+
int c = color_to_gd(wrap->img, color);
|
|
15
11
|
gdImageRectangle(wrap->img,
|
|
16
12
|
NUM2INT(x1), NUM2INT(y1),
|
|
17
13
|
NUM2INT(x2), NUM2INT(y2),
|
|
@@ -23,11 +19,7 @@ static VALUE gd_image_filled_rect(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALU
|
|
|
23
19
|
gd_image_wrapper *wrap;
|
|
24
20
|
TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
|
|
25
21
|
|
|
26
|
-
int
|
|
27
|
-
int g = NUM2INT(rb_ary_entry(color, 1));
|
|
28
|
-
int b = NUM2INT(rb_ary_entry(color, 2));
|
|
29
|
-
|
|
30
|
-
int c = gdImageColorAllocate(wrap->img, r, g, b);
|
|
22
|
+
int c = color_to_gd(wrap->img, color);
|
|
31
23
|
gdImageFilledRectangle(wrap->img,
|
|
32
24
|
NUM2INT(x1), NUM2INT(y1),
|
|
33
25
|
NUM2INT(x2), NUM2INT(y2),
|
data/ext/gd/rectangle.o
CHANGED
|
Binary file
|
data/ext/gd/text.c
CHANGED
|
@@ -19,11 +19,7 @@ static VALUE gd_image_text(VALUE self, VALUE text, VALUE opts) {
|
|
|
19
19
|
if (NIL_P(x) || NIL_P(y) || NIL_P(size) || NIL_P(color) || NIL_P(font))
|
|
20
20
|
rb_raise(rb_eArgError, "missing options");
|
|
21
21
|
|
|
22
|
-
int
|
|
23
|
-
int g = NUM2INT(rb_ary_entry(color,1));
|
|
24
|
-
int b = NUM2INT(rb_ary_entry(color,2));
|
|
25
|
-
|
|
26
|
-
int fg = gdImageColorAllocate(wrap->img, r, g, b);
|
|
22
|
+
int fg = color_to_gd(wrap->img, color);
|
|
27
23
|
|
|
28
24
|
int brect[8];
|
|
29
25
|
char *err = gdImageStringFT(
|
data/ext/gd/text.o
CHANGED
|
Binary file
|
data/lib/gd/gd.so
ADDED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-libgd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Germán Alberto Giménez Silva
|
|
@@ -66,6 +66,7 @@ files:
|
|
|
66
66
|
- ext/gd/version.c
|
|
67
67
|
- ext/gd/version.o
|
|
68
68
|
- lib/gd.rb
|
|
69
|
+
- lib/gd/gd.so
|
|
69
70
|
homepage: https://github.com/ggerman/ruby-libgd
|
|
70
71
|
licenses:
|
|
71
72
|
- MIT
|