ruby-libgd 0.1.6 → 0.1.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/gd/color.c +14 -2
- data/ext/gd/color.o +0 -0
- data/ext/gd/draw_line.c +2 -2
- data/ext/gd/draw_line.o +0 -0
- data/ext/gd/gd.so +0 -0
- data/ext/gd/image.c +49 -1
- data/ext/gd/image.o +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6bebe9c1a521b1a7e5fc50f31a6abc29d0b075de0fa6761d8673ccfb9870b958
|
|
4
|
+
data.tar.gz: 452861ff154b42c8618d891bf43cdaee7ac2c75f8376760a3225d432d0956914
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a9ce11ae3c04fed19b4a5d8d44f4069acecf46df5f7bf3797bc2cb032d382a638eff535a932bb0d3f6ff4be26ba636cf55166ff0471674573951a2cc4825b40
|
|
7
|
+
data.tar.gz: 5e0cbcdda5264574fb65b76273dbee942f55f03299cef0b3a091c5bff9528d5a773e58027e165f88933cfb5c122460dc4cb8b5bbe8bb8848e25e2f9a6d653b5e
|
data/ext/gd/color.c
CHANGED
|
@@ -12,12 +12,24 @@ int color_to_gd(gdImagePtr im, VALUE color) {
|
|
|
12
12
|
if (gdImageTrueColor(im)) {
|
|
13
13
|
if (RARRAY_LEN(color) >= 4) {
|
|
14
14
|
int a = NUM2INT(rb_ary_entry(color, 3));
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
if (a < 0) a = 0;
|
|
17
|
+
if (a > 255) a = 255;
|
|
18
|
+
|
|
19
|
+
int gd_a = (a * 127) / 255;
|
|
20
|
+
|
|
21
|
+
return gdTrueColorAlpha(r, g, b, gd_a);
|
|
16
22
|
}
|
|
17
23
|
return gdTrueColor(r,g,b);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
if (RARRAY_LEN(color) >= 4) {
|
|
27
|
+
int a = NUM2INT(rb_ary_entry(color, 3));
|
|
28
|
+
int gd_a = (a * 127) / 255;
|
|
29
|
+
return gdImageColorAllocateAlpha(im, r, g, b, gd_a);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return gdImageColorAllocate(im, r, g, b);
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
static VALUE gd_color_rgb(VALUE self, VALUE r, VALUE g, VALUE b) {
|
data/ext/gd/color.o
CHANGED
|
Binary file
|
data/ext/gd/draw_line.c
CHANGED
|
@@ -44,8 +44,8 @@ static VALUE gd_image_line(int argc, VALUE *argv, VALUE self) {
|
|
|
44
44
|
rb_warn("Line coordinates clipped to image bounds");
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (TYPE(color) != T_ARRAY || RARRAY_LEN(color)
|
|
48
|
-
rb_raise(rb_eArgError, "color must be [r,g,b]");
|
|
47
|
+
if (TYPE(color) != T_ARRAY || RARRAY_LEN(color) < 3 || RARRAY_LEN(color) > 4) {
|
|
48
|
+
rb_raise(rb_eArgError, "color must be [r,g,b] or [r,g,b,a]");
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
int c = color_to_gd(wrap->img, color);
|
data/ext/gd/draw_line.o
CHANGED
|
Binary file
|
data/ext/gd/gd.so
CHANGED
|
Binary file
|
data/ext/gd/image.c
CHANGED
|
@@ -19,8 +19,9 @@ 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
|
+
|
|
23
|
+
gdImageAlphaBlending(wrap->img, 1);
|
|
22
24
|
gdImageSaveAlpha(wrap->img, 1);
|
|
23
|
-
gdImageAlphaBlending(wrap->img, 0);
|
|
24
25
|
|
|
25
26
|
int t = gdTrueColorAlpha(0,0,0,127);
|
|
26
27
|
gdImageFilledRectangle(wrap->img, 0, 0, w-1, h-1, t);
|
|
@@ -219,6 +220,52 @@ static VALUE gd_image_copy (
|
|
|
219
220
|
return Qnil;
|
|
220
221
|
}
|
|
221
222
|
|
|
223
|
+
static VALUE gd_image_copy_resize(int argc, VALUE *argv, VALUE self) {
|
|
224
|
+
VALUE src_img;
|
|
225
|
+
VALUE dst_x, dst_y, src_x, src_y, src_w, src_h, dst_w, dst_h, resample;
|
|
226
|
+
|
|
227
|
+
rb_scan_args(argc, argv, "91",
|
|
228
|
+
&src_img, &dst_x, &dst_y, &src_x, &src_y,
|
|
229
|
+
&src_w, &src_h, &dst_w, &dst_h,
|
|
230
|
+
&resample
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
gd_image_wrapper *dst, *src;
|
|
234
|
+
TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, dst);
|
|
235
|
+
TypedData_Get_Struct(src_img, gd_image_wrapper, &gd_image_type, src);
|
|
236
|
+
|
|
237
|
+
int dx = NUM2INT(dst_x);
|
|
238
|
+
int dy = NUM2INT(dst_y);
|
|
239
|
+
int sx = NUM2INT(src_x);
|
|
240
|
+
int sy = NUM2INT(src_y);
|
|
241
|
+
int sw = NUM2INT(src_w);
|
|
242
|
+
int sh = NUM2INT(src_h);
|
|
243
|
+
int dw = NUM2INT(dst_w);
|
|
244
|
+
int dh = NUM2INT(dst_h);
|
|
245
|
+
|
|
246
|
+
int do_resample = RTEST(resample);
|
|
247
|
+
|
|
248
|
+
if (do_resample) {
|
|
249
|
+
gdImageCopyResampled(
|
|
250
|
+
dst->img, src->img,
|
|
251
|
+
dx, dy,
|
|
252
|
+
sx, sy,
|
|
253
|
+
dw, dh,
|
|
254
|
+
sw, sh
|
|
255
|
+
);
|
|
256
|
+
} else {
|
|
257
|
+
gdImageCopyResized(
|
|
258
|
+
dst->img, src->img,
|
|
259
|
+
dx, dy,
|
|
260
|
+
sx, sy,
|
|
261
|
+
dw, dh,
|
|
262
|
+
sw, sh
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return self;
|
|
267
|
+
}
|
|
268
|
+
|
|
222
269
|
void gd_define_image(VALUE mGD) {
|
|
223
270
|
VALUE cGDImage = rb_define_class_under(mGD, "Image", rb_cObject);
|
|
224
271
|
|
|
@@ -227,6 +274,7 @@ void gd_define_image(VALUE mGD) {
|
|
|
227
274
|
rb_define_method(cGDImage, "width", gd_image_width, 0);
|
|
228
275
|
rb_define_method(cGDImage, "height", gd_image_height, 0);
|
|
229
276
|
rb_define_method(cGDImage, "initialize", gd_image_initialize, -1);
|
|
277
|
+
rb_define_method(cGDImage, "copy_resize", gd_image_copy_resize, -1);
|
|
230
278
|
rb_define_method(cGDImage, "copy", gd_image_copy, 7);
|
|
231
279
|
rb_define_method(cGDImage, "clone", gd_image_clone, 0);
|
|
232
280
|
rb_define_singleton_method(cGDImage, "open", gd_image_open, 1);
|
data/ext/gd/image.o
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Germán Alberto Giménez Silva
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: High-performance native Ruby bindings to libgd for image generation,
|
|
14
14
|
drawing, filters, alpha blending, and transformations.
|