MCPcopy Create free account
hub / github.com/OpenActionAPI/rust-elgato-streamdeck / send_image

Method send_image

src/lib.rs:274–306  ·  view source on GitHub ↗
(&self, key: u8, image_data: &[u8])

Source from the content-addressed store, hash-verified

272 }
273
274 fn send_image(&self, key: u8, image_data: &[u8]) -> Result<(), StreamDeckError> {
275 if key >= self.kind.key_count() {
276 return Err(StreamDeckError::InvalidKeyIndex);
277 }
278
279 let key = if let Kind::Original = self.kind { flip_key_index(&self.kind, key) } else { key };
280
281 if !self.kind.is_visual() {
282 return Err(StreamDeckError::NoScreen);
283 }
284
285 self.write_image_data_reports(
286 image_data,
287 WriteImageParameters::for_key(self.kind, image_data.len()),
288 |page_number, this_length, last_package| match self.kind {
289 Kind::Original => vec![0x02, 0x01, (page_number + 1) as u8, 0, if last_package { 1 } else { 0 }, key + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
290
291 Kind::Mini | Kind::MiniMk2 | Kind::MiniDiscord | Kind::MiniMk2Module => vec![0x02, 0x01, page_number as u8, 0, if last_package { 1 } else { 0 }, key + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
292
293 _ => vec![
294 0x02,
295 0x07,
296 key,
297 if last_package { 1 } else { 0 },
298 (this_length & 0xff) as u8,
299 (this_length >> 8) as u8,
300 (page_number & 0xff) as u8,
301 (page_number >> 8) as u8,
302 ],
303 },
304 )?;
305 Ok(())
306 }
307
308 /// Writes image data to Stream Deck device, changes must be flushed with `.flush()` before
309 /// they will appear on the device!

Callers 2

clear_button_imageMethod · 0.80
flushMethod · 0.80

Calls 4

flip_key_indexFunction · 0.85
key_countMethod · 0.80
is_visualMethod · 0.80

Tested by

no test coverage detected