fix(#4): apply shadows, whites, blacks, vibrance, temperature, tint params
This commit is contained in:
parent
bab2f17533
commit
6db7d6f56d
48
src/main.rs
48
src/main.rs
@ -287,6 +287,54 @@ fn apply_image_parameters(lr: *mut libraw_data_t, args: &Args) {
|
||||
libraw_set_fbdd_noiserd(lr, value);
|
||||
}
|
||||
|
||||
// Apply shadows adjustment (map to brightness for dark areas)
|
||||
if args.shadows != 0 && !lr.is_null() {
|
||||
let value = args.shadows.min(100).max(-100) as f32 / 100.0 * 200.0;
|
||||
libraw_set_bright(lr, value);
|
||||
}
|
||||
|
||||
// Apply whites adjustment (map to highlight recovery)
|
||||
if args.whites != 0 && !lr.is_null() {
|
||||
let value = args.whites.min(100).max(-100) as c_int;
|
||||
libraw_set_highlight(lr, value);
|
||||
}
|
||||
|
||||
// Apply blacks adjustment (map to brightness offset for dark point)
|
||||
if args.blacks != 0 && !lr.is_null() {
|
||||
let value = args.blacks.min(100).max(-100) as f32 / 100.0 * -100.0;
|
||||
libraw_set_bright(lr, value);
|
||||
}
|
||||
|
||||
// Apply vibrance adjustment (selective saturation, map to saturation multiplier)
|
||||
if args.vibrance != 0 && !lr.is_null() {
|
||||
let value = 1.0 + args.vibrance.min(100).max(-100) as f32 / 200.0;
|
||||
libraw_set_gamma(lr, 0, value);
|
||||
}
|
||||
|
||||
// Apply temperature adjustment (white balance via user_mul)
|
||||
if args.temperature != 0 && !lr.is_null() {
|
||||
let temp_mul = [
|
||||
256i16 as c_int,
|
||||
256i16 as c_int + args.temperature.min(100).max(-100) as c_int,
|
||||
256i16 as c_int,
|
||||
256i16 as c_int,
|
||||
];
|
||||
libraw_set_user_mul(lr, temp_mul.as_ptr());
|
||||
libraw_set_use_auto_wb(lr, 0);
|
||||
}
|
||||
|
||||
// Apply tint adjustment (green-magenta white balance axis)
|
||||
if args.tint != 0 && !lr.is_null() {
|
||||
let tint_mul = [
|
||||
256i16 as c_int + args.tint.min(100).max(-100) as c_int,
|
||||
256i16 as c_int,
|
||||
256i16 as c_int,
|
||||
256i16 as c_int - args.tint.min(100).max(-100) as c_int,
|
||||
];
|
||||
libraw_set_user_mul(lr, tint_mul.as_ptr());
|
||||
libraw_set_use_auto_wb(lr, 0);
|
||||
}
|
||||
|
||||
// Apply saturation
|
||||
if args.saturation != 0 && !lr.is_null() {
|
||||
let value = 1.0 + args.saturation.min(100).max(-100) as f32 / 100.0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user