2026-07-09 02:59:53 +03:00
|
|
|
fn main() {
|
2026-07-13 14:37:22 +03:00
|
|
|
let base = "_images/_psd_stil_test/sultan_test/sultan";
|
2026-07-09 02:59:53 +03:00
|
|
|
|
|
|
|
|
// Load Layer 2 our output and reference
|
|
|
|
|
let layers = hcie_psd::import_psd(std::path::Path::new(&format!("{}/sultan_0003_Layer 2.psd", base))).unwrap();
|
|
|
|
|
let comp_layers: Vec<hcie_composite::Layer> = layers.iter().map(|l| hcie_composite::Layer {
|
|
|
|
|
name: l.name.clone(), layer_type: l.layer_type.clone(), data: l.data.clone(),
|
|
|
|
|
pixels: l.pixels.clone(), width: l.width, height: l.height,
|
|
|
|
|
visible: l.visible, opacity: l.opacity, blend_mode: l.blend_mode.clone(),
|
|
|
|
|
locked: l.locked, dirty: l.dirty, id: l.id, parent_id: l.parent_id,
|
|
|
|
|
styles: l.styles.clone(), clipping_mask: l.clipping_mask, collapsed: l.collapsed,
|
|
|
|
|
adjustment: l.adjustment.clone(), mask_pixels: l.mask_pixels.clone(),
|
|
|
|
|
mask_bounds: l.mask_bounds, mask_default_color: l.mask_default_color,
|
|
|
|
|
curve_points: l.curve_points.clone(), fill_opacity: l.fill_opacity,
|
|
|
|
|
effects: l.effects.clone(),
|
|
|
|
|
effects_dirty: std::sync::atomic::AtomicBool::new(false),
|
|
|
|
|
effects_cache: std::sync::Mutex::new(None),
|
|
|
|
|
adjustment_raw: None,
|
|
|
|
|
is_section_divider: false,
|
|
|
|
|
image_resources_raw: None,
|
|
|
|
|
}).collect();
|
|
|
|
|
let w = comp_layers[0].width;
|
|
|
|
|
let h = comp_layers[0].height;
|
|
|
|
|
let rendered = hcie_composite::composite_layers(&comp_layers, w, h);
|
|
|
|
|
let ref_img = image::open(&format!("{}/Layer 2.png", base)).unwrap().to_rgba8();
|
|
|
|
|
|
|
|
|
|
// Scan horizontal line at y=620 (worst area for Emboss)
|
|
|
|
|
println!("=== Horizontal scan at y=620 (Emboss worst area) ===");
|
|
|
|
|
for x in 175..=195 {
|
|
|
|
|
let i = (620 * w + x) as usize * 4;
|
|
|
|
|
let ri = (620 * ref_img.width() + x) as usize * 4;
|
|
|
|
|
let our = &rendered[i..i+4];
|
|
|
|
|
let refv = &ref_img.as_raw()[ri..ri+4];
|
|
|
|
|
let alpha_layer = layers[0].pixels[i+3]; // original alpha
|
|
|
|
|
let diff: f64 = (0..4).map(|c| (our[c] as f64 - refv[c] as f64).abs()).sum();
|
|
|
|
|
println!(" x={}: alpha_orig={} ours=({},{},{},{}) ref=({},{},{},{}) diff={:.0}",
|
|
|
|
|
x, alpha_layer, our[0], our[1], our[2], our[3], refv[0], refv[1], refv[2], refv[3], diff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Also scan around the shape boundary at various y values
|
|
|
|
|
println!("\n=== Shape boundary scan ===");
|
|
|
|
|
for y in [200, 400, 600] {
|
|
|
|
|
for x in [100, 200, 300, 400] {
|
|
|
|
|
let i = (y * w + x) as usize * 4;
|
|
|
|
|
let ri = (y * ref_img.width() + x) as usize * 4;
|
|
|
|
|
let our = &rendered[i..i+4];
|
|
|
|
|
let refv = &ref_img.as_raw()[ri..ri+4];
|
|
|
|
|
let alpha_layer = layers[0].pixels[i+3];
|
|
|
|
|
let diff: f64 = (0..4).map(|c| (our[c] as f64 - refv[c] as f64).abs()).sum();
|
|
|
|
|
if diff > 5.0 {
|
|
|
|
|
println!(" ({},{}) alpha_orig={} ours=({},{},{},{}) ref=({},{},{},{}) diff={:.0}",
|
|
|
|
|
x, y, alpha_layer, our[0], our[1], our[2], our[3], refv[0], refv[1], refv[2], refv[3], diff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scan the entire row y=620 and count pixels where alpha is > 0
|
|
|
|
|
println!("\n=== Alpha scan at y=620 ===");
|
|
|
|
|
let mut alpha_nonzero = 0;
|
|
|
|
|
for x in 0..w {
|
|
|
|
|
let i = (620 * w + x) as usize * 4;
|
|
|
|
|
if layers[0].pixels[i+3] > 0 { alpha_nonzero += 1; }
|
|
|
|
|
}
|
|
|
|
|
println!(" Pixels with alpha>0 at y=620: {}", alpha_nonzero);
|
|
|
|
|
|
|
|
|
|
// Sample the shape outline - find where alpha transitions
|
|
|
|
|
println!("\n=== Alpha transitions at y=620 ===");
|
|
|
|
|
let mut prev_alpha = 0u8;
|
|
|
|
|
for x in 0..w {
|
|
|
|
|
let i = (620 * w + x) as usize * 4;
|
|
|
|
|
let a = layers[0].pixels[i+3];
|
|
|
|
|
if (a > 0 && prev_alpha == 0) || (a == 0 && prev_alpha > 0) {
|
|
|
|
|
println!(" x={}: alpha {} -> {}", x, prev_alpha, a);
|
|
|
|
|
}
|
|
|
|
|
prev_alpha = a;
|
|
|
|
|
}
|
|
|
|
|
}
|