pixbufutils 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/ext/pixbufutils/filter.h +22 -22
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ba2ec614619680bd44bf1e4c122ba3b8dc1c830
4
- data.tar.gz: 41112646a90c2c68aa2f2f8da9750732e83130d5
3
+ metadata.gz: 21a112cea7c4b07cad4965b3826547d21e49d700
4
+ data.tar.gz: 5b7866be086861252f435f41533950bc3f468f7c
5
5
  SHA512:
6
- metadata.gz: 524e1a045190ed226aa85f41e72051e509cc9dbc7d6d60004f0e6ff3c90cc7d204648eef0887a604c5e415a90e45e6172d5ff040b619dcc26a74047212d1cd66
7
- data.tar.gz: dd0d72083538fd27eb43d72a391420b61bc3c3b00bc62a3181bd29b18f959e47f55c21a21e9a9de9401ec0fa45e71dd20dc29a07883f6548f930158b3fac7b86
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.4"
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")
@@ -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] = (unsigned char) MAX(MIN(mod + sp[0], 255), 0);
43
- dp[1] = (unsigned char) MAX(MIN(mod + sp[1], 255), 0);
44
- dp[2] = (unsigned char) MAX(MIN(mod + sp[2], 255), 0);
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] = (unsigned char) MAX(MIN(sp[0] + ( max - sp[0] ) * mod , 255), 0);
192
+ dp[0] = pix_value(sp[0] + ( max - sp[0] ) * mod);
193
193
  if (max != sp[1])
194
- dp[1] = (unsigned char) MAX(MIN(sp[1] + ( max - sp[1] ) * mod , 255), 0);
194
+ dp[1] = pix_value(sp[1] + ( max - sp[1] ) * mod);
195
195
  if (max != sp[2])
196
- dp[2] = (unsigned char) MAX(MIN(sp[2] + ( max - sp[2] ) * mod , 255), 0);
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] = (unsigned char) MAX(MIN(127 + ( (((double)sp[0]) - 127) * mod ), 255), 0);
251
- dp[1] = (unsigned char) MAX(MIN(127 + ( (((double)sp[1]) - 127) * mod ), 255), 0);
252
- dp[2] = (unsigned char) MAX(MIN(127 + ( (((double)sp[2]) - 127) * mod ), 255), 0);
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] = (unsigned char)MIN(MAX(sum_red, 0.0), 255.0); /* red */
358
- dp[1] = (unsigned char)MIN(MAX(sum_green, 0.0), 255.0); /* green */
359
- dp[2] = (unsigned char)MIN(MAX(sum_blue, 0.0), 255.0); /* blue */
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
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixbufutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Youngs