redeye 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/ext/redeye/extconf.rb +10 -3
- data/ext/redeye/redeye.c +122 -133
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14edbfbfa5f297a73aea39eae3813550cc4f9d02
|
4
|
+
data.tar.gz: db0a0e1e5b1e83e9247fb945a087ce0493911cef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf5b50e6a59a95004483cf830dec668d4667e5f6decf28dd13636c30626be3b5af4431de6341d484c1cbfe22f086955fe920af0589b56c5d310e28698620ecd8
|
7
|
+
data.tar.gz: f155537cc657d438dce1a154dc91ffd24f5d73d4513a62c1f25fc62ea5714d8875322cbd40bf05bf740d38df0aae83b9d7afa91efc852f2ae91912587734e771
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ spec = Gem::Specification.new do |s|
|
|
22
22
|
s.name = "redeye"
|
23
23
|
s.author = "Geoff Youngs"
|
24
24
|
s.email = "git@intersect-uk.co.uk"
|
25
|
-
s.version = "1.0.
|
25
|
+
s.version = "1.0.3"
|
26
26
|
s.homepage = "http://github.com/geoffyoungs/redeye"
|
27
27
|
s.summary = "Redeye correction for Gdk::Pixbuf"
|
28
28
|
s.add_dependency("rubber-generate", ">= 0.0.17")
|
data/ext/redeye/extconf.rb
CHANGED
@@ -19,7 +19,7 @@ end
|
|
19
19
|
# Look for headers in {gem_root}/ext/{package}
|
20
20
|
if use_gems
|
21
21
|
%w[
|
22
|
-
glib2
|
22
|
+
glib2].each do |package|
|
23
23
|
require package
|
24
24
|
if Gem.loaded_specs[package]
|
25
25
|
$CFLAGS += " -I" + Gem.loaded_specs[package].full_gem_path + "/ext/" + package
|
@@ -40,8 +40,15 @@ end
|
|
40
40
|
|
41
41
|
$CFLAGS += " -I."
|
42
42
|
have_func("rb_errinfo")
|
43
|
-
PKGConfig.have_package("
|
44
|
-
|
43
|
+
PKGConfig.have_package("gdk-pixbuf-2.0") or exit(-1)
|
44
|
+
|
45
|
+
unless have_header("gdk-pixbuf/gdk-pixbuf.h")
|
46
|
+
paths = Gem.find_files("gdk-pixbuf/gdk-pixbuf.h")
|
47
|
+
paths.each do |path|
|
48
|
+
$CFLAGS += " '-I#{File.dirname(path)}'"
|
49
|
+
end
|
50
|
+
have_header("gdk-pixbuf/gdk-pixbuf.h") or exit -1
|
51
|
+
end
|
45
52
|
|
46
53
|
STDOUT.print("checking for new allocation framework... ") # for ruby-1.7
|
47
54
|
if Object.respond_to? :allocate
|
data/ext/redeye/redeye.c
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
2
|
-
/* Includes */
|
3
|
-
#include <ruby.h>
|
4
|
-
#include <stdlib.h>
|
5
|
-
#include <stdio.h>
|
6
|
-
#include <string.h>
|
2
|
+
/* Includes */
|
3
|
+
#include <ruby.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
#include <stdio.h>
|
6
|
+
#include <string.h>
|
7
|
+
#if defined GCC
|
8
|
+
#define OPTIONAL_ATTR __attribute__((unused))
|
9
|
+
#else
|
10
|
+
#define OPTIONAL_ATTR
|
11
|
+
#endif
|
7
12
|
#include "gdk-pixbuf/gdk-pixbuf.h"
|
8
13
|
|
9
14
|
/* Setup types */
|
@@ -14,39 +19,23 @@ typedef int rubber_bool;
|
|
14
19
|
/* Prototypes */
|
15
20
|
#include "rbglib.h"
|
16
21
|
|
17
|
-
#include "rbgtk.h"
|
18
|
-
|
19
|
-
#if defined(G_PLATFORM_WIN32) && !defined(RUBY_GTK2_STATIC_COMPILATION)
|
20
|
-
# ifdef RUBY_GTK2_COMPILATION
|
21
|
-
# define RUBY_GTK2_VAR __declspec(dllexport)
|
22
|
-
# else
|
23
|
-
# define RUBY_GTK2_VAR extern __declspec(dllimport)
|
24
|
-
# endif
|
25
|
-
#else
|
26
|
-
# define RUBY_GTK2_VAR extern
|
27
|
-
#endif
|
28
|
-
|
29
|
-
RUBY_GTK2_VAR VALUE mGtk;
|
30
|
-
RUBY_GTK2_VAR VALUE mGdk;
|
31
|
-
|
32
|
-
#define RBGTK_INITIALIZE(obj,gtkobj) (rbgtk_initialize_gtkobject(obj, GTK_OBJECT(gtkobj)))
|
33
22
|
static VALUE cRedEye;
|
34
23
|
static VALUE
|
35
|
-
RedEye___alloc__(VALUE self);
|
24
|
+
RedEye___alloc__(VALUE self OPTIONAL_ATTR );
|
36
25
|
static VALUE
|
37
|
-
RedEye_initialize(VALUE self, VALUE __v_pixbuf, VALUE __v_minX, VALUE __v_minY, VALUE __v_maxX, VALUE __v_maxY);
|
26
|
+
RedEye_initialize(VALUE self OPTIONAL_ATTR , VALUE __v_pixbuf OPTIONAL_ATTR, VALUE __v_minX OPTIONAL_ATTR, VALUE __v_minY OPTIONAL_ATTR, VALUE __v_maxX OPTIONAL_ATTR, VALUE __v_maxY OPTIONAL_ATTR);
|
38
27
|
static VALUE
|
39
28
|
RedEye_identify_blobs(int __p_argc, VALUE *__p_argv, VALUE self);
|
40
29
|
static VALUE
|
41
|
-
RedEye_correct_blob(VALUE self, VALUE __v_blob_id);
|
30
|
+
RedEye_correct_blob(VALUE self OPTIONAL_ATTR , VALUE __v_blob_id OPTIONAL_ATTR);
|
42
31
|
static VALUE
|
43
32
|
RedEye_highlight_blob(int __p_argc, VALUE *__p_argv, VALUE self);
|
44
33
|
static VALUE
|
45
34
|
RedEye_preview_blob(int __p_argc, VALUE *__p_argv, VALUE self);
|
46
35
|
static VALUE
|
47
|
-
RedEye_preview(VALUE self);
|
36
|
+
RedEye_preview(VALUE self OPTIONAL_ATTR );
|
48
37
|
static VALUE
|
49
|
-
RedEye_pixbuf(VALUE self);
|
38
|
+
RedEye_pixbuf(VALUE self OPTIONAL_ATTR );
|
50
39
|
static VALUE structRegion;
|
51
40
|
|
52
41
|
/* Inline C code */
|
@@ -80,59 +69,59 @@ typedef struct {
|
|
80
69
|
|
81
70
|
#define MIN_RED_VAL 20
|
82
71
|
|
83
|
-
static inline VALUE
|
72
|
+
static inline VALUE
|
84
73
|
unref_pixbuf(GdkPixbuf *pixbuf)
|
85
74
|
{
|
86
75
|
volatile VALUE pb = Qnil;
|
87
|
-
|
76
|
+
|
88
77
|
pb = GOBJ2RVAL(pixbuf);
|
89
|
-
|
78
|
+
|
90
79
|
g_object_unref(pixbuf);
|
91
|
-
|
80
|
+
|
92
81
|
return pb;
|
93
82
|
}
|
94
83
|
|
95
84
|
static void identify_possible_redeye_pixels(redeyeop_t *op,
|
96
85
|
double green_sensitivity, double blue_sensitivity,
|
97
|
-
int min_red_val)
|
86
|
+
int min_red_val)
|
98
87
|
{
|
99
88
|
guchar *data = gdk_pixbuf_get_pixels(op->pixbuf);
|
100
89
|
int rowstride = gdk_pixbuf_get_rowstride(op->pixbuf);
|
101
90
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->pixbuf) ? 4 : 3;
|
102
|
-
|
91
|
+
|
103
92
|
int y, ry = 0, x, rx = 0;
|
104
93
|
for ( y = op->area.minY; y < op->area.maxY; y++ )
|
105
94
|
{
|
106
95
|
guchar *thisLine = data + (rowstride * y);
|
107
96
|
guchar *pixel;
|
108
|
-
|
97
|
+
|
109
98
|
pixel = thisLine + (op->area.minX * pixWidth);
|
110
99
|
rx = 0;
|
111
|
-
|
100
|
+
|
112
101
|
for ( x = op->area.minX; x < op->area.maxX; x++ )
|
113
102
|
{
|
114
|
-
|
103
|
+
|
115
104
|
int r,g,b;
|
116
|
-
|
105
|
+
|
117
106
|
r = pixel[0];
|
118
107
|
g = pixel[1];
|
119
108
|
b = pixel[2];
|
120
|
-
|
109
|
+
|
121
110
|
gboolean threshMet;
|
122
|
-
|
123
|
-
threshMet = (((double)r) > (green_sensitivity * (double)g)) &&
|
124
|
-
(((double)r) > (blue_sensitivity * (double)b)) &&
|
111
|
+
|
112
|
+
threshMet = (((double)r) > (green_sensitivity * (double)g)) &&
|
113
|
+
(((double)r) > (blue_sensitivity * (double)b)) &&
|
125
114
|
(r > min_red_val);
|
126
|
-
|
115
|
+
|
127
116
|
if(threshMet)
|
128
117
|
op->mask[ rx + ry ] = r;
|
129
118
|
else
|
130
119
|
op->mask[ rx + ry ] = 0; /* MEMZERO should have done its job ? */
|
131
|
-
|
120
|
+
|
132
121
|
pixel += pixWidth;
|
133
122
|
rx ++;
|
134
123
|
}
|
135
|
-
|
124
|
+
|
136
125
|
ry += op->area.width;
|
137
126
|
}
|
138
127
|
}
|
@@ -141,17 +130,17 @@ static void identify_possible_redeye_pixels(redeyeop_t *op,
|
|
141
130
|
inline int group_at(redeyeop_t *op, int px, int py)
|
142
131
|
{
|
143
132
|
int index, region;
|
144
|
-
|
133
|
+
|
145
134
|
if (px < 0 || py < 0)
|
146
135
|
return 0;
|
147
|
-
|
136
|
+
|
148
137
|
index = px + ( py * op->area.width );
|
149
|
-
|
138
|
+
|
150
139
|
if (index < 0)
|
151
140
|
return 0;
|
152
141
|
if (index > (op->area.width * op->area.height))
|
153
142
|
return 0;
|
154
|
-
|
143
|
+
|
155
144
|
region = op->regions.data[ index ];
|
156
145
|
if (region > 0) {
|
157
146
|
if (op->regions.region[ region ].mergeWith) {
|
@@ -166,11 +155,11 @@ inline int group_at(redeyeop_t *op, int px, int py)
|
|
166
155
|
|
167
156
|
#define group_for(x,y) group_at(op, x, y)
|
168
157
|
|
169
|
-
static void identify_blob_groupings(redeyeop_t *op)
|
158
|
+
static void identify_blob_groupings(redeyeop_t *op)
|
170
159
|
{
|
171
160
|
volatile int next_blob_id = 1, blob_id, y, x;
|
172
|
-
|
173
|
-
|
161
|
+
|
162
|
+
|
174
163
|
for( y = 0; y < op->area.height; y++ )
|
175
164
|
{
|
176
165
|
for ( x = 0; x < op->area.width; x++ )
|
@@ -180,28 +169,28 @@ static void identify_blob_groupings(redeyeop_t *op)
|
|
180
169
|
int sx, sy, group = 0;
|
181
170
|
// Target pixel is true
|
182
171
|
blob_id = 0;
|
183
|
-
|
172
|
+
|
184
173
|
for (sy = y; sy >= y - 1; sy --) {
|
185
174
|
sx = (sy == y) ? x : x + 1;
|
186
175
|
for (; sx >= (x - 1); sx --) {
|
187
176
|
/*if ((sx >= x) && (sy >= y))
|
188
177
|
goto blob_scan_done;*/
|
189
|
-
|
178
|
+
|
190
179
|
if (sx >= 0 && sy >= 0)
|
191
180
|
group = group_for(sx, sy);
|
192
|
-
|
181
|
+
|
193
182
|
if (group) {
|
194
183
|
existing = TRUE;
|
195
184
|
if (blob_id) {
|
196
185
|
int target = MIN(blob_id, group);
|
197
186
|
int from = MAX(blob_id, group);
|
198
|
-
|
187
|
+
|
199
188
|
if (op->regions.region[target].mergeWith > 0) {
|
200
189
|
// Already merged
|
201
190
|
target = op->regions.region[target].mergeWith;
|
202
191
|
}
|
203
192
|
op->regions.region[from].mergeWith = target;
|
204
|
-
|
193
|
+
|
205
194
|
// Merge blob_id & group
|
206
195
|
}
|
207
196
|
blob_id = group;
|
@@ -220,38 +209,38 @@ static void identify_blob_groupings(redeyeop_t *op)
|
|
220
209
|
op->regions.region[blob_id].height = 1;
|
221
210
|
op->regions.region[blob_id].noPixels = 1;
|
222
211
|
op->regions.region[blob_id].mergeWith = 0;
|
223
|
-
|
212
|
+
|
224
213
|
next_blob_id ++;
|
225
214
|
op->regions.len = next_blob_id;
|
226
|
-
|
215
|
+
|
227
216
|
if (next_blob_id >= op->regions.size) {
|
228
217
|
int extra, new_size;
|
229
|
-
|
218
|
+
|
230
219
|
/*
|
231
220
|
* Realloc in increasingly large chunks to reduce memory fragmentation
|
232
221
|
*/
|
233
222
|
extra = op->regions.size;
|
234
223
|
new_size = op->regions.size + extra;
|
235
|
-
|
224
|
+
|
236
225
|
REALLOC_N(op->regions.region, region_info, new_size);
|
237
|
-
|
226
|
+
|
238
227
|
op->regions.size = new_size;
|
239
228
|
}
|
240
229
|
}
|
241
|
-
|
242
|
-
if (existing)
|
230
|
+
|
231
|
+
if (existing)
|
243
232
|
{
|
244
233
|
op->regions.region[blob_id].minX = MIN(x, op->regions.region[blob_id].minX);
|
245
234
|
op->regions.region[blob_id].maxX = MAX(x, op->regions.region[blob_id].maxX);
|
246
235
|
op->regions.region[blob_id].minY = MIN(y, op->regions.region[blob_id].minY);
|
247
236
|
op->regions.region[blob_id].maxY = MAX(y, op->regions.region[blob_id].maxY);
|
248
|
-
op->regions.region[blob_id].width = op->regions.region[blob_id].maxX -
|
237
|
+
op->regions.region[blob_id].width = op->regions.region[blob_id].maxX -
|
249
238
|
op->regions.region[blob_id].minX + 1;
|
250
|
-
op->regions.region[blob_id].height = op->regions.region[blob_id].maxY -
|
239
|
+
op->regions.region[blob_id].height = op->regions.region[blob_id].maxY -
|
251
240
|
op->regions.region[blob_id].minY + 1;
|
252
241
|
op->regions.region[blob_id].noPixels ++;
|
253
242
|
}
|
254
|
-
|
243
|
+
|
255
244
|
op->regions.data[ x + (y * op->area.width) ] = blob_id;
|
256
245
|
}
|
257
246
|
}
|
@@ -264,14 +253,14 @@ static void identify_blob_groupings(redeyeop_t *op)
|
|
264
253
|
/*
|
265
254
|
if (op->regions.len <= 0xf || 1)
|
266
255
|
{
|
267
|
-
if (g == 0)
|
256
|
+
if (g == 0)
|
268
257
|
fprintf(fp, " ");
|
269
258
|
else
|
270
259
|
fprintf(fp, "%x", g);
|
271
260
|
}
|
272
261
|
else
|
273
262
|
{
|
274
|
-
if (g == 0)
|
263
|
+
if (g == 0)
|
275
264
|
fprintf(fp, " ");
|
276
265
|
else
|
277
266
|
fprintf(fp, "%x ", g);
|
@@ -311,23 +300,23 @@ static void free_redeye(redeyeop_t *ptr)
|
|
311
300
|
inline gboolean in_region(redeyeop_t *op, int x, int y, int blob_id)
|
312
301
|
{
|
313
302
|
int index;
|
314
|
-
|
303
|
+
|
315
304
|
if ( x < op->area.minX || x > op->area.maxX ||
|
316
305
|
y < op->area.minY || y > op->area.maxY )
|
317
306
|
return FALSE;
|
318
|
-
|
307
|
+
|
319
308
|
index = (x - op->area.minX) + ((y - op->area.minY) * op->area.width);
|
320
|
-
|
309
|
+
|
321
310
|
return op->regions.data[index] == blob_id;
|
322
311
|
}
|
323
312
|
|
324
313
|
inline double alpha_level_for_pixel(redeyeop_t *op, int x, int y, int blob_id)
|
325
314
|
{
|
326
315
|
int j = 0, c = 0, xm, ym;
|
327
|
-
|
316
|
+
|
328
317
|
if (in_region(op, x, y, blob_id))
|
329
318
|
return 1.0;
|
330
|
-
|
319
|
+
|
331
320
|
for ( xm = -2; xm <= 2; xm++ )
|
332
321
|
{
|
333
322
|
for ( ym = -2; ym <= 2; ym ++ )
|
@@ -339,7 +328,7 @@ inline double alpha_level_for_pixel(redeyeop_t *op, int x, int y, int blob_id)
|
|
339
328
|
j ++;
|
340
329
|
}
|
341
330
|
}
|
342
|
-
|
331
|
+
|
343
332
|
return ((double)j)/((double)c);
|
344
333
|
}
|
345
334
|
|
@@ -348,7 +337,7 @@ inline char col(double val)
|
|
348
337
|
if (val < 0) return 0;
|
349
338
|
if (val > 255) return 255;
|
350
339
|
return val;
|
351
|
-
|
340
|
+
|
352
341
|
}
|
353
342
|
|
354
343
|
static GdkPixbuf *redeye_preview(redeyeop_t *op, gboolean reset)
|
@@ -356,27 +345,27 @@ static GdkPixbuf *redeye_preview(redeyeop_t *op, gboolean reset)
|
|
356
345
|
int width, height;
|
357
346
|
width = op->area.width;
|
358
347
|
height = op->area.height;
|
359
|
-
|
348
|
+
|
360
349
|
if (width + op->area.minX > gdk_pixbuf_get_width(op->pixbuf)) {
|
361
350
|
width = gdk_pixbuf_get_width(op->pixbuf) - op->area.minX;
|
362
351
|
}
|
363
352
|
if (height + op->area.minY > gdk_pixbuf_get_height(op->pixbuf)) {
|
364
353
|
height = gdk_pixbuf_get_height(op->pixbuf) - op->area.minY;
|
365
354
|
}
|
366
|
-
|
367
|
-
if ( op->preview == NULL )
|
355
|
+
|
356
|
+
if ( op->preview == NULL )
|
368
357
|
{
|
369
358
|
GdkPixbuf *sub = NULL;
|
370
|
-
sub = gdk_pixbuf_new_subpixbuf(op->pixbuf, op->area.minX, op->area.minY,
|
359
|
+
sub = gdk_pixbuf_new_subpixbuf(op->pixbuf, op->area.minX, op->area.minY,
|
371
360
|
width, height);
|
372
|
-
|
361
|
+
|
373
362
|
op->preview = gdk_pixbuf_copy(sub);
|
374
363
|
g_object_unref(sub);
|
375
364
|
} else if (reset) {
|
376
|
-
gdk_pixbuf_copy_area(op->pixbuf, op->area.minX, op->area.minY,
|
365
|
+
gdk_pixbuf_copy_area(op->pixbuf, op->area.minX, op->area.minY,
|
377
366
|
width, height, op->preview, 0, 0);
|
378
367
|
}
|
379
|
-
|
368
|
+
|
380
369
|
return op->preview;
|
381
370
|
}
|
382
371
|
|
@@ -384,35 +373,35 @@ static void desaturate_blob(redeyeop_t *op, int blob_id)
|
|
384
373
|
{
|
385
374
|
int y, x;
|
386
375
|
int minX, minY, maxX, maxY;
|
387
|
-
|
376
|
+
|
388
377
|
minY = MAX(0, op->area.minY + op->regions.region[blob_id].minY - 1);
|
389
|
-
maxY = MIN(op->area.maxY + op->regions.region[blob_id].maxY + 1,
|
378
|
+
maxY = MIN(op->area.maxY + op->regions.region[blob_id].maxY + 1,
|
390
379
|
gdk_pixbuf_get_height(op->pixbuf)-1);
|
391
380
|
minX = MAX(0, op->area.minX + op->regions.region[blob_id].minX - 1);
|
392
|
-
maxX = MIN(op->area.maxX + op->regions.region[blob_id].maxX + 1,
|
381
|
+
maxX = MIN(op->area.maxX + op->regions.region[blob_id].maxX + 1,
|
393
382
|
gdk_pixbuf_get_width(op->pixbuf)-1);
|
394
|
-
|
383
|
+
|
395
384
|
guchar *data = gdk_pixbuf_get_pixels(op->pixbuf);
|
396
385
|
int rowstride = gdk_pixbuf_get_rowstride(op->pixbuf);
|
397
386
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->pixbuf) ? 4 : 3;
|
398
|
-
|
387
|
+
|
399
388
|
for ( y = minY; y <= maxY; y++ )
|
400
389
|
{
|
401
390
|
guchar *thisLine = data + (rowstride * y);
|
402
391
|
guchar *pixel;
|
403
|
-
|
392
|
+
|
404
393
|
pixel = thisLine + (minX * pixWidth);
|
405
|
-
|
394
|
+
|
406
395
|
for ( x = minX; x <= maxX; x++ )
|
407
396
|
{
|
408
|
-
|
397
|
+
|
409
398
|
double alpha = alpha_level_for_pixel(op, x, y, blob_id);
|
410
399
|
int r,g,b,grey;
|
411
|
-
|
400
|
+
|
412
401
|
r = pixel[0];
|
413
402
|
g = pixel[1];
|
414
403
|
b = pixel[2];
|
415
|
-
|
404
|
+
|
416
405
|
if (alpha > 0)
|
417
406
|
{
|
418
407
|
grey = alpha * ((double)( 5 * (double)r + 60 * (double)g + 30 * (double)b)) / 100.0 +
|
@@ -422,11 +411,11 @@ static void desaturate_blob(redeyeop_t *op, int blob_id)
|
|
422
411
|
pixel[1] = col((grey * alpha) + (1-alpha) * g);
|
423
412
|
pixel[2] = col((grey * alpha) + (1-alpha) * b);
|
424
413
|
}
|
425
|
-
|
414
|
+
|
426
415
|
pixel += pixWidth;
|
427
416
|
}
|
428
417
|
}
|
429
|
-
|
418
|
+
|
430
419
|
}
|
431
420
|
|
432
421
|
static void highlight_blob(redeyeop_t *op, int blob_id, int colour)
|
@@ -434,16 +423,16 @@ static void highlight_blob(redeyeop_t *op, int blob_id, int colour)
|
|
434
423
|
int y, x;
|
435
424
|
int minX, minY, maxX, maxY;
|
436
425
|
int hr, hg, hb;
|
437
|
-
|
426
|
+
|
438
427
|
hr = (colour >> 16) & 0xff;
|
439
428
|
hg = (colour >> 8) & 0xff;
|
440
429
|
hb = (colour) & 0xff;
|
441
|
-
|
430
|
+
|
442
431
|
minY = MAX(0, op->area.minY - 1);
|
443
432
|
maxY = MIN(op->area.maxY + 1, gdk_pixbuf_get_height(op->pixbuf)-1);
|
444
433
|
minX = MAX(0, op->area.minX - 1);
|
445
434
|
maxX = MIN(op->area.maxX + 1, gdk_pixbuf_get_width(op->pixbuf)-1);
|
446
|
-
|
435
|
+
|
447
436
|
guchar *data = gdk_pixbuf_get_pixels(op->pixbuf);
|
448
437
|
int rowstride = gdk_pixbuf_get_rowstride(op->pixbuf);
|
449
438
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->pixbuf) ? 4 : 3;
|
@@ -452,32 +441,32 @@ static void highlight_blob(redeyeop_t *op, int blob_id, int colour)
|
|
452
441
|
{
|
453
442
|
guchar *thisLine = data + (rowstride * y);
|
454
443
|
guchar *pixel;
|
455
|
-
|
444
|
+
|
456
445
|
pixel = thisLine + (minX * pixWidth);
|
457
|
-
|
446
|
+
|
458
447
|
for ( x = minX; x <= maxX; x++ )
|
459
448
|
{
|
460
|
-
|
449
|
+
|
461
450
|
double alpha = alpha_level_for_pixel(op, x, y, blob_id);
|
462
451
|
int r,g,b;
|
463
|
-
|
452
|
+
|
464
453
|
r = (pixel[0]);
|
465
454
|
g = (pixel[1]);
|
466
455
|
b = (pixel[2]);
|
467
|
-
|
468
|
-
|
456
|
+
|
457
|
+
|
469
458
|
if (alpha > 0)
|
470
459
|
{
|
471
|
-
|
460
|
+
|
472
461
|
pixel[0] = col((1-alpha) * r + (alpha * hr));
|
473
462
|
pixel[1] = col((1-alpha) * g + (alpha * hg));
|
474
463
|
pixel[2] = col((1-alpha) * b + (alpha * hb));
|
475
464
|
}
|
476
|
-
|
465
|
+
|
477
466
|
pixel += pixWidth;
|
478
467
|
}
|
479
468
|
}
|
480
|
-
|
469
|
+
|
481
470
|
}
|
482
471
|
|
483
472
|
|
@@ -486,18 +475,18 @@ static void preview_blob(redeyeop_t *op, int blob_id, int colour, gboolean reset
|
|
486
475
|
int y, x;
|
487
476
|
int minX, minY, maxX, maxY;
|
488
477
|
int hr, hg, hb;
|
489
|
-
|
478
|
+
|
490
479
|
redeye_preview(op, reset_preview);
|
491
|
-
|
480
|
+
|
492
481
|
hr = (colour >> 16) & 0xff;
|
493
482
|
hg = (colour >> 8) & 0xff;
|
494
483
|
hb = (colour) & 0xff;
|
495
|
-
|
484
|
+
|
496
485
|
minY = 0;
|
497
486
|
maxY = gdk_pixbuf_get_height(op->preview)-1;
|
498
487
|
minX = 0;
|
499
488
|
maxX = gdk_pixbuf_get_width(op->preview)-1;
|
500
|
-
|
489
|
+
|
501
490
|
guchar *data = gdk_pixbuf_get_pixels(op->preview);
|
502
491
|
int rowstride = gdk_pixbuf_get_rowstride(op->preview);
|
503
492
|
int pixWidth = gdk_pixbuf_get_has_alpha(op->preview) ? 4 : 3;
|
@@ -506,40 +495,40 @@ static void preview_blob(redeyeop_t *op, int blob_id, int colour, gboolean reset
|
|
506
495
|
{
|
507
496
|
guchar *thisLine = data + (rowstride * y);
|
508
497
|
guchar *pixel;
|
509
|
-
|
498
|
+
|
510
499
|
pixel = thisLine + (minX * pixWidth);
|
511
|
-
|
500
|
+
|
512
501
|
for ( x = minX; x <= maxX; x++ )
|
513
502
|
{
|
514
|
-
|
503
|
+
|
515
504
|
double alpha = alpha_level_for_pixel(op, x + op->area.minX, y + op->area.minY, blob_id);
|
516
505
|
int r,g,b;
|
517
|
-
|
506
|
+
|
518
507
|
r = (pixel[0]);
|
519
508
|
g = (pixel[1]);
|
520
509
|
b = (pixel[2]);
|
521
|
-
|
522
|
-
|
510
|
+
|
511
|
+
|
523
512
|
if (alpha > 0)
|
524
513
|
{
|
525
|
-
|
514
|
+
|
526
515
|
pixel[0] = col((1-alpha) * r + (alpha * hr));
|
527
516
|
pixel[1] = col((1-alpha) * g + (alpha * hg));
|
528
517
|
pixel[2] = col((1-alpha) * b + (alpha * hb));
|
529
518
|
}
|
530
|
-
|
519
|
+
|
531
520
|
pixel += pixWidth;
|
532
521
|
}
|
533
522
|
}
|
534
|
-
|
523
|
+
|
535
524
|
}
|
536
525
|
|
537
526
|
|
538
527
|
/* Code */
|
539
528
|
static VALUE
|
540
|
-
RedEye___alloc__(VALUE self)
|
529
|
+
RedEye___alloc__(VALUE self OPTIONAL_ATTR )
|
541
530
|
{
|
542
|
-
VALUE __p_retval = Qnil;
|
531
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
543
532
|
|
544
533
|
#line 536 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"
|
545
534
|
do { __p_retval = Data_Wrap_Struct(self, NULL, free_redeye, new_redeye()); goto out; } while(0);
|
@@ -548,7 +537,7 @@ out:
|
|
548
537
|
}
|
549
538
|
|
550
539
|
static VALUE
|
551
|
-
RedEye_initialize(VALUE self, VALUE __v_pixbuf, VALUE __v_minX, VALUE __v_minY, VALUE __v_maxX, VALUE __v_maxY)
|
540
|
+
RedEye_initialize(VALUE self OPTIONAL_ATTR , VALUE __v_pixbuf OPTIONAL_ATTR, VALUE __v_minX OPTIONAL_ATTR, VALUE __v_minY OPTIONAL_ATTR, VALUE __v_maxX OPTIONAL_ATTR, VALUE __v_maxY OPTIONAL_ATTR)
|
552
541
|
{
|
553
542
|
GdkPixbuf * pixbuf; GdkPixbuf * __orig_pixbuf;
|
554
543
|
int minX; int __orig_minX;
|
@@ -598,7 +587,7 @@ RedEye_initialize(VALUE self, VALUE __v_pixbuf, VALUE __v_minX, VALUE __v_minY,
|
|
598
587
|
static VALUE
|
599
588
|
RedEye_identify_blobs(int __p_argc, VALUE *__p_argv, VALUE self)
|
600
589
|
{
|
601
|
-
VALUE __p_retval = Qnil;
|
590
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
602
591
|
VALUE __v_green_sensitivity = Qnil;
|
603
592
|
double green_sensitivity; double __orig_green_sensitivity;
|
604
593
|
VALUE __v_blue_sensitivity = Qnil;
|
@@ -653,7 +642,7 @@ out:
|
|
653
642
|
}
|
654
643
|
|
655
644
|
static VALUE
|
656
|
-
RedEye_correct_blob(VALUE self, VALUE __v_blob_id)
|
645
|
+
RedEye_correct_blob(VALUE self OPTIONAL_ATTR , VALUE __v_blob_id OPTIONAL_ATTR)
|
657
646
|
{
|
658
647
|
int blob_id; int __orig_blob_id;
|
659
648
|
__orig_blob_id = blob_id = NUM2INT(__v_blob_id);
|
@@ -709,7 +698,7 @@ RedEye_highlight_blob(int __p_argc, VALUE *__p_argv, VALUE self)
|
|
709
698
|
static VALUE
|
710
699
|
RedEye_preview_blob(int __p_argc, VALUE *__p_argv, VALUE self)
|
711
700
|
{
|
712
|
-
VALUE __p_retval = Qnil;
|
701
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
713
702
|
VALUE __v_blob_id = Qnil;
|
714
703
|
int blob_id; int __orig_blob_id;
|
715
704
|
VALUE __v_col = Qnil;
|
@@ -750,9 +739,9 @@ out:
|
|
750
739
|
}
|
751
740
|
|
752
741
|
static VALUE
|
753
|
-
RedEye_preview(VALUE self)
|
742
|
+
RedEye_preview(VALUE self OPTIONAL_ATTR )
|
754
743
|
{
|
755
|
-
VALUE __p_retval = Qnil;
|
744
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
756
745
|
|
757
746
|
#line 635 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"
|
758
747
|
|
@@ -768,9 +757,9 @@ out:
|
|
768
757
|
}
|
769
758
|
|
770
759
|
static VALUE
|
771
|
-
RedEye_pixbuf(VALUE self)
|
760
|
+
RedEye_pixbuf(VALUE self OPTIONAL_ATTR )
|
772
761
|
{
|
773
|
-
VALUE __p_retval = Qnil;
|
762
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
774
763
|
|
775
764
|
#line 642 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"
|
776
765
|
|
@@ -786,9 +775,9 @@ out:
|
|
786
775
|
}
|
787
776
|
|
788
777
|
static VALUE
|
789
|
-
Region_ratio(VALUE self)
|
778
|
+
Region_ratio(VALUE self OPTIONAL_ATTR )
|
790
779
|
{
|
791
|
-
VALUE __p_retval = Qnil;
|
780
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
792
781
|
|
793
782
|
#line 497 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"
|
794
783
|
int width,height;
|
@@ -804,9 +793,9 @@ out:
|
|
804
793
|
}
|
805
794
|
|
806
795
|
static VALUE
|
807
|
-
Region_density(VALUE self)
|
796
|
+
Region_density(VALUE self OPTIONAL_ATTR )
|
808
797
|
{
|
809
|
-
VALUE __p_retval = Qnil;
|
798
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
810
799
|
|
811
800
|
#line 507 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"
|
812
801
|
|
@@ -828,7 +817,7 @@ out:
|
|
828
817
|
static VALUE
|
829
818
|
Region_squareish_query(int __p_argc, VALUE *__p_argv, VALUE self)
|
830
819
|
{
|
831
|
-
VALUE __p_retval = Qnil;
|
820
|
+
VALUE __p_retval OPTIONAL_ATTR = Qnil;
|
832
821
|
VALUE __v_min_ratio = Qnil;
|
833
822
|
double min_ratio; double __orig_min_ratio;
|
834
823
|
VALUE __v_min_density = Qnil;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redeye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Youngs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubber-generate
|