1/* Copyright 2016 Software Freedom Conservancy Inc. 2 * 3 * This software is licensed under the GNU Lesser General Public License 4 * (version 2.1 or later). See the COPYING file in this distribution. 5 */ 6 7[CCode (cprefix="libraw_", cheader_filename="libraw/libraw.h")] 8namespace LibRaw { 9 10[CCode (cname="LIBRAW_CHECK_VERSION")] 11public bool check_version(int major, int minor, int patch); 12 13public unowned string version(); 14 15public unowned string versionNumber(); 16 17[SimpleType] 18[CCode (cname="libraw_imgother_t")] 19public struct ImageOther { 20 public float iso_speed; 21 public float shutter; 22 public float aperture; 23 public float focal_len; 24 public time_t timestamp; 25 public uint shot_order; 26 public uint gpsdata[32]; 27 public char desc[512]; 28 public char artist[64]; 29} 30 31[SimpleType] 32[CCode (cname="libraw_iparams_t")] 33public struct ImageParams { 34 public uint raw_count; 35 public uint dng_version; 36 public bool is_foveon; 37 public int colors; 38 public uint filters; 39 40 public char *make; 41 public char *model; 42 public char *cdesc; 43 44 public string get_make() { 45 return build_string(make, 64); 46 } 47 48 public string get_model() { 49 return build_string(model, 64); 50 } 51 52 public string get_cdesc() { 53 return build_string(cdesc, 5); 54 } 55 56 private static string build_string(char *array, int len) { 57 GLib.StringBuilder builder = new GLib.StringBuilder(); 58 for (int ctr = 0; ctr < len; ctr++) { 59 if (array[ctr] != '\0') 60 builder.append_c(array[ctr]); 61 else 62 break; 63 } 64 65 return builder.str; 66 } 67} 68 69[SimpleType] 70[CCode (cname="libraw_image_sizes_t")] 71public struct ImageSizes { 72 public ushort raw_height; 73 public ushort raw_width; 74 public ushort height; 75 public ushort width; 76 public ushort top_margin; 77 public ushort left_margin; 78 public ushort iheight; 79 public ushort iwidth; 80 public double pixel_aspect; 81 public int flip; 82 public ushort right_margin; 83 public ushort bottom_margin; 84} 85 86[CCode (cname="enum LibRaw_constructor_flags", cprefix="LIBRAW_OPIONS_")] 87public enum Options { 88 [CCode (cname="LIBRAW_OPTIONS_NONE")] 89 NONE, 90 NO_MEMERR_CALLBACK, 91 NO_DATAERR_CALLBACK 92} 93 94[SimpleType] 95[CCode (cname="libraw_output_params_t")] 96public struct OutputParams { 97 public uint greybox[4]; 98 public double aber[4]; 99 public double gamm[6]; 100 public float user_mul[4]; 101 public uint shot_select; 102 public uint multi_out; 103 public float bright; 104 public float threshold; 105 public bool half_size; 106 public bool four_color_rgb; 107 public int highlight; 108 public bool use_auto_wb; 109 public bool use_camera_wb; 110 public int use_camera_matrix; 111 public int output_color; 112 public int output_bps; 113 public bool output_tiff; 114 public int user_flip; 115 public int user_qual; 116 public int user_black; 117 public int user_sat; 118 public int med_passes; 119 public bool no_auto_bright; 120 public float auto_bright_thr; 121 public int use_fuji_rotate; 122 public int green_matching; 123 124 /* DCB parameters */ 125 public int dcb_iterations; 126 public int dcb_enhance_fl; 127 public int fbdd_noiserd; 128 129 /* VCD parameters */ 130 public int eeci_refine; 131 public int es_med_passes; 132 /* AMaZE*/ 133 public int ca_correc; 134 public float cared; 135 public float cablue; 136 public int cfaline; 137 public float linenoise; 138 public int cfa_clean; 139 public float lclean; 140 public float cclean; 141 public int cfa_green; 142 public float green_thresh; 143 public int exp_correc; 144 public float exp_shift; 145 public float exp_preser; 146 147 public static void set_chromatic_aberrations(OutputParams* params, double red_multiplier, double green_multiplier) { 148 params->aber[0] = red_multiplier; 149 params->aber[2] = green_multiplier; 150 } 151 152 public static void set_gamma_curve(OutputParams* params, double power, double slope) { 153 params->gamm[0] = 1.0 / power; 154 params->gamm[1] = slope; 155 } 156} 157 158[Compact] 159[CCode (cname="libraw_processed_image_t", free_function="free")] 160public class ProcessedImage { 161 public ushort height; 162 public ushort width; 163 public ushort colors; 164 public ushort bits; 165 public uint data_size; 166 [CCode (array_length_cname="data_size")] 167 public uint8[] data; 168} 169 170[Compact] 171[CCode (cname="libraw_data_t", cprefix="libraw_", free_function="libraw_close")] 172public class Processor { 173 public OutputParams params; 174 175 private Progress progress_flags; 176 private Warnings process_warnings; 177 private ImageParams idata; 178 private ImageSizes sizes; 179 private ImageOther other; 180 private Thumbnail thumbnail; 181 182 [CCode (cname="libraw_init")] 183 public Processor(Options flags = Options.NONE); 184 185 public Result adjust_sizes_info_only(); 186 [CCode (cname="libraw_dcraw_document_mode_processing")] 187 public Result document_mode_processing(); 188 public unowned ImageOther get_image_other() { return other; } 189 public unowned ImageParams get_image_params() { return idata; } 190 public Progress get_progress_flags() { return progress_flags; } 191 public Warnings get_process_warnings() { return process_warnings; } 192 public unowned ImageSizes get_sizes() { return sizes; } 193 public unowned Thumbnail get_thumbnail() { return thumbnail; } 194 [CCode (cname="libraw_dcraw_make_mem_image")] 195 public ProcessedImage make_mem_image(ref Result result); 196 [CCode (cname="libraw_dcraw_make_mem_thumb")] 197 public ProcessedImage make_mem_thumb(ref Result result); 198 public Result open_buffer(uint8[] buffer); 199 public Result open_file(string filename); 200 [CCode (cname="libraw_dcraw_process")] 201 public Result process(); 202 [CCode (cname="libraw_dcraw_ppm_tiff_writer")] 203 public Result ppm_tiff_writer(string outfile); 204 public void recycle(); 205 public Result rotate_fuji_raw(); 206 [CCode (cname="libraw_dcraw_thumb_writer")] 207 public Result thumb_writer(string outfile); 208 public Result unpack(); 209 public Result unpack_thumb(); 210} 211 212[CCode (cname="enum LibRaw_progress", cprefix="LIBRAW_PROGRESS_")] 213public enum Progress { 214 START; 215 216 [CCode (cname="libraw_strprogress")] 217 public unowned string to_string(); 218} 219 220[CCode (cname="enum LibRaw_errors", cprefix="LIBRAW_")] 221public enum Result { 222 SUCCESS, 223 UNSPECIFIED_ERROR, 224 FILE_UNSUPPORTED, 225 REQUEST_FOR_NONEXISTENT_IMAGE, 226 OUT_OF_ORDER_CALL, 227 NO_THUMBNAIL, 228 UNSUPPORTED_THUMBNAIL, 229 UNSUFFICIENT_MEMORY, 230 DATA_ERROR, 231 IO_ERROR, 232 CANCELLED_BY_CALLBACK, 233 BAD_CROP; 234 235 [CCode (cname="LIBRAW_FATAL_ERROR")] 236 public bool is_fatal_error(); 237 238 [CCode (cname="libraw_strerror")] 239 public unowned string to_string(); 240} 241 242[SimpleType] 243[CCode (cname="libraw_thumbnail_t")] 244public struct Thumbnail { 245 public ThumbnailFormat tformat; 246 public ushort twidth; 247 public ushort theight; 248 public uint tlength; 249 public int tcolors; 250 [CCode (array_length_cname="tlength")] 251 public unowned uint8[] thumb; 252} 253 254[CCode (cname="enum LibRaw_thumbnail_formats", cprefix="LIBRAW_THUMBNAIL_")] 255public enum ThumbnailFormat { 256 UNKNOWN, 257 JPEG, 258 BITMAP, 259 LAYER, 260 ROLLEI; 261} 262 263[CCode (cname="enum LibRaw_warnings", cprefix="LIBRAW_WARN_")] 264public enum Warnings { 265 NONE 266} 267 268} 269 270