pub struct CfaPattern(/* private fields */);Expand description
CFA (Colour Filter Array) pattern with validation
- Bayer 2×2: 4 bytes like
[b'R', b'G', b'G', b'B'] - X-Trans 6×6: 36 bytes
- Valid colours: R, G, B, C (Cyan), Y (Yellow), W (White), E (Emerald)
Implementations§
Source§impl CfaPattern
impl CfaPattern
Sourcepub fn new(pattern: Vec<u8>) -> Result<Self, String>
pub fn new(pattern: Vec<u8>) -> Result<Self, String>
Examples found in repository?
examples/create_test_vsf.rs (line 16)
9fn main() {
10 // Create a simple 8x8 test image
11 let samples: Vec<u64> = (0..64).map(|i| i * 4).collect(); // 0, 4, 8, 12, ..., 252
12 let image = BitPackedTensor::pack(8, vec![8, 8], &samples);
13
14 // Create metadata
15 let metadata = RawMetadata {
16 cfa_pattern: Some(CfaPattern::new(vec![b'R', b'G', b'G', b'B']).unwrap()), // RGGB Bayer pattern
17 black_level: Some(BlackLevel::new(64.0).unwrap()),
18 white_level: Some(WhiteLevel::new(255.0).unwrap()),
19 dark_frame_hash: None,
20 flat_field_hash: None,
21 bias_frame_hash: None,
22 vignette_correction_hash: None,
23 distortion_correction_hash: None,
24 magic_9: None,
25 };
26
27 // Create camera settings
28 let camera = CameraSettings {
29 make: None,
30 model: None,
31 serial_number: None,
32 iso_speed: Some(IsoSpeed::new(800.0).unwrap()),
33 shutter_time_s: Some(ShutterTime::new(1.0 / 60.0).unwrap()), // 1/60 second
34 aperture_f_number: Some(Aperture::new(2.8).unwrap()),
35 focal_length_m: Some(FocalLength::new(0.050).unwrap()), // 50mm
36 exposure_compensation: None,
37 focus_distance_m: Some(FocusDistance::new(3.5).unwrap()),
38 flash_fired: Some(FlashFired::new(false).unwrap()),
39 metering_mode: Some(MeteringMode::new("matrix".to_string()).unwrap()),
40 };
41
42 // Build the VSF file
43 let bytes = build_raw_image(image, Some(metadata), Some(camera), None)
44 .expect("Failed to build VSF file");
45
46 // Write to file
47 std::fs::write("test_sample.vsf", &bytes).expect("Failed to write file");
48
49 println!("Created test_sample.vsf ({} bytes)", bytes.len());
50}pub fn to_vsf_type(self) -> VsfType
pub fn from_vsf_type(vsf: VsfType) -> Result<Self, String>
Trait Implementations§
Source§impl Clone for CfaPattern
impl Clone for CfaPattern
Source§fn clone(&self) -> CfaPattern
fn clone(&self) -> CfaPattern
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CfaPattern
impl RefUnwindSafe for CfaPattern
impl Send for CfaPattern
impl Sync for CfaPattern
impl Unpin for CfaPattern
impl UnsafeUnpin for CfaPattern
impl UnwindSafe for CfaPattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more