ruby-libgd 0.3.1 → 0.3.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gd/gd.so +0 -0
  3. data/ext/gd/image.c +36 -0
  4. data/ext/gd/image.o +0 -0
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12ec2b7cee7423c19cf4573b065068ea7503ab69411969866c98bde8013af909
4
- data.tar.gz: 0f1d9c044ca898bfa02cebc4c0e10bdb8894fb08cf9e6c48bf4a2f02da46fb3f
3
+ metadata.gz: d318d5d92026ec9ece18021d3cecef81707d64bfe134856d73f5ee007872ac89
4
+ data.tar.gz: 11b4e17352cd1ff477478297b2a3004f13760dc001b8ac04ee6b6a082feac04e
5
5
  SHA512:
6
- metadata.gz: b173710ef6a9bd66c964dfddded870406e8f9b833c4fcb5bba4a09dace6a92790ebb56ebc45dbb59c2b96dc7d66878965930dcf7e29c237755d548c0397455a5
7
- data.tar.gz: d61159864c2ed251d0e072fc3951ad7a8ab3a7ba505cf584bd6e9390e3c0b0f94f76dbcc7452940caf62de4dabbf84f0e853fdb9b846d6a7b614cbd0280982f9
6
+ metadata.gz: 4a6719d7ddcc0c9cda1ec061e57a021c5ea729003764e62e19c327ddea77a3160d1f36f6953e8d8c54d6d9e946333347c5093668ea6670a65af468aeb61a3f92
7
+ data.tar.gz: 0c4ba9ea4e0b4faed88aefcebe0164edfc4ab9722113914eeecd024863bedb187c6c4f2936a6822af0ad32b6f41b7d31fcdd781f35fdb1d3114888d8940c1e35
data/ext/gd/gd.so CHANGED
Binary file
data/ext/gd/image.c CHANGED
@@ -48,6 +48,41 @@ static VALUE gd_image_initialize(int argc, VALUE *argv, VALUE self) {
48
48
  return self;
49
49
  }
50
50
 
51
+ static VALUE gd_image_initialize_true_color(VALUE self, VALUE width, VALUE height) {
52
+ gd_image_wrapper *wrap;
53
+ TypedData_Get_Struct(self, gd_image_wrapper, &gd_image_type, wrap);
54
+
55
+ if (wrap->img) {
56
+ gdImageDestroy(wrap->img);
57
+ }
58
+
59
+ int w = NUM2INT(width);
60
+ int h = NUM2INT(height);
61
+ if (w <= 0 || h <= 0) {
62
+ rb_raise(rb_eArgError, "width and height must be positive");
63
+ }
64
+
65
+ wrap->img = gdImageCreateTrueColor(w, h);
66
+ if (!wrap->img) {
67
+ rb_raise(rb_eRuntimeError, "failed to create true color image");
68
+ }
69
+
70
+ // Opcional: desactivar el fondo transparente si no lo necesitas
71
+ gdImageSaveAlpha(wrap->img, 1);
72
+ gdImageAlphaBlending(wrap->img, 0);
73
+
74
+ int t = gdTrueColorAlpha(0,0,0,127);
75
+ gdImageFilledRectangle(wrap->img, 0,0, w-1, h-1, t);
76
+
77
+ return self;
78
+ }
79
+
80
+ static VALUE gd_image_s_new_true_color(VALUE klass, VALUE width, VALUE height) {
81
+ VALUE img = rb_obj_alloc(klass);
82
+ rb_funcall(img, rb_intern("initialize"), 2, width, height);
83
+ return img;
84
+ }
85
+
51
86
  /* ---------------------------------------------------------
52
87
  * initialize_copy (correct way for clone/dup)
53
88
  * --------------------------------------------------------- */
@@ -303,6 +338,7 @@ void gd_define_image(VALUE mGD) {
303
338
  rb_define_method(cGDImage, "copy", gd_image_copy, 7);
304
339
 
305
340
  rb_define_singleton_method(cGDImage, "open", gd_image_open, 1);
341
+ rb_define_singleton_method(cGDImage, "new_true_color", gd_image_s_new_true_color, 2);
306
342
 
307
343
  rb_define_method(cGDImage, "alpha_blending=", gd_image_alpha_blending, 1);
308
344
  rb_define_method(cGDImage, "save_alpha=", gd_image_save_alpha, 1);
data/ext/gd/image.o CHANGED
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Germán Alberto Giménez Silva