lib_raw 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1114 @@
1
+ #include "lib_raw.h"
2
+ #include "libraw/libraw.h"
3
+
4
+
5
+ VALUE rb_mLibRaw;
6
+
7
+ VALUE rb_mColormatrixType;
8
+ VALUE rb_mCameraMount;
9
+ VALUE rb_mCameraFormat;
10
+ VALUE rb_mSonyArw2Option;
11
+ VALUE rb_mDp2qOption;
12
+ VALUE rb_mDecoderFlag;
13
+ VALUE rb_mWarning;
14
+ VALUE rb_mProgress;
15
+ VALUE rb_mThumbnailFormat;
16
+
17
+ VALUE rb_cRawObject;
18
+
19
+ VALUE rb_cIParam;
20
+ VALUE rb_cImageSize;
21
+ VALUE rb_cImgOther;
22
+ VALUE rb_cOutputParam;
23
+ VALUE rb_cMakerNote;
24
+ VALUE rb_cLensInfo;
25
+
26
+ VALUE rb_eRawError;
27
+ VALUE rb_eUnspecifiedError;
28
+ VALUE rb_eFileUnsupported;
29
+ VALUE rb_eRequestForNonexistentImage;
30
+ VALUE rb_eOutOfOrderCall;
31
+ VALUE rb_eNoThumbnail;
32
+ VALUE rb_eUnsupportedThumbnail;
33
+ VALUE rb_eInputClosed;
34
+ VALUE rb_eUnsufficientMemory;
35
+ VALUE rb_eDataError;
36
+ VALUE rb_eIOError;
37
+ VALUE rb_eCancelledByCallback;
38
+ VALUE rb_eBadCrop;
39
+
40
+
41
+
42
+ // LibRaw Native Resource
43
+
44
+ void lib_raw_native_resource_delete(LibRawNativeResource * p)
45
+ {
46
+ if (p->libraw) {
47
+ delete p->libraw;
48
+ }
49
+ free(p);
50
+ }
51
+
52
+ void output_param_native_resource_delete(OutputParamNativeResource * p)
53
+ {
54
+ free(p);
55
+ }
56
+
57
+ LibRaw* get_lib_raw(VALUE self)
58
+ {
59
+ VALUE resource = rb_iv_get(self, "lib_raw_native_resource");
60
+ if (resource==Qnil) {
61
+ return NULL;
62
+ }
63
+
64
+ LibRawNativeResource *p = NULL;
65
+ Data_Get_Struct(resource, LibRawNativeResource, p);
66
+ if (p) {
67
+ return p->libraw;
68
+ }
69
+
70
+ return NULL;
71
+ }
72
+
73
+ libraw_output_params_t* get_output_params(VALUE self)
74
+ {
75
+ VALUE resource = rb_iv_get(self, "output_param_native_resource");
76
+ if (resource==Qnil) {
77
+ return NULL;
78
+ }
79
+
80
+ OutputParamNativeResource *p = NULL;
81
+ Data_Get_Struct(resource, OutputParamNativeResource, p);
82
+ if (p) {
83
+ return &p->params;
84
+ }
85
+
86
+ return NULL;
87
+ }
88
+
89
+ void copy_lib_raw(VALUE dst, VALUE src)
90
+ {
91
+ VALUE resource = rb_iv_get(src, "lib_raw_native_resource");
92
+ rb_iv_set(dst, "lib_raw_native_resource", resource);
93
+ }
94
+
95
+ void check_errors(int e)
96
+ {
97
+ enum LibRaw_errors errorcode = (LibRaw_errors)e;
98
+ if (e!=LIBRAW_SUCCESS) {
99
+ const char *mess = libraw_strerror(e);
100
+
101
+ switch (e) {
102
+ case LIBRAW_UNSPECIFIED_ERROR:
103
+ rb_raise(rb_eUnspecifiedError, "%s", mess);
104
+ case LIBRAW_FILE_UNSUPPORTED:
105
+ rb_raise(rb_eFileUnsupported, "%s", mess);
106
+ case LIBRAW_REQUEST_FOR_NONEXISTENT_IMAGE:
107
+ rb_raise(rb_eRequestForNonexistentImage, "%s", mess);
108
+ case LIBRAW_OUT_OF_ORDER_CALL:
109
+ rb_raise(rb_eOutOfOrderCall, "%s", mess);
110
+ case LIBRAW_NO_THUMBNAIL:
111
+ rb_raise(rb_eNoThumbnail, "%s", mess);
112
+ case LIBRAW_UNSUPPORTED_THUMBNAIL:
113
+ rb_raise(rb_eUnsupportedThumbnail, "%s", mess);
114
+ case LIBRAW_INPUT_CLOSED:
115
+ rb_raise(rb_eInputClosed, "%s", mess);
116
+ case LIBRAW_UNSUFFICIENT_MEMORY:
117
+ rb_raise(rb_eUnsufficientMemory, "%s", mess);
118
+ case LIBRAW_DATA_ERROR:
119
+ rb_raise(rb_eDataError, "%s", mess);
120
+ case LIBRAW_IO_ERROR:
121
+ rb_raise(rb_eIOError, "%s", mess);
122
+ case LIBRAW_CANCELLED_BY_CALLBACK:
123
+ rb_raise(rb_eCancelledByCallback, "%s", mess);
124
+ case LIBRAW_BAD_CROP:
125
+ rb_raise(rb_eBadCrop, "%s", mess);
126
+ default:
127
+ rb_raise(rb_eRawError, "%s", mess);
128
+ }
129
+ }
130
+ }
131
+
132
+
133
+ // LibRaw::RawObject
134
+
135
+ void apply_rawobject(VALUE self)
136
+ {
137
+ LibRaw *raw = get_lib_raw(self);
138
+ if (raw) {
139
+ apply_data(self, &raw->imgdata);
140
+ }
141
+ }
142
+
143
+ void apply_data(VALUE self, libraw_data_t *p)
144
+ {
145
+ if (p) {
146
+ // size
147
+ VALUE size = rb_iv_get(self, "@size");
148
+ if (size==Qnil) {
149
+ size = rb_class_new_instance(0, NULL, rb_cImageSize);
150
+ rb_iv_set(self, "@size", size);
151
+ }
152
+ apply_image_size(size, &p->sizes);
153
+
154
+ // idata
155
+ VALUE idata = rb_iv_get(self, "@idata");
156
+ if (idata==Qnil) {
157
+ idata = rb_class_new_instance(0, NULL, rb_cIParam);
158
+ rb_iv_set(self, "@idata", idata);
159
+ }
160
+ apply_iparam(idata, &p->idata);
161
+
162
+ // lens
163
+ VALUE lens = rb_iv_get(self, "@lens");
164
+ if (lens==Qnil) {
165
+ lens = rb_class_new_instance(0, NULL, rb_cLensInfo);
166
+ rb_iv_set(self, "@lens", lens);
167
+ }
168
+ apply_lensinfo(lens, &p->lens);
169
+
170
+ // TODO: params
171
+
172
+ // TODO: color
173
+ /*
174
+ VALUE color = rb_iv_get(self, "@color");
175
+ if (color==Qnil) {
176
+ color = rb_class_new_instance(0, NULL, rb_cColorData);
177
+ rb_iv_set(self, "@color", color);
178
+ }
179
+ apply_colordata(color, &p->color);
180
+ */
181
+
182
+ // other
183
+ VALUE other = rb_iv_get(self, "@other");
184
+ if (other==Qnil) {
185
+ other = rb_class_new_instance(0, NULL, rb_cImgOther);
186
+ rb_iv_set(self, "@other", other);
187
+ }
188
+ apply_imgother(other, &p->other);
189
+
190
+ // param
191
+ VALUE param = rb_iv_get(self, "@param");
192
+ if (param==Qnil) {
193
+ param = rb_class_new_instance(0, NULL, rb_cOutputParam);
194
+ rb_iv_set(self, "@param", param);
195
+ }
196
+ apply_output_param(param, &p->params);
197
+ }
198
+ }
199
+
200
+ VALUE rb_raw_object_initialize(VALUE self)
201
+ {
202
+ LibRawNativeResource *p = ALLOC(LibRawNativeResource);
203
+ p->libraw = NULL;
204
+
205
+ try {
206
+ p->libraw = new LibRaw(LIBRAW_OPTIONS_NONE);
207
+ } catch (std::bad_alloc) {
208
+ rb_raise(rb_eStandardError, "alloc error");
209
+ }
210
+
211
+ VALUE resource = Data_Wrap_Struct(CLASS_OF(self), 0, lib_raw_native_resource_delete, p);
212
+ rb_iv_set(self, "lib_raw_native_resource", resource);
213
+
214
+ apply_data(self, &p->libraw->imgdata);
215
+
216
+ return self;
217
+ }
218
+
219
+ VALUE rb_raw_object_open_file(VALUE self, VALUE filename)
220
+ {
221
+ LibRaw *libraw = get_lib_raw(self);
222
+
223
+ char *name = RSTRING_PTR(rb_obj_as_string(filename));
224
+ int ret = libraw->open_file(name);
225
+ apply_rawobject(self);
226
+ check_errors(ret);
227
+
228
+ return Qtrue;
229
+ }
230
+
231
+ VALUE rb_raw_object_open_buffer(VALUE self, VALUE buff)
232
+ {
233
+ LibRaw *libraw = get_lib_raw(self);
234
+
235
+ int ret = libraw->open_buffer(RSTRING_PTR(buff), RSTRING_LEN(buff));
236
+ apply_rawobject(self);
237
+ check_errors(ret);
238
+
239
+ return Qtrue;
240
+ }
241
+
242
+ VALUE rb_raw_object_unpack(VALUE self)
243
+ {
244
+ LibRaw *libraw = get_lib_raw(self);
245
+
246
+ int ret = libraw->unpack();
247
+ check_errors(ret);
248
+
249
+ return Qtrue;
250
+ }
251
+
252
+ VALUE rb_raw_object_unpack_thumb(VALUE self)
253
+ {
254
+ LibRaw *libraw = get_lib_raw(self);
255
+
256
+ int ret = libraw->unpack_thumb();
257
+ check_errors(ret);
258
+
259
+ return Qtrue;
260
+ }
261
+
262
+ VALUE rb_raw_object_recycle_datastream(VALUE self)
263
+ {
264
+ LibRaw *libraw = get_lib_raw(self);
265
+
266
+ libraw->recycle_datastream();
267
+
268
+ return Qnil;
269
+ }
270
+
271
+ VALUE rb_raw_object_recycle(VALUE self)
272
+ {
273
+ LibRaw *libraw = get_lib_raw(self);
274
+
275
+ libraw->recycle();
276
+
277
+ return Qnil;
278
+ }
279
+
280
+ VALUE rb_raw_object_dcraw_ppm_tiff_writer(VALUE self, VALUE filename)
281
+ {
282
+ LibRaw *libraw = get_lib_raw(self);
283
+
284
+ const char *name = RSTRING_PTR(filename);
285
+ int ret = libraw->dcraw_ppm_tiff_writer(name);
286
+ check_errors(ret);
287
+
288
+ return Qtrue;
289
+ }
290
+
291
+ VALUE rb_raw_object_dcraw_thumb_writer(VALUE self, VALUE filename)
292
+ {
293
+ LibRaw *libraw = get_lib_raw(self);
294
+
295
+ const char *name = RSTRING_PTR(filename);
296
+ int ret = libraw->dcraw_thumb_writer(name);
297
+ check_errors(ret);
298
+
299
+ return Qtrue;
300
+ }
301
+
302
+ VALUE rb_raw_object_dcraw_process(VALUE self, VALUE param)
303
+ {
304
+ LibRaw *libraw = get_lib_raw(self);
305
+ libraw_output_params_t *params = get_output_params(param);
306
+
307
+ memmove(&libraw->imgdata.params, params, sizeof(libraw_output_params_t));
308
+
309
+ int ret = libraw->dcraw_process();
310
+ check_errors(ret);
311
+
312
+ return Qtrue;
313
+ }
314
+
315
+
316
+ // LibRaw::IParam
317
+
318
+ void apply_iparam(VALUE self, libraw_iparams_t *p)
319
+ {
320
+ if (p) {
321
+ rb_iv_set(self, "@make", rb_str_new2(p->make));
322
+ rb_iv_set(self, "@model", rb_str_new2(p->model));
323
+ rb_iv_set(self, "@software", rb_str_new2(p->software));
324
+ rb_iv_set(self, "@raw_count", INT2FIX(p->raw_count));
325
+ rb_iv_set(self, "@dng_version", INT2FIX(p->dng_version));
326
+ rb_iv_set(self, "@is_foveon", p->is_foveon ? Qtrue : Qfalse);
327
+ rb_iv_set(self, "@colors", INT2FIX(p->colors));
328
+ rb_iv_set(self, "@filters", INT2FIX(p->filters));
329
+ rb_iv_set(self, "@cdesc", rb_str_new2(p->cdesc));
330
+ }
331
+ }
332
+
333
+
334
+ // LibRaw::ImageSize
335
+
336
+ void apply_image_size(VALUE self, libraw_image_sizes_t *p)
337
+ {
338
+ if (p) {
339
+ rb_iv_set(self, "@raw_height", INT2FIX(p->raw_height));
340
+ rb_iv_set(self, "@raw_width", INT2FIX(p->raw_width));
341
+ rb_iv_set(self, "@height", INT2FIX(p->height));
342
+ rb_iv_set(self, "@width", INT2FIX(p->width));
343
+ rb_iv_set(self, "@top_margin", INT2FIX(p->top_margin));
344
+ rb_iv_set(self, "@left_margin", INT2FIX(p->left_margin));
345
+ rb_iv_set(self, "@iheight", INT2FIX(p->iheight));
346
+ rb_iv_set(self, "@iwidth", INT2FIX(p->iwidth));
347
+ rb_iv_set(self, "@raw_pitch", INT2FIX(p->raw_pitch));
348
+ rb_iv_set(self, "@pixel_aspect", rb_float_new(p->pixel_aspect));
349
+ rb_iv_set(self, "@flip", INT2FIX(p->flip));
350
+ }
351
+ }
352
+
353
+
354
+ // LibRaw::ColorData
355
+
356
+ void apply_colordata(VALUE self, libraw_colordata_t *p)
357
+ {
358
+ if (p) {
359
+ // TODO
360
+ }
361
+ }
362
+
363
+
364
+ // LibRaw::ImgOther
365
+
366
+ void apply_imgother(VALUE self, libraw_imgother_t *p)
367
+ {
368
+ if (p) {
369
+ rb_iv_set(self, "@iso_speed", rb_float_new(p->iso_speed));
370
+ rb_iv_set(self, "@shutter", rb_float_new(p->shutter));
371
+ rb_iv_set(self, "@aperture", rb_float_new(p->aperture));
372
+ rb_iv_set(self, "@focal_len", rb_float_new(p->focal_len));
373
+ rb_iv_set(self, "@timestamp", INT2FIX(p->timestamp));
374
+ rb_iv_set(self, "@shot_order", INT2FIX(p->shot_order));
375
+ rb_iv_set(self, "@desc", rb_str_new2(p->desc));
376
+ rb_iv_set(self, "@artist", rb_str_new2(p->artist));
377
+
378
+ // TODO: parsed_gps
379
+ }
380
+ }
381
+
382
+
383
+ // LibRaw::OutputParam
384
+
385
+ VALUE rb_output_param_initialize(VALUE self)
386
+ {
387
+ OutputParamNativeResource *p = ALLOC(OutputParamNativeResource);
388
+
389
+
390
+ memset(&p->params, 0, sizeof(libraw_output_params_t));
391
+
392
+ double aber[4] = {1,1,1,1};
393
+ double gamm[6] = { 0.45,4.5,0,0,0,0 };
394
+ unsigned greybox[4] = { 0, 0, UINT_MAX, UINT_MAX };
395
+ unsigned cropbox[4] = { 0, 0, UINT_MAX, UINT_MAX };
396
+
397
+ memmove(&p->params.aber,&aber,sizeof(aber));
398
+ memmove(&p->params.gamm,&gamm,sizeof(gamm));
399
+ memmove(&p->params.greybox,&greybox,sizeof(greybox));
400
+ memmove(&p->params.cropbox,&cropbox,sizeof(cropbox));
401
+
402
+ p->params.bright=1;
403
+ p->params.use_camera_matrix=1;
404
+ p->params.user_flip=-1;
405
+ p->params.user_black=-1;
406
+ p->params.user_cblack[0]=p->params.user_cblack[1]=p->params.user_cblack[2]=p->params.user_cblack[3]=-1000001;
407
+ p->params.user_sat=-1;
408
+ p->params.user_qual=-1;
409
+ p->params.output_color=1;
410
+ p->params.output_bps=8;
411
+ p->params.use_fuji_rotate=1;
412
+ p->params.exp_shift = 1.0;
413
+ p->params.auto_bright_thr = LIBRAW_DEFAULT_AUTO_BRIGHTNESS_THRESHOLD;
414
+ p->params.adjust_maximum_thr= LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD;
415
+ p->params.use_rawspeed = 1;
416
+ p->params.no_auto_scale = 0;
417
+ p->params.no_interpolation = 0;
418
+ p->params.sraw_ycc = 0;
419
+ p->params.force_foveon_x3f = 0;
420
+ p->params.x3f_flags = LIBRAW_DP2Q_INTERPOLATERG|LIBRAW_DP2Q_INTERPOLATEAF;
421
+ p->params.sony_arw2_options = 0;
422
+ p->params.sony_arw2_posterization_thr = 0;
423
+ p->params.green_matching = 0;
424
+ p->params.coolscan_nef_gamma = 1.0f;
425
+
426
+
427
+ VALUE resource = Data_Wrap_Struct(CLASS_OF(self), 0, output_param_native_resource_delete, p);
428
+ rb_iv_set(self, "output_param_native_resource", resource);
429
+
430
+ apply_output_param(self, &p->params);
431
+
432
+ return self;
433
+ }
434
+
435
+ void apply_output_param(VALUE self, libraw_output_params_t *p)
436
+ {
437
+ if (p) {
438
+ // TODO: greybox
439
+ // TODO: cropbox
440
+ // TODO: aber
441
+ // TODO: gamm
442
+ // TODO: user_mul
443
+ rb_iv_set(self, "@shot_select", INT2FIX(p->shot_select));
444
+ rb_iv_set(self, "@bright", rb_float_new(p->bright));
445
+ rb_iv_set(self, "@threshold", rb_float_new(p->threshold));
446
+ rb_iv_set(self, "@half_size", INT2FIX(p->half_size));
447
+ rb_iv_set(self, "@four_color_rgb", INT2FIX(p->four_color_rgb));
448
+ rb_iv_set(self, "@highlight", INT2FIX(p->highlight));
449
+ rb_iv_set(self, "@use_auto_wb", p->use_auto_wb ? Qtrue : Qfalse);
450
+ rb_iv_set(self, "@use_camera_wb", p->use_camera_wb ? Qtrue : Qfalse);
451
+ rb_iv_set(self, "@use_camera_matrix", p->use_camera_matrix ? Qtrue : Qfalse);
452
+ rb_iv_set(self, "@output_color", INT2FIX(p->output_color));
453
+ // TODO: output_profile
454
+ // TODO: camera_profile
455
+ // TODO: bad_pixels
456
+ // TODO: dark_frame
457
+ rb_iv_set(self, "@output_bps", INT2FIX(p->output_bps));
458
+ rb_iv_set(self, "@output_tiff", INT2FIX(p->output_tiff));
459
+ rb_iv_set(self, "@user_flip", INT2FIX(p->user_flip));
460
+ rb_iv_set(self, "@user_qual", INT2FIX(p->user_qual));
461
+ rb_iv_set(self, "@user_black", INT2FIX(p->user_black));
462
+ // TODO: user_cblack
463
+ rb_iv_set(self, "@user_sat", INT2FIX(p->user_sat));
464
+ rb_iv_set(self, "@med_passes", INT2FIX(p->med_passes));
465
+ rb_iv_set(self, "@auto_bright_thr", rb_float_new(p->auto_bright_thr));
466
+ rb_iv_set(self, "@adjust_maximum_thr", rb_float_new(p->adjust_maximum_thr));
467
+ rb_iv_set(self, "@no_auto_bright", p->no_auto_bright ? Qtrue : Qfalse);
468
+ rb_iv_set(self, "@use_fuji_rotate", p->use_fuji_rotate ? Qtrue : Qfalse);
469
+ rb_iv_set(self, "@green_matching", INT2FIX(p->green_matching));
470
+
471
+ // DCB parameters
472
+ rb_iv_set(self, "@dcb_iterations", INT2FIX(p->dcb_iterations));
473
+ rb_iv_set(self, "@dcb_enhance_fl", INT2FIX(p->dcb_enhance_fl));
474
+ rb_iv_set(self, "@fbdd_noiserd", INT2FIX(p->fbdd_noiserd));
475
+
476
+ // VCD parameters
477
+ rb_iv_set(self, "@eeci_refine", INT2FIX(p->eeci_refine));
478
+ rb_iv_set(self, "@es_med_passes", INT2FIX(p->es_med_passes));
479
+
480
+ // AMaZE
481
+ rb_iv_set(self, "@ca_correc", INT2FIX(p->ca_correc));
482
+ rb_iv_set(self, "@cared", rb_float_new(p->cared));
483
+ rb_iv_set(self, "@cablue", rb_float_new(p->cablue));
484
+ rb_iv_set(self, "@cfaline", INT2FIX(p->cfaline));
485
+ rb_iv_set(self, "@linenoise", rb_float_new(p->linenoise));
486
+ rb_iv_set(self, "@cfa_clean", INT2FIX(p->cfa_clean));
487
+ rb_iv_set(self, "@lclean", rb_float_new(p->lclean));
488
+ rb_iv_set(self, "@cclean", rb_float_new(p->cclean));
489
+ rb_iv_set(self, "@cfa_green", INT2FIX(p->cfa_green));
490
+ rb_iv_set(self, "@green_thresh", rb_float_new(p->green_thresh));
491
+ rb_iv_set(self, "@exp_correc", INT2FIX(p->exp_correc));
492
+ rb_iv_set(self, "@exp_shift", rb_float_new(p->exp_shift));
493
+ rb_iv_set(self, "@exp_preser", rb_float_new(p->exp_preser));
494
+
495
+ // WF debanding
496
+ rb_iv_set(self, "@wf_debanding", INT2FIX(p->wf_debanding));
497
+ // TODO: wf_deband_treshold
498
+
499
+ // Raw speed
500
+ rb_iv_set(self, "@use_rawspeed", p->use_rawspeed ? Qtrue : Qfalse);
501
+
502
+ // Disable Auto-scale
503
+ rb_iv_set(self, "@no_auto_scale", p->no_auto_scale ? Qtrue : Qfalse);
504
+
505
+ // Disable intepolation
506
+ rb_iv_set(self, "@no_interpolation", p->no_interpolation ? Qtrue : Qfalse);
507
+
508
+ // Disable sRAW YCC to RGB conversion
509
+ rb_iv_set(self, "@sraw_ycc", INT2FIX(p->sraw_ycc));
510
+
511
+ // Force use x3f data decoding either if demosaic pack GPL2 enabled
512
+ rb_iv_set(self, "@force_foveon_x3f", INT2FIX(p->force_foveon_x3f));
513
+ rb_iv_set(self, "@x3f_flags", INT2FIX(p->x3f_flags));
514
+
515
+ // Sony ARW2 digging mode
516
+ rb_iv_set(self, "@sony_arw2_options", INT2FIX(p->sony_arw2_options));
517
+ rb_iv_set(self, "@sony_arw2_posterization_thr", INT2FIX(p->sony_arw2_posterization_thr));
518
+
519
+ // Nikon Coolscan
520
+ rb_iv_set(self, "@coolscan_nef_gamma", rb_float_new(p->coolscan_nef_gamma));
521
+ }
522
+ }
523
+
524
+ VALUE rb_output_param_greybox(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
525
+ {
526
+ libraw_output_params_t *params = get_output_params(self);
527
+
528
+ params->greybox[0] = NUM2LONG(x);
529
+ params->greybox[1] = NUM2LONG(y);
530
+ params->greybox[2] = NUM2LONG(w);
531
+ params->greybox[3] = NUM2LONG(h);
532
+
533
+ apply_output_param(self, params);
534
+
535
+ return self;
536
+ }
537
+
538
+ VALUE rb_output_param_cropbox(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
539
+ {
540
+ libraw_output_params_t *params = get_output_params(self);
541
+
542
+ params->cropbox[0]= NUM2LONG(x);
543
+ params->cropbox[1]= NUM2LONG(y);
544
+ params->cropbox[2]= NUM2LONG(w);
545
+ params->cropbox[3]= NUM2LONG(h);
546
+
547
+ apply_output_param(self, params);
548
+
549
+ return self;
550
+ }
551
+
552
+ VALUE rb_output_param_gamma(VALUE self, VALUE pwr, VALUE ts)
553
+ {
554
+ libraw_output_params_t *params = get_output_params(self);
555
+
556
+ params->gamm[0] = RFLOAT_VALUE(rb_Float(pwr));
557
+ params->gamm[1] = RFLOAT_VALUE(rb_Float(ts));
558
+
559
+ apply_output_param(self, params);
560
+
561
+ return self;
562
+ }
563
+
564
+ VALUE rb_output_param_whitebalance(VALUE self, VALUE r, VALUE g, VALUE b, VALUE g2)
565
+ {
566
+ libraw_output_params_t *params = get_output_params(self);
567
+
568
+ params->user_mul[0] = RFLOAT_VALUE(rb_Float(r));
569
+ params->user_mul[1] = RFLOAT_VALUE(rb_Float(g));
570
+ params->user_mul[2] = RFLOAT_VALUE(rb_Float(b));
571
+ params->user_mul[3] = RFLOAT_VALUE(rb_Float(g2));
572
+
573
+ apply_output_param(self, params);
574
+
575
+ return self;
576
+ }
577
+
578
+ VALUE rb_output_param_set_bright(VALUE self, VALUE val)
579
+ {
580
+ libraw_output_params_t *params = get_output_params(self);
581
+
582
+ params->bright = RFLOAT_VALUE(rb_Float(val));
583
+
584
+ apply_output_param(self, params);
585
+
586
+ return self;
587
+ }
588
+
589
+ VALUE rb_output_param_set_highlight(VALUE self, VALUE val)
590
+ {
591
+ libraw_output_params_t *params = get_output_params(self);
592
+
593
+ params->highlight = NUM2LONG(val);
594
+
595
+ apply_output_param(self, params);
596
+
597
+ return self;
598
+ }
599
+
600
+ VALUE rb_output_param_set_use_auto_wb(VALUE self, VALUE val)
601
+ {
602
+ libraw_output_params_t *params = get_output_params(self);
603
+
604
+ params->use_auto_wb = !(val==Qnil || val==Qfalse);
605
+
606
+ apply_output_param(self, params);
607
+
608
+ return self;
609
+ }
610
+
611
+ VALUE rb_output_param_set_use_camera_wb(VALUE self, VALUE val)
612
+ {
613
+ libraw_output_params_t *params = get_output_params(self);
614
+
615
+ params->use_camera_wb = !(val==Qnil || val==Qfalse);
616
+
617
+ apply_output_param(self, params);
618
+
619
+ return self;
620
+ }
621
+
622
+ VALUE rb_output_param_set_fbdd_noiserd(VALUE self, VALUE val)
623
+ {
624
+ libraw_output_params_t *params = get_output_params(self);
625
+
626
+ params->fbdd_noiserd = NUM2LONG(val);
627
+
628
+ apply_output_param(self, params);
629
+
630
+ return self;
631
+ }
632
+
633
+
634
+ // LibRaw::MakerNote
635
+
636
+ void apply_makernote(VALUE self, libraw_makernotes_lens_t *p)
637
+ {
638
+ if (p) {
639
+ rb_iv_set(self, "@lens_id", INT2FIX(p->LensID));
640
+ rb_iv_set(self, "@lens", rb_str_new2(p->Lens));
641
+ rb_iv_set(self, "@lens_format", INT2FIX(p->LensFormat));
642
+ rb_iv_set(self, "@lens_mount", INT2FIX(p->LensMount));
643
+ rb_iv_set(self, "@cam_id", INT2FIX(p->CamID));
644
+ rb_iv_set(self, "@camera_format", INT2FIX(p->CameraFormat));
645
+ rb_iv_set(self, "@camera_mount", INT2FIX(p->CameraMount));
646
+ rb_iv_set(self, "@body", rb_str_new2(p->body));
647
+ rb_iv_set(self, "@focal_type", INT2FIX(p->FocalType));
648
+ rb_iv_set(self, "@lens_features_pre", rb_str_new2(p->LensFeatures_pre));
649
+ rb_iv_set(self, "@lens_features_suf", rb_str_new2(p->LensFeatures_suf));
650
+ rb_iv_set(self, "@min_focal", rb_float_new(p->MinFocal));
651
+ rb_iv_set(self, "@max_focal", rb_float_new(p->MaxFocal));
652
+ rb_iv_set(self, "@max_ap_4_min_focal", rb_float_new(p->MaxAp4MinFocal));
653
+ rb_iv_set(self, "@max_ap_4_max_focal", rb_float_new(p->MaxAp4MaxFocal));
654
+ rb_iv_set(self, "@min_ap_4_min_focal", rb_float_new(p->MinAp4MinFocal));
655
+ rb_iv_set(self, "@min_ap_4_max_focal", rb_float_new(p->MinAp4MaxFocal));
656
+ rb_iv_set(self, "@max_ap", rb_float_new(p->MaxAp));
657
+ rb_iv_set(self, "@min_ap", rb_float_new(p->MinAp));
658
+ rb_iv_set(self, "@cur_focal", rb_float_new(p->CurFocal));
659
+ rb_iv_set(self, "@cur_ap", rb_float_new(p->CurAp));
660
+ rb_iv_set(self, "@max_ap_4_cur_focal", rb_float_new(p->MaxAp4CurFocal));
661
+ rb_iv_set(self, "@min_ap_4_cur_focal", rb_float_new(p->MinAp4CurFocal));
662
+ rb_iv_set(self, "@lens_f_stops", rb_float_new(p->LensFStops));
663
+ rb_iv_set(self, "@teleconverter_id", INT2FIX(p->TeleconverterID));
664
+ rb_iv_set(self, "@teleconverter", rb_str_new2(p->Teleconverter));
665
+ rb_iv_set(self, "@adapter_id", INT2FIX(p->AdapterID));
666
+ rb_iv_set(self, "@adapter", rb_str_new2(p->Adapter));
667
+ rb_iv_set(self, "@attachment_id", INT2FIX(p->AttachmentID));
668
+ rb_iv_set(self, "@attachment", rb_str_new2(p->Attachment));
669
+ rb_iv_set(self, "@canon_focal_units", INT2FIX(p->CanonFocalUnits));
670
+ rb_iv_set(self, "@focal_length_in_35mm_format", rb_float_new(p->FocalLengthIn35mmFormat));
671
+ }
672
+ }
673
+
674
+
675
+ // LibRaw::LensInfo
676
+
677
+ void apply_lensinfo(VALUE self, libraw_lensinfo_t *p)
678
+ {
679
+ if (p) {
680
+ rb_iv_set(self, "@min_focal", rb_float_new(p->MinFocal));
681
+ rb_iv_set(self, "@max_focal", rb_float_new(p->MaxFocal));
682
+ rb_iv_set(self, "@max_ap_4_min_focal", rb_float_new(p->MaxAp4MinFocal));
683
+ rb_iv_set(self, "@max_ap_4_max_focal", rb_float_new(p->MaxAp4MaxFocal));
684
+ rb_iv_set(self, "@exif_max_ap", rb_float_new(p->EXIF_MaxAp));
685
+ rb_iv_set(self, "@lens_make", rb_str_new2(p->LensMake));
686
+ rb_iv_set(self, "@lens", rb_str_new2(p->Lens));
687
+ rb_iv_set(self, "@focal_length_in_35mm_format", INT2FIX(p->FocalLengthIn35mmFormat));
688
+ // TODO: nikon
689
+ // TODO: dng
690
+
691
+ // makernotes
692
+ VALUE makernotes = rb_iv_get(self, "@makernotes");
693
+ if (makernotes==Qnil) {
694
+ makernotes = rb_class_new_instance(0, NULL, rb_cMakerNote);
695
+ rb_iv_set(self, "@makernotes", makernotes);
696
+ }
697
+ apply_makernote(makernotes, &p->makernotes);
698
+ }
699
+ }
700
+
701
+
702
+
703
+ extern "C" void Init_lib_raw(void)
704
+ {
705
+ rb_mLibRaw = rb_define_module("LibRaw");
706
+
707
+
708
+ // const
709
+
710
+ // LibRaw::ColormatrixType
711
+
712
+ rb_mColormatrixType = rb_define_module_under(rb_mLibRaw, "ColormatrixType");
713
+
714
+ rb_define_const(rb_mColormatrixType, "NONE", INT2FIX(LIBRAW_CMATRIX_NONE));
715
+ rb_define_const(rb_mColormatrixType, "DNG", INT2FIX(LIBRAW_CMATRIX_DNG));
716
+ rb_define_const(rb_mColormatrixType, "DIGBACK", INT2FIX(LIBRAW_CMATRIX_DIGBACK));
717
+ rb_define_const(rb_mColormatrixType, "OTHER", INT2FIX(LIBRAW_CMATRIX_OTHER));
718
+
719
+
720
+ // LibRaw::CameraMount
721
+
722
+ rb_mCameraMount = rb_define_module_under(rb_mLibRaw, "CameraMount");
723
+
724
+ rb_define_const(rb_mCameraMount, "Unknown", INT2FIX(LIBRAW_MOUNT_Unknown));
725
+ rb_define_const(rb_mCameraMount, "Minolta_A", INT2FIX(LIBRAW_MOUNT_Minolta_A));
726
+ rb_define_const(rb_mCameraMount, "Sony_E", INT2FIX(LIBRAW_MOUNT_Sony_E));
727
+ rb_define_const(rb_mCameraMount, "Canon_EF", INT2FIX(LIBRAW_MOUNT_Canon_EF));
728
+ rb_define_const(rb_mCameraMount, "Canon_EF_S", INT2FIX(LIBRAW_MOUNT_Canon_EF_S));
729
+ rb_define_const(rb_mCameraMount, "Canon_EF_M", INT2FIX(LIBRAW_MOUNT_Canon_EF_M));
730
+ rb_define_const(rb_mCameraMount, "Nikon_F", INT2FIX(LIBRAW_MOUNT_Nikon_F));
731
+ rb_define_const(rb_mCameraMount, "Nikon_CX", INT2FIX(LIBRAW_MOUNT_Nikon_CX));
732
+ rb_define_const(rb_mCameraMount, "FT", INT2FIX(LIBRAW_MOUNT_FT));
733
+ rb_define_const(rb_mCameraMount, "MFT", INT2FIX(LIBRAW_MOUNT_mFT));
734
+ rb_define_const(rb_mCameraMount, "Pentax_K", INT2FIX(LIBRAW_MOUNT_Pentax_K));
735
+ rb_define_const(rb_mCameraMount, "Pentax_Q", INT2FIX(LIBRAW_MOUNT_Pentax_Q));
736
+ rb_define_const(rb_mCameraMount, "Pentax_645", INT2FIX(LIBRAW_MOUNT_Pentax_645));
737
+ rb_define_const(rb_mCameraMount, "Fuji_X", INT2FIX(LIBRAW_MOUNT_Fuji_X));
738
+ rb_define_const(rb_mCameraMount, "Leica_M", INT2FIX(LIBRAW_MOUNT_Leica_M));
739
+ rb_define_const(rb_mCameraMount, "Leica_R", INT2FIX(LIBRAW_MOUNT_Leica_R));
740
+ rb_define_const(rb_mCameraMount, "Leica_S", INT2FIX(LIBRAW_MOUNT_Leica_S));
741
+ rb_define_const(rb_mCameraMount, "Samsung_NX", INT2FIX(LIBRAW_MOUNT_Samsung_NX));
742
+ rb_define_const(rb_mCameraMount, "RicohModule", INT2FIX(LIBRAW_MOUNT_RicohModule));
743
+ rb_define_const(rb_mCameraMount, "Samsung_NX_M", INT2FIX(LIBRAW_MOUNT_Samsung_NX_M));
744
+ rb_define_const(rb_mCameraMount, "Leica_T", INT2FIX(LIBRAW_MOUNT_Leica_T));
745
+ rb_define_const(rb_mCameraMount, "Contax_N", INT2FIX(LIBRAW_MOUNT_Contax_N));
746
+ rb_define_const(rb_mCameraMount, "Sigma_X3F", INT2FIX(LIBRAW_MOUNT_Sigma_X3F));
747
+ rb_define_const(rb_mCameraMount, "FixedLens", INT2FIX(LIBRAW_MOUNT_FixedLens));
748
+
749
+
750
+ // LibRaw::CameraFormat
751
+
752
+ rb_mCameraFormat = rb_define_module_under(rb_mLibRaw, "CameraFormat");
753
+
754
+ rb_define_const(rb_mCameraFormat, "APSC", INT2FIX(LIBRAW_FORMAT_APSC));
755
+ rb_define_const(rb_mCameraFormat, "FF", INT2FIX(LIBRAW_FORMAT_FF));
756
+ rb_define_const(rb_mCameraFormat, "MF", INT2FIX(LIBRAW_FORMAT_MF));
757
+ rb_define_const(rb_mCameraFormat, "APSH", INT2FIX(LIBRAW_FORMAT_APSH));
758
+ rb_define_const(rb_mCameraFormat, "FT", INT2FIX(LIBRAW_FORMAT_FT));
759
+
760
+
761
+ // LibRaw::SonyArw2Option
762
+
763
+ rb_mSonyArw2Option = rb_define_module_under(rb_mLibRaw, "SonyArw2Option");
764
+
765
+ rb_define_const(rb_mSonyArw2Option, "NONE", INT2FIX(LIBRAW_SONYARW2_NONE));
766
+ rb_define_const(rb_mSonyArw2Option, "BASEONLY", INT2FIX(LIBRAW_SONYARW2_BASEONLY));
767
+ rb_define_const(rb_mSonyArw2Option, "DELTAONLY", INT2FIX(LIBRAW_SONYARW2_DELTAONLY));
768
+ rb_define_const(rb_mSonyArw2Option, "DELTAZEROBASE", INT2FIX(LIBRAW_SONYARW2_DELTAZEROBASE));
769
+ rb_define_const(rb_mSonyArw2Option, "DELTATOVALUE", INT2FIX(LIBRAW_SONYARW2_DELTATOVALUE));
770
+
771
+
772
+ // LibRaw::Dp2qOption
773
+
774
+ rb_mDp2qOption = rb_define_module_under(rb_mLibRaw, "Dp2qOption");
775
+
776
+ rb_define_const(rb_mDp2qOption, "NONE", INT2FIX(LIBRAW_DP2QOPT_NONE));
777
+ rb_define_const(rb_mDp2qOption, "INTERPOLATERG", INT2FIX(LIBRAW_DP2Q_INTERPOLATERG));
778
+ rb_define_const(rb_mDp2qOption, "INTERPOLATEAF", INT2FIX(LIBRAW_DP2Q_INTERPOLATEAF));
779
+
780
+
781
+ // LibRaw::DecoderFlags
782
+
783
+ rb_mDecoderFlag = rb_define_module_under(rb_mLibRaw, "DecoderFlag");
784
+
785
+ //rb_define_const(rb_mDecoderFlag, "LEGACY", INT2FIX(LIBRAW_DECODER_LEGACY));
786
+ //rb_define_const(rb_mDecoderFlag, "FLATFIELD", INT2FIX(LIBRAW_DECODER_FLATFIELD));
787
+ rb_define_const(rb_mDecoderFlag, "USEBAYER2", INT2FIX(LIBRAW_DECODER_USEBAYER2));
788
+ rb_define_const(rb_mDecoderFlag, "HASCURVE", INT2FIX(LIBRAW_DECODER_HASCURVE));
789
+ rb_define_const(rb_mDecoderFlag, "SONYARW2", INT2FIX(LIBRAW_DECODER_SONYARW2));
790
+ rb_define_const(rb_mDecoderFlag, "TRYRAWSPEED", INT2FIX(LIBRAW_DECODER_TRYRAWSPEED));
791
+ rb_define_const(rb_mDecoderFlag, "OWNALLOC", INT2FIX(LIBRAW_DECODER_OWNALLOC));
792
+ rb_define_const(rb_mDecoderFlag, "FIXEDMAXC", INT2FIX(LIBRAW_DECODER_FIXEDMAXC));
793
+ rb_define_const(rb_mDecoderFlag, "NOTSET", INT2FIX(LIBRAW_DECODER_NOTSET));
794
+
795
+
796
+ // LibRaw::Warning
797
+
798
+ rb_mWarning = rb_define_module_under(rb_mLibRaw, "Warning");
799
+
800
+ rb_define_const(rb_mWarning, "NONE", INT2FIX(LIBRAW_WARN_NONE));
801
+ rb_define_const(rb_mWarning, "FOVEON_NOMATRIX", INT2FIX(LIBRAW_WARN_FOVEON_NOMATRIX));
802
+ rb_define_const(rb_mWarning, "FOVEON_INVALIDWB", INT2FIX(LIBRAW_WARN_FOVEON_INVALIDWB));
803
+ rb_define_const(rb_mWarning, "BAD_CAMERA_WB", INT2FIX(LIBRAW_WARN_BAD_CAMERA_WB));
804
+ rb_define_const(rb_mWarning, "NO_METADATA", INT2FIX(LIBRAW_WARN_NO_METADATA));
805
+ rb_define_const(rb_mWarning, "NO_JPEGLIB", INT2FIX(LIBRAW_WARN_NO_JPEGLIB));
806
+ rb_define_const(rb_mWarning, "NO_EMBEDDED_PROFILE", INT2FIX(LIBRAW_WARN_NO_EMBEDDED_PROFILE));
807
+ rb_define_const(rb_mWarning, "NO_INPUT_PROFILE", INT2FIX(LIBRAW_WARN_NO_INPUT_PROFILE));
808
+ rb_define_const(rb_mWarning, "BAD_OUTPUT_PROFILE", INT2FIX(LIBRAW_WARN_BAD_OUTPUT_PROFILE));
809
+ rb_define_const(rb_mWarning, "NO_BADPIXELMAP", INT2FIX(LIBRAW_WARN_NO_BADPIXELMAP));
810
+ rb_define_const(rb_mWarning, "BAD_DARKFRAME_FILE", INT2FIX(LIBRAW_WARN_BAD_DARKFRAME_FILE));
811
+ rb_define_const(rb_mWarning, "BAD_DARKFRAME_DIM", INT2FIX(LIBRAW_WARN_BAD_DARKFRAME_DIM));
812
+ rb_define_const(rb_mWarning, "NO_JASPER", INT2FIX(LIBRAW_WARN_NO_JASPER));
813
+ rb_define_const(rb_mWarning, "RAWSPEED_PROBLEM", INT2FIX(LIBRAW_WARN_RAWSPEED_PROBLEM));
814
+ rb_define_const(rb_mWarning, "RAWSPEED_UNSUPPORTED", INT2FIX(LIBRAW_WARN_RAWSPEED_UNSUPPORTED));
815
+ rb_define_const(rb_mWarning, "RAWSPEED_PROCESSED", INT2FIX(LIBRAW_WARN_RAWSPEED_PROCESSED));
816
+ rb_define_const(rb_mWarning, "FALLBACK_TO_AHD", INT2FIX(LIBRAW_WARN_FALLBACK_TO_AHD));
817
+
818
+
819
+ // LibRaw::Progress
820
+
821
+ rb_mProgress = rb_define_module_under(rb_mLibRaw, "Progress");
822
+
823
+ rb_define_const(rb_mProgress, "START", INT2FIX(LIBRAW_PROGRESS_START));
824
+ rb_define_const(rb_mProgress, "OPEN", INT2FIX(LIBRAW_PROGRESS_OPEN));
825
+ rb_define_const(rb_mProgress, "IDENTIFY", INT2FIX(LIBRAW_PROGRESS_IDENTIFY));
826
+ rb_define_const(rb_mProgress, "SIZE_ADJUST", INT2FIX(LIBRAW_PROGRESS_SIZE_ADJUST));
827
+ rb_define_const(rb_mProgress, "LOAD_RAW", INT2FIX(LIBRAW_PROGRESS_LOAD_RAW));
828
+ rb_define_const(rb_mProgress, "RAW2_IMAGE", INT2FIX(LIBRAW_PROGRESS_RAW2_IMAGE));
829
+ rb_define_const(rb_mProgress, "REMOVE_ZEROES", INT2FIX(LIBRAW_PROGRESS_REMOVE_ZEROES));
830
+ rb_define_const(rb_mProgress, "BAD_PIXELS", INT2FIX(LIBRAW_PROGRESS_BAD_PIXELS));
831
+ rb_define_const(rb_mProgress, "DARK_FRAME", INT2FIX(LIBRAW_PROGRESS_DARK_FRAME));
832
+ rb_define_const(rb_mProgress, "FOVEON_INTERPOLATE", INT2FIX(LIBRAW_PROGRESS_FOVEON_INTERPOLATE));
833
+ rb_define_const(rb_mProgress, "SCALE_COLORS", INT2FIX(LIBRAW_PROGRESS_SCALE_COLORS));
834
+ rb_define_const(rb_mProgress, "PRE_INTERPOLATE", INT2FIX(LIBRAW_PROGRESS_PRE_INTERPOLATE));
835
+ rb_define_const(rb_mProgress, "INTERPOLATE", INT2FIX(LIBRAW_PROGRESS_INTERPOLATE));
836
+ rb_define_const(rb_mProgress, "MIX_GREEN", INT2FIX(LIBRAW_PROGRESS_MIX_GREEN));
837
+ rb_define_const(rb_mProgress, "MEDIAN_FILTER", INT2FIX(LIBRAW_PROGRESS_MEDIAN_FILTER));
838
+ rb_define_const(rb_mProgress, "HIGHLIGHTS", INT2FIX(LIBRAW_PROGRESS_HIGHLIGHTS));
839
+ rb_define_const(rb_mProgress, "FUJI_ROTATE", INT2FIX(LIBRAW_PROGRESS_FUJI_ROTATE));
840
+ rb_define_const(rb_mProgress, "FLIP", INT2FIX(LIBRAW_PROGRESS_FLIP));
841
+ rb_define_const(rb_mProgress, "APPLY_PROFILE", INT2FIX(LIBRAW_PROGRESS_APPLY_PROFILE));
842
+ rb_define_const(rb_mProgress, "CONVERT_RGB", INT2FIX(LIBRAW_PROGRESS_CONVERT_RGB));
843
+ rb_define_const(rb_mProgress, "STRETCH", INT2FIX(LIBRAW_PROGRESS_STRETCH));
844
+
845
+ rb_define_const(rb_mProgress, "STAGE20", INT2FIX(LIBRAW_PROGRESS_STAGE20));
846
+ rb_define_const(rb_mProgress, "STAGE21", INT2FIX(LIBRAW_PROGRESS_STAGE21));
847
+ rb_define_const(rb_mProgress, "STAGE22", INT2FIX(LIBRAW_PROGRESS_STAGE22));
848
+ rb_define_const(rb_mProgress, "STAGE23", INT2FIX(LIBRAW_PROGRESS_STAGE23));
849
+ rb_define_const(rb_mProgress, "STAGE24", INT2FIX(LIBRAW_PROGRESS_STAGE24));
850
+ rb_define_const(rb_mProgress, "STAGE25", INT2FIX(LIBRAW_PROGRESS_STAGE25));
851
+ rb_define_const(rb_mProgress, "STAGE26", INT2FIX(LIBRAW_PROGRESS_STAGE26));
852
+ rb_define_const(rb_mProgress, "STAGE27", INT2FIX(LIBRAW_PROGRESS_STAGE27));
853
+
854
+ rb_define_const(rb_mProgress, "THUMB_LOAD", INT2FIX(LIBRAW_PROGRESS_THUMB_LOAD));
855
+ rb_define_const(rb_mProgress, "TRESERVED1", INT2FIX(LIBRAW_PROGRESS_TRESERVED1));
856
+ rb_define_const(rb_mProgress, "TRESERVED2", INT2FIX(LIBRAW_PROGRESS_TRESERVED2));
857
+ rb_define_const(rb_mProgress, "TRESERVED3", INT2FIX(LIBRAW_PROGRESS_TRESERVED3));
858
+
859
+
860
+ // LibRaw::ThumbnailFormat
861
+
862
+ rb_mThumbnailFormat = rb_define_module_under(rb_mLibRaw, "ThumbnailFormat");
863
+
864
+ rb_define_const(rb_mThumbnailFormat, "UNKNOWN", INT2FIX(LIBRAW_THUMBNAIL_UNKNOWN));
865
+ rb_define_const(rb_mThumbnailFormat, "JPEG", INT2FIX(LIBRAW_THUMBNAIL_JPEG));
866
+ rb_define_const(rb_mThumbnailFormat, "BITMAP", INT2FIX(LIBRAW_THUMBNAIL_BITMAP));
867
+ rb_define_const(rb_mThumbnailFormat, "LAYER", INT2FIX(LIBRAW_THUMBNAIL_LAYER));
868
+ rb_define_const(rb_mThumbnailFormat, "ROLLEI", INT2FIX(LIBRAW_THUMBNAIL_ROLLEI));
869
+
870
+
871
+
872
+ // class
873
+
874
+ // LibRaw::RawObject
875
+
876
+ rb_cRawObject = rb_define_class_under(rb_mLibRaw, "RawObject", rb_cObject);
877
+
878
+ rb_define_attr(rb_cRawObject, "size", 1, 0);
879
+ rb_define_attr(rb_cRawObject, "idata", 1, 0);
880
+ rb_define_attr(rb_cRawObject, "lens", 1, 0);
881
+ rb_define_attr(rb_cRawObject, "other", 1, 0);
882
+ rb_define_attr(rb_cRawObject, "param", 1, 0);
883
+
884
+ rb_define_method(rb_cRawObject, "initialize", RUBY_METHOD_FUNC(rb_raw_object_initialize), 0);
885
+ rb_define_method(rb_cRawObject, "open_file", RUBY_METHOD_FUNC(rb_raw_object_open_file), 1);
886
+ rb_define_method(rb_cRawObject, "open_buffer", RUBY_METHOD_FUNC(rb_raw_object_open_buffer), 1);
887
+ rb_define_method(rb_cRawObject, "unpack", RUBY_METHOD_FUNC(rb_raw_object_unpack), 0);
888
+ rb_define_method(rb_cRawObject, "unpack_thumb", RUBY_METHOD_FUNC(rb_raw_object_unpack_thumb), 0);
889
+ rb_define_method(rb_cRawObject, "recycle_datastream", RUBY_METHOD_FUNC(rb_raw_object_recycle_datastream), 0);
890
+ rb_define_method(rb_cRawObject, "recycle", RUBY_METHOD_FUNC(rb_raw_object_recycle), 0);
891
+ rb_define_method(rb_cRawObject, "dcraw_ppm_tiff_writer", RUBY_METHOD_FUNC(rb_raw_object_dcraw_ppm_tiff_writer), 1);
892
+ rb_define_method(rb_cRawObject, "dcraw_thumb_writer", RUBY_METHOD_FUNC(rb_raw_object_dcraw_thumb_writer), 1);
893
+ rb_define_method(rb_cRawObject, "dcraw_process", RUBY_METHOD_FUNC(rb_raw_object_dcraw_process), 1);
894
+
895
+
896
+ // LibRaw::IParam
897
+
898
+ rb_cIParam = rb_define_class_under(rb_mLibRaw, "IParam", rb_cObject);
899
+
900
+ rb_define_attr(rb_cIParam, "make", 1, 0);
901
+ rb_define_attr(rb_cIParam, "model", 1, 0);
902
+ rb_define_attr(rb_cIParam, "software", 1, 0);
903
+ rb_define_attr(rb_cIParam, "raw_count", 1, 0);
904
+ rb_define_attr(rb_cIParam, "dng_version", 1, 0);
905
+ rb_define_attr(rb_cIParam, "is_foveon", 1, 0);
906
+ rb_define_attr(rb_cIParam, "colors", 1, 0);
907
+ rb_define_attr(rb_cIParam, "filters", 1, 0);
908
+ rb_define_attr(rb_cIParam, "cdesc", 1, 0);
909
+
910
+
911
+ // LibRaw::ImageSize
912
+
913
+ rb_cImageSize = rb_define_class_under(rb_mLibRaw, "ImageSize", rb_cObject);
914
+
915
+ rb_define_attr(rb_cImageSize, "raw_height", 1, 0);
916
+ rb_define_attr(rb_cImageSize, "raw_width", 1, 0);
917
+ rb_define_attr(rb_cImageSize, "height", 1, 0);
918
+ rb_define_attr(rb_cImageSize, "width", 1, 0);
919
+ rb_define_attr(rb_cImageSize, "top_margin", 1, 0);
920
+ rb_define_attr(rb_cImageSize, "left_margin", 1, 0);
921
+ rb_define_attr(rb_cImageSize, "iheight", 1, 0);
922
+ rb_define_attr(rb_cImageSize, "iwidth", 1, 0);
923
+ rb_define_attr(rb_cImageSize, "raw_pitch", 1, 0);
924
+ rb_define_attr(rb_cImageSize, "pixel_aspect", 1, 0);
925
+ rb_define_attr(rb_cImageSize, "flip", 1, 0);
926
+
927
+
928
+ // LibRaw::ImgOther
929
+
930
+ rb_cImgOther = rb_define_class_under(rb_mLibRaw, "ImgOther", rb_cObject);
931
+
932
+ rb_define_attr(rb_cImgOther, "iso_speed", 1, 0);
933
+ rb_define_attr(rb_cImgOther, "shutter", 1, 0);
934
+ rb_define_attr(rb_cImgOther, "aperture", 1, 0);
935
+ rb_define_attr(rb_cImgOther, "focal_len", 1, 0);
936
+ rb_define_attr(rb_cImgOther, "timestamp", 1, 0);
937
+ rb_define_attr(rb_cImgOther, "shot_order", 1, 0);
938
+ rb_define_attr(rb_cImgOther, "desc", 1, 0);
939
+ rb_define_attr(rb_cImgOther, "artist", 1, 0);
940
+
941
+
942
+ // LibRaw::OutputParam
943
+
944
+ rb_cOutputParam = rb_define_class_under(rb_mLibRaw, "OutputParam", rb_cObject);
945
+
946
+ rb_define_attr(rb_cOutputParam, "shot_select", 1, 0);
947
+ rb_define_attr(rb_cOutputParam, "bright", 1, 0);
948
+ rb_define_attr(rb_cOutputParam, "threshold", 1, 0);
949
+ rb_define_attr(rb_cOutputParam, "half_size", 1, 0);
950
+ rb_define_attr(rb_cOutputParam, "four_color_rgb", 1, 0);
951
+ rb_define_attr(rb_cOutputParam, "highlight", 1, 0);
952
+ rb_define_attr(rb_cOutputParam, "use_auto_wb", 1, 0);
953
+ rb_define_attr(rb_cOutputParam, "use_camera_wb", 1, 0);
954
+ rb_define_attr(rb_cOutputParam, "use_camera_matrix", 1, 0);
955
+ rb_define_attr(rb_cOutputParam, "output_color", 1, 0);
956
+ rb_define_attr(rb_cOutputParam, "output_bps", 1, 0);
957
+ rb_define_attr(rb_cOutputParam, "output_tiff", 1, 0);
958
+ rb_define_attr(rb_cOutputParam, "user_flip", 1, 0);
959
+ rb_define_attr(rb_cOutputParam, "user_qual", 1, 0);
960
+ rb_define_attr(rb_cOutputParam, "user_black", 1, 0);
961
+ rb_define_attr(rb_cOutputParam, "user_sat", 1, 0);
962
+ rb_define_attr(rb_cOutputParam, "med_passes", 1, 0);
963
+ rb_define_attr(rb_cOutputParam, "auto_bright_thr", 1, 0);
964
+ rb_define_attr(rb_cOutputParam, "adjust_maximum_thr", 1, 0);
965
+ rb_define_attr(rb_cOutputParam, "no_auto_bright", 1, 0);
966
+ rb_define_attr(rb_cOutputParam, "use_fuji_rotate", 1, 0);
967
+ rb_define_attr(rb_cOutputParam, "green_matching", 1, 0);
968
+
969
+ rb_define_attr(rb_cOutputParam, "dcb_iterations", 1, 0);
970
+ rb_define_attr(rb_cOutputParam, "dcb_enhance_fl", 1, 0);
971
+ rb_define_attr(rb_cOutputParam, "fbdd_noiserd", 1, 0);
972
+
973
+ rb_define_attr(rb_cOutputParam, "eeci_refine", 1, 0);
974
+ rb_define_attr(rb_cOutputParam, "es_med_passes", 1, 0);
975
+
976
+ rb_define_attr(rb_cOutputParam, "ca_correc", 1, 0);
977
+ rb_define_attr(rb_cOutputParam, "cared", 1, 0);
978
+ rb_define_attr(rb_cOutputParam, "cablue", 1, 0);
979
+ rb_define_attr(rb_cOutputParam, "cfaline", 1, 0);
980
+ rb_define_attr(rb_cOutputParam, "linenoise", 1, 0);
981
+ rb_define_attr(rb_cOutputParam, "cfa_clean", 1, 0);
982
+ rb_define_attr(rb_cOutputParam, "lclean", 1, 0);
983
+ rb_define_attr(rb_cOutputParam, "cclean", 1, 0);
984
+ rb_define_attr(rb_cOutputParam, "cfa_green", 1, 0);
985
+ rb_define_attr(rb_cOutputParam, "green_thresh", 1, 0);
986
+ rb_define_attr(rb_cOutputParam, "exp_correc", 1, 0);
987
+ rb_define_attr(rb_cOutputParam, "exp_shift", 1, 0);
988
+ rb_define_attr(rb_cOutputParam, "exp_preser", 1, 0);
989
+
990
+ rb_define_attr(rb_cOutputParam, "wf_debanding", 1, 0);
991
+
992
+ rb_define_attr(rb_cOutputParam, "use_rawspeed", 1, 0);
993
+
994
+ rb_define_attr(rb_cOutputParam, "no_auto_scale", 1, 0);
995
+
996
+ rb_define_attr(rb_cOutputParam, "no_interpolation", 1, 0);
997
+
998
+ rb_define_attr(rb_cOutputParam, "sraw_ycc", 1, 0);
999
+
1000
+ rb_define_attr(rb_cOutputParam, "force_foveon_x3f", 1, 0);
1001
+ rb_define_attr(rb_cOutputParam, "x3f_flags", 1, 0);
1002
+
1003
+ rb_define_attr(rb_cOutputParam, "sony_arw2_options", 1, 0);
1004
+ rb_define_attr(rb_cOutputParam, "sony_arw2_posterization_thr", 1, 0);
1005
+
1006
+ rb_define_attr(rb_cOutputParam, "coolscan_nef_gamma", 1, 0);
1007
+
1008
+ rb_define_method(rb_cOutputParam, "initialize", RUBY_METHOD_FUNC(rb_output_param_initialize), 0);
1009
+ rb_define_method(rb_cOutputParam, "greybox", RUBY_METHOD_FUNC(rb_output_param_greybox), 4);
1010
+ rb_define_method(rb_cOutputParam, "cropbox", RUBY_METHOD_FUNC(rb_output_param_cropbox), 4);
1011
+ rb_define_method(rb_cOutputParam, "gamma", RUBY_METHOD_FUNC(rb_output_param_gamma), 2);
1012
+ rb_define_method(rb_cOutputParam, "whitebalance", RUBY_METHOD_FUNC(rb_output_param_whitebalance), 4);
1013
+ rb_define_method(rb_cOutputParam, "bright=", RUBY_METHOD_FUNC(rb_output_param_set_bright), 1);
1014
+ rb_define_method(rb_cOutputParam, "highlight=", RUBY_METHOD_FUNC(rb_output_param_set_highlight), 1);
1015
+ rb_define_method(rb_cOutputParam, "use_auto_wb=", RUBY_METHOD_FUNC(rb_output_param_set_use_auto_wb), 1);
1016
+ rb_define_method(rb_cOutputParam, "use_camera_wb=", RUBY_METHOD_FUNC(rb_output_param_set_use_camera_wb), 1);
1017
+ rb_define_method(rb_cOutputParam, "fbdd_noiserd=", RUBY_METHOD_FUNC(rb_output_param_set_fbdd_noiserd), 1);
1018
+
1019
+
1020
+ // LibRaw::MakerNote
1021
+
1022
+ rb_cMakerNote = rb_define_class_under(rb_mLibRaw, "MakerNote", rb_cObject);
1023
+
1024
+ rb_define_attr(rb_cMakerNote, "lens_id", 1, 0);
1025
+ rb_define_attr(rb_cMakerNote, "lens", 1, 0);
1026
+ rb_define_attr(rb_cMakerNote, "lens_format", 1, 0);
1027
+ rb_define_attr(rb_cMakerNote, "lens_mount", 1, 0);
1028
+ rb_define_attr(rb_cMakerNote, "cam_id", 1, 0);
1029
+ rb_define_attr(rb_cMakerNote, "camera_format", 1, 0);
1030
+ rb_define_attr(rb_cMakerNote, "camera_mount", 1, 0);
1031
+ rb_define_attr(rb_cMakerNote, "body", 1, 0);
1032
+ rb_define_attr(rb_cMakerNote, "focal_type", 1, 0);
1033
+ rb_define_attr(rb_cMakerNote, "lens_features_pre", 1, 0);
1034
+ rb_define_attr(rb_cMakerNote, "lens_features_suf", 1, 0);
1035
+ rb_define_attr(rb_cMakerNote, "min_focal", 1, 0);
1036
+ rb_define_attr(rb_cMakerNote, "max_focal", 1, 0);
1037
+ rb_define_attr(rb_cMakerNote, "max_ap_4_min_focal", 1, 0);
1038
+ rb_define_attr(rb_cMakerNote, "max_ap_4_max_focal", 1, 0);
1039
+ rb_define_attr(rb_cMakerNote, "min_ap_4_min_focal", 1, 0);
1040
+ rb_define_attr(rb_cMakerNote, "min_ap_4_max_focal", 1, 0);
1041
+ rb_define_attr(rb_cMakerNote, "max_ap", 1, 0);
1042
+ rb_define_attr(rb_cMakerNote, "min_ap", 1, 0);
1043
+ rb_define_attr(rb_cMakerNote, "cur_focal", 1, 0);
1044
+ rb_define_attr(rb_cMakerNote, "cur_ap", 1, 0);
1045
+ rb_define_attr(rb_cMakerNote, "max_ap_4_cur_focal", 1, 0);
1046
+ rb_define_attr(rb_cMakerNote, "min_ap_4_cur_focal", 1, 0);
1047
+ rb_define_attr(rb_cMakerNote, "lens_f_stops", 1, 0);
1048
+ rb_define_attr(rb_cMakerNote, "teleconverter_id", 1, 0);
1049
+ rb_define_attr(rb_cMakerNote, "teleconverter", 1, 0);
1050
+ rb_define_attr(rb_cMakerNote, "adapter_id", 1, 0);
1051
+ rb_define_attr(rb_cMakerNote, "adapter", 1, 0);
1052
+ rb_define_attr(rb_cMakerNote, "attachment_id", 1, 0);
1053
+ rb_define_attr(rb_cMakerNote, "attachment", 1, 0);
1054
+ rb_define_attr(rb_cMakerNote, "canon_focal_units", 1, 0);
1055
+ rb_define_attr(rb_cMakerNote, "focal_length_in_35mm_format", 1, 0);
1056
+
1057
+
1058
+ // LibRaw::LensInfo
1059
+
1060
+ rb_cLensInfo = rb_define_class_under(rb_mLibRaw, "LensInfo", rb_cObject);
1061
+ rb_define_attr(rb_cLensInfo, "min_focal", 1, 0);
1062
+ rb_define_attr(rb_cLensInfo, "max_focal", 1, 0);
1063
+ rb_define_attr(rb_cLensInfo, "max_ap_4_min_focal", 1, 0);
1064
+ rb_define_attr(rb_cLensInfo, "max_ap_4_max_focal", 1, 0);
1065
+ rb_define_attr(rb_cLensInfo, "exif_max_ap", 1, 0);
1066
+ rb_define_attr(rb_cLensInfo, "lens_make", 1, 0);
1067
+ rb_define_attr(rb_cLensInfo, "lens", 1, 0);
1068
+ rb_define_attr(rb_cLensInfo, "focal_length_in_35mm_format", 1, 0);
1069
+ rb_define_attr(rb_cLensInfo, "nikon", 1, 0);
1070
+ rb_define_attr(rb_cLensInfo, "dng", 1, 0);
1071
+ rb_define_attr(rb_cLensInfo, "makernotes", 1, 0);
1072
+
1073
+
1074
+ // Error
1075
+
1076
+ // LibRaw::RawError
1077
+ rb_eRawError = rb_define_class_under(rb_mLibRaw, "RawError", rb_eStandardError);
1078
+
1079
+ // LibRaw::UnspecifiedError
1080
+ rb_eUnspecifiedError = rb_define_class_under(rb_mLibRaw, "UnspecifiedError", rb_eRawError);
1081
+
1082
+ // LibRaw::FileUnsupported
1083
+ rb_eFileUnsupported = rb_define_class_under(rb_mLibRaw, "FileUnsupported", rb_eRawError);
1084
+
1085
+ // LibRaw::RequestForNonexistentImage
1086
+ rb_eRequestForNonexistentImage = rb_define_class_under(rb_mLibRaw, "RequestForNonexistentImage", rb_eRawError);
1087
+
1088
+ // LibRaw::OutOfOrderCall
1089
+ rb_eOutOfOrderCall = rb_define_class_under(rb_mLibRaw, "OutOfOrderCall", rb_eRawError);
1090
+
1091
+ // LibRaw::NoThumbnail
1092
+ rb_eNoThumbnail = rb_define_class_under(rb_mLibRaw, "NoThumbnail", rb_eRawError);
1093
+
1094
+ // LibRaw::UnsupportedThumbnail
1095
+ rb_eUnsupportedThumbnail = rb_define_class_under(rb_mLibRaw, "UnsupportedThumbnail", rb_eRawError);
1096
+
1097
+ // LibRaw::InputClosed
1098
+ rb_eInputClosed = rb_define_class_under(rb_mLibRaw, "InputClosed", rb_eRawError);
1099
+
1100
+ // LibRaw::UnsufficientMemory
1101
+ rb_eUnsufficientMemory = rb_define_class_under(rb_mLibRaw, "UnsufficientMemory", rb_eRawError);
1102
+
1103
+ // LibRaw::DataError
1104
+ rb_eDataError = rb_define_class_under(rb_mLibRaw, "DataError", rb_eRawError);
1105
+
1106
+ // LibRaw::IOError
1107
+ rb_eIOError = rb_define_class_under(rb_mLibRaw, "IOError", rb_eRawError);
1108
+
1109
+ // LibRaw::CancelledByCallback
1110
+ rb_eCancelledByCallback = rb_define_class_under(rb_mLibRaw, "CancelledByCallback", rb_eRawError);
1111
+
1112
+ // LibRaw::BadCrop
1113
+ rb_eBadCrop = rb_define_class_under(rb_mLibRaw, "BadCrop", rb_eRawError);
1114
+ }