Class: Rubyraw::Raw

Inherits:
Object
  • Object
show all
Defined in:
ext/rubyraw/rubyraw.c

Instance Method Summary collapse

Instance Method Details

#decode(path, opt) ⇒ Object



10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
# File 'ext/rubyraw/rubyraw.c', line 10151

VALUE
decode(VALUE self, VALUE path, VALUE opt){
    Check_Type(path, T_STRING);

    char* v[16] = {0};
    int c = 0;
    int debug_mode = 0;
    v[c++] = "ruby.exe";

    if(opt != Qnil){
        if(Qtrue == rb_hash_aref(opt, ID2SYM(rb_intern("debug_mode"))))
            debug_mode = 1;

        if(Qtrue == rb_hash_aref(opt, ID2SYM(rb_intern("print_message"))))
            v[c++] = "-v";

        if(Qtrue == rb_hash_aref(opt, ID2SYM(rb_intern("apply_awb"))))
            v[c++] = "-a";

        if(Qtrue == rb_hash_aref(opt, ID2SYM(rb_intern("tiff_mode"))))
            v[c++] = "-T";
    }

    v[c++] = StringValuePtr(path);

    if(debug_mode!=0){
        for(int i=0; i<c; i++){
            printf("\narg[%d]:%s\n", i, v[i]);
        }
    }

#if 0
    if(TYPE(opt)!=T_NIL){
        Check_Type(opt, T_HASH);
        VALUE param;
        VALUE opt_print = StringValuePtr("print");
        if( rb_hash_has_key(opt, opt_print) == Qtrue){
            //param = rb_hash_fetch(opt, rb_str_new2("print"));
            c++;
            v[2] = "-v";
        }
    }
    printf(_("\nRaw photo decoder \"dcraw\" v%s"), DCRAW_VERSION);
    printf(_("\nby Dave Coffin, dcoffin a cybercom o net\n"));
    printf(_("\nUsage:  %s [OPTION]... [FILE]...\n\n"), argv[0]);
    o puts(_("-v        Print verbose messages"));
      puts(_("-c        Write image data to standard output"));
      puts(_("-e        Extract embedded thumbnail image"));
      puts(_("-i        Identify files without decoding them"));
      puts(_("-i -v     Identify files and show metadata"));
      puts(_("-z        Change file dates to camera timestamp"));
      puts(_("-w        Use camera white balance, if possible"));
    o puts(_("-a        Average the whole image for white balance"));
      puts(_("-A <x y w h> Average a grey box for white balance"));
      puts(_("-r <r g b g> Set custom white balance"));
      puts(_("+M/-M     Use/don't use an embedded color matrix"));
      puts(_("-C <r b>  Correct chromatic aberration"));
      puts(_("-P <file> Fix the dead pixels listed in this file"));
      puts(_("-K <file> Subtract dark frame (16-bit raw PGM)"));
      puts(_("-k <num>  Set the darkness level"));
      puts(_("-S <num>  Set the saturation level"));
      puts(_("-n <num>  Set threshold for wavelet denoising"));
      puts(_("-H [0-9]  Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)"));
      puts(_("-t [0-7]  Flip image (0=none, 3=180, 5=90CCW, 6=90CW)"));
      puts(_("-o [0-5]  Output colorspace (raw,sRGB,Adobe,Wide,ProPhoto,XYZ)"));
#ifn  def NO_LCMS
      puts(_("-o <file> Apply output ICC profile from file"));
      puts(_("-p <file> Apply camera ICC profile from file or \"embed\""));
#end  if
      puts(_("-d        Document mode (no color, no interpolation)"));
      puts(_("-D        Document mode without scaling (totally raw)"));
      puts(_("-j        Don't stretch or rotate raw pixels"));
      puts(_("-W        Don't automatically brighten the image"));
      puts(_("-b <num>  Adjust brightness (default = 1.0)"));
      puts(_("-g <p ts> Set custom gamma curve (default = 2.222 4.5)"));
      puts(_("-q [0-3]  Set the interpolation quality"));
      puts(_("-h        Half-size color image (twice as fast as \"-q 0\")"));
      puts(_("-f        Interpolate RGGB as four colors"));
      puts(_("-m <num>  Apply a 3x3 median filter to R-G and B-G"));
      puts(_("-s [0..N-1] Select one raw image or \"all\" from each file"));
      puts(_("-6        Write 16-bit instead of 8-bit"));
      puts(_("-4        Linear 16-bit, same as \"-6 -W -g 1 1\""));
      puts(_("-T        Write TIFF instead of PPM"));
#endif


    decode_raw(c, &v);

    return INT2NUM(0);
}