summaryrefslogtreecommitdiff
path: root/src/qhyccd
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2019-03-24 16:39:33 -0700
committeriximeow <me@iximeow.net>2019-03-24 16:39:33 -0700
commitc80c18604b20e0e79fc0d2666e9bab218cdb1e81 (patch)
tree12594872d33d5ac8e91fd71f52b96f41adb1b120 /src/qhyccd
parenta4d1f3e0ca4c9d686b8bac0871035cd11920b45c (diff)
swap red and blue from qhy camera, merge with endianness loop for perf (almost an additional second as separate steps)
Diffstat (limited to 'src/qhyccd')
-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);