MCPcopy Create free account
hub / github.com/CapSoftware/scap / get_cropped_data

Function get_cropped_data

src/frame/mod.rs:122–138  ·  view source on GitHub ↗
(data: Vec<u8>, cur_width: i32, height: i32, width: i32)

Source from the content-addressed store, hash-verified

120}
121
122pub fn get_cropped_data(data: Vec<u8>, cur_width: i32, height: i32, width: i32) -> Vec<u8> {
123 if data.len() as i32 != height * cur_width * 4 {
124 data
125 } else {
126 let mut cropped_data: Vec<u8> = vec![0; (4 * height * width).try_into().unwrap()];
127 let mut cropped_data_index = 0;
128
129 for (i, item) in data.iter().enumerate() {
130 let x = i as i32 % (cur_width * 4);
131 if x < (width * 4) {
132 cropped_data[cropped_data_index] = *item;
133 cropped_data_index += 1;
134 }
135 }
136 cropped_data
137 }
138}
139
140#[cfg(test)]
141mod tests {

Callers 2

create_bgr_frameFunction · 0.85
create_rgb_frameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected