ruby-libgd 0.1.5 → 0.1.6
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/filter.c +26 -0
- data/ext/gd/filter.o +0 -0
- data/ext/gd/gd.so +0 -0
- data/lib/gd.rb +14 -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: 4654b62899e8c7bc35cded648fdc90b550121c5b0652ec7a53ccf7548afac59b
|
|
4
|
+
data.tar.gz: c3bb9bdb80cde240e99fef79a554e5a5765e64171ee9934f3e48e93798dc85df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94789cb7afd59af7207cc9884a18d3fa38e031ad9a8b0e6ba989a15ffc760eb9331a08402a21ad0106ddf643bd2a0e33a1ae9b4e430fdc457243b4836e8e4234
|
|
7
|
+
data.tar.gz: 671827da51d580b188e3d0344ee2e1218a09e11c37ab879d2f70d56a12d45483cd85813ec69fdfd9985122d3a4836b71a4377b43dfd59e0ed19e0c5b21504c4b
|
data/ext/gd/filter.c
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
#include "ruby_gd.h"
|
|
2
2
|
#include <string.h>
|
|
3
3
|
|
|
4
|
+
static void gd_image_apply_sepia(gdImagePtr img) {
|
|
5
|
+
int x, y;
|
|
6
|
+
for (y = 0; y < img->sy; y++) {
|
|
7
|
+
for (x = 0; x < img->sx; x++) {
|
|
8
|
+
int c = gdImageGetTrueColorPixel(img, x, y);
|
|
9
|
+
|
|
10
|
+
int r = gdTrueColorGetRed(c);
|
|
11
|
+
int g = gdTrueColorGetGreen(c);
|
|
12
|
+
int b = gdTrueColorGetBlue(c);
|
|
13
|
+
|
|
14
|
+
int tr = (int)(0.393*r + 0.769*g + 0.189*b);
|
|
15
|
+
int tg = (int)(0.349*r + 0.686*g + 0.168*b);
|
|
16
|
+
int tb = (int)(0.272*r + 0.534*g + 0.131*b);
|
|
17
|
+
|
|
18
|
+
if (tr > 255) tr = 255;
|
|
19
|
+
if (tg > 255) tg = 255;
|
|
20
|
+
if (tb > 255) tb = 255;
|
|
21
|
+
|
|
22
|
+
gdImageSetPixel(img, x, y, gdTrueColor(tr, tg, tb));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
4
27
|
static VALUE gd_image_filter(int argc, VALUE *argv, VALUE self) {
|
|
5
28
|
VALUE type, arg1, arg2, arg3, arg4;
|
|
6
29
|
rb_scan_args(argc, argv, "14", &type, &arg1, &arg2, &arg3, &arg4);
|
|
@@ -58,6 +81,9 @@ static VALUE gd_image_filter(int argc, VALUE *argv, VALUE self) {
|
|
|
58
81
|
NUM2INT(arg2)
|
|
59
82
|
);
|
|
60
83
|
}
|
|
84
|
+
else if (strcmp(name, "sepia") == 0) {
|
|
85
|
+
gd_image_apply_sepia(wrap->img);
|
|
86
|
+
}
|
|
61
87
|
else {
|
|
62
88
|
rb_raise(rb_eArgError, "unknown filter");
|
|
63
89
|
}
|
data/ext/gd/filter.o
CHANGED
|
Binary file
|
data/ext/gd/gd.so
CHANGED
|
Binary file
|
data/lib/gd.rb
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
require "gd/gd"
|
|
2
2
|
|
|
3
|
+
class GD::Image
|
|
4
|
+
DEFAULT_FONT = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
|
|
5
|
+
DEFAULT_FONT_SIZE = 12
|
|
6
|
+
|
|
7
|
+
def draw_string(x, y, text, color, size: DEFAULT_FONT_SIZE, font: DEFAULT_FONT)
|
|
8
|
+
self.text(text, {
|
|
9
|
+
x: x,
|
|
10
|
+
y: y,
|
|
11
|
+
size: size,
|
|
12
|
+
color: color,
|
|
13
|
+
font: font
|
|
14
|
+
})
|
|
15
|
+
end
|
|
16
|
+
end
|
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.6
|
|
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-06 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.
|