summaryrefslogtreecommitdiff
path: root/src/qhyccd/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/qhyccd/mod.rs')
-rw-r--r--src/qhyccd/mod.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/qhyccd/mod.rs b/src/qhyccd/mod.rs
index 654d743..0967b7e 100644
--- a/src/qhyccd/mod.rs
+++ b/src/qhyccd/mod.rs
@@ -257,11 +257,19 @@ impl Camera {
bufsize as usize
)
};
- for i in 0..(bufsize as usize / 2) {
- let tmp = dataslice[i * 2];
- dataslice[i * 2] = dataslice[i * 2 + 1];
- dataslice[i * 2 + 1] = tmp;
+ for i in 0..(dataslice.len() / 6) {
+ let (b_low, b_high) = (dataslice[i * 6], dataslice[i * 6 + 1]);
+ let tmp2 = dataslice[i * 6 + 1];
+ dataslice[i * 6 + 1] = dataslice[i * 6 + 4];
+ dataslice[i * 6] = dataslice[i * 6 + 5];
+ dataslice[i * 6 + 4] = b_high;
+ dataslice[i * 6 + 5] = b_low;
+
+ let g_low = dataslice[i * 6 + 2];
+ dataslice[i * 6 + 2] = dataslice[i * 6 + 3];
+ dataslice[i * 6 + 3] = g_low;
}
+ println!("the amount of data mod 6: {}", dataslice.len() % 6);
let mut writer = encoder.write_header().unwrap();
writer.write_image_data(dataslice).unwrap();
dealloc(data as *mut u8, data_layout);