pixbufutils 0.0.4 → 0.0.5
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/Rakefile +1 -1
- data/ext/pixbufutils/filter.h +22 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21a112cea7c4b07cad4965b3826547d21e49d700
|
4
|
+
data.tar.gz: 5b7866be086861252f435f41533950bc3f468f7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 818a614285c9296209c11404f86230ffe8ea19578e1434f4e288d96272f9c25114f17c1610e39af82ed762361fdba1f8e22ac099825475e70aade5936e41303f
|
7
|
+
data.tar.gz: 16c6272eb52737e78fc44a15337c369b45f7983cd26e6ba92090bc0bf653971ae233c29cf0bc3d5f5e767dd47a21b146e5e3914d4b4696abac1e7354697fe768
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ spec = Gem::Specification.new do |s|
|
|
22
22
|
s.name = "pixbufutils"
|
23
23
|
s.author = "Geoff Youngs"
|
24
24
|
s.email = "git@intersect-uk.co.uk"
|
25
|
-
s.version = "0.0.
|
25
|
+
s.version = "0.0.5"
|
26
26
|
s.homepage = "http://github.com/geoffyoungs/pixbufutils"
|
27
27
|
s.summary = "Additional utils for Gdk::Pixbuf"
|
28
28
|
s.add_dependency("rubber-generate", ">= 0.0.17")
|
data/ext/pixbufutils/filter.h
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
#include <math.h>
|
2
2
|
|
3
|
+
inline unsigned char pix_value(int value)
|
4
|
+
{
|
5
|
+
if (value < 0)
|
6
|
+
return 0;
|
7
|
+
if (value > 255)
|
8
|
+
return 255;
|
9
|
+
return (unsigned char) value;
|
10
|
+
}
|
11
|
+
|
3
12
|
static GdkPixbuf *pixbuf_adjust_brightness(GdkPixbuf *src, GdkPixbuf *dest, int adjust) {
|
4
13
|
int s_has_alpha, d_has_alpha;
|
5
14
|
int s_width, s_height, s_rowstride;
|
@@ -7,7 +16,7 @@ static GdkPixbuf *pixbuf_adjust_brightness(GdkPixbuf *src, GdkPixbuf *dest, int
|
|
7
16
|
guchar *s_pix, *sp;
|
8
17
|
guchar *d_pix, *dp;
|
9
18
|
int i, j, pix_width;
|
10
|
-
int mod = (int) floor(255 * (adjust/100));
|
19
|
+
int mod = (int) floor(255 * ((double)adjust/100.0));
|
11
20
|
|
12
21
|
|
13
22
|
g_return_val_if_fail(src != NULL, NULL);
|
@@ -39,9 +48,9 @@ static GdkPixbuf *pixbuf_adjust_brightness(GdkPixbuf *src, GdkPixbuf *dest, int
|
|
39
48
|
|
40
49
|
for (j = 0; j < s_width; j++) {
|
41
50
|
|
42
|
-
dp[0] = (
|
43
|
-
dp[1] = (
|
44
|
-
dp[2] = (
|
51
|
+
dp[0] = pix_value(mod + sp[0]);
|
52
|
+
dp[1] = pix_value(mod + sp[1]);
|
53
|
+
dp[2] = pix_value(mod + sp[2]);
|
45
54
|
|
46
55
|
if (s_has_alpha)
|
47
56
|
{
|
@@ -59,15 +68,6 @@ static GdkPixbuf *pixbuf_adjust_brightness(GdkPixbuf *src, GdkPixbuf *dest, int
|
|
59
68
|
return dest;
|
60
69
|
}
|
61
70
|
|
62
|
-
inline unsigned char pix_value(int value)
|
63
|
-
{
|
64
|
-
if (value < 0)
|
65
|
-
return 0;
|
66
|
-
if (value > 255)
|
67
|
-
return 255;
|
68
|
-
return (unsigned char) value;
|
69
|
-
}
|
70
|
-
|
71
71
|
static GdkPixbuf *pixbuf_adjust_saturation(GdkPixbuf *src, GdkPixbuf *dest, int adjust) {
|
72
72
|
int s_has_alpha, d_has_alpha;
|
73
73
|
int s_width, s_height, s_rowstride;
|
@@ -189,11 +189,11 @@ static GdkPixbuf *pixbuf_adjust_vibrance(GdkPixbuf *src, GdkPixbuf *dest, int ad
|
|
189
189
|
mod = ((abs(max - avg) * 2/255) * -1 * adjust) / 100.0;
|
190
190
|
|
191
191
|
if (max != sp[0])
|
192
|
-
dp[0] = (
|
192
|
+
dp[0] = pix_value(sp[0] + ( max - sp[0] ) * mod);
|
193
193
|
if (max != sp[1])
|
194
|
-
dp[1] = (
|
194
|
+
dp[1] = pix_value(sp[1] + ( max - sp[1] ) * mod);
|
195
195
|
if (max != sp[2])
|
196
|
-
dp[2] = (
|
196
|
+
dp[2] = pix_value(sp[2] + ( max - sp[2] ) * mod);
|
197
197
|
|
198
198
|
if (s_has_alpha)
|
199
199
|
{
|
@@ -247,9 +247,9 @@ static GdkPixbuf *pixbuf_adjust_contrast(GdkPixbuf *src, GdkPixbuf *dest, int ad
|
|
247
247
|
|
248
248
|
for (j = 0; j < s_width; j++) {
|
249
249
|
|
250
|
-
dp[0] = (
|
251
|
-
dp[1] = (
|
252
|
-
dp[2] = (
|
250
|
+
dp[0] = pix_value(127 + ( (((double)sp[0]) - 127) * mod ));
|
251
|
+
dp[1] = pix_value(127 + ( (((double)sp[1]) - 127) * mod ));
|
252
|
+
dp[2] = pix_value(127 + ( (((double)sp[2]) - 127) * mod ));
|
253
253
|
|
254
254
|
if (s_has_alpha)
|
255
255
|
{
|
@@ -354,9 +354,9 @@ static GdkPixbuf *pixbuf_convolution_matrix(GdkPixbuf *src, GdkPixbuf *dest, int
|
|
354
354
|
sum_green /= divisor;
|
355
355
|
sum_blue /= divisor;
|
356
356
|
|
357
|
-
dp[0] = (
|
358
|
-
dp[1] = (
|
359
|
-
dp[2] = (
|
357
|
+
dp[0] = pix_value(sum_red); /* red */
|
358
|
+
dp[1] = pix_value(sum_green); /* green */
|
359
|
+
dp[2] = pix_value(sum_blue); /* blue */
|
360
360
|
|
361
361
|
if (s_has_alpha)
|
362
362
|
{
|