MCPcopy Create free account
hub / github.com/RustCV/RustCV / bgra32_to_bgr

Function bgra32_to_bgr

rustcv-camera/src/decode.rs:200–207  ·  view source on GitHub ↗

Drop the alpha channel from BGRA32 to produce BGR24. 从 BGRA32 去掉 Alpha 通道,生成 BGR24。 Input: [B, G, R, A, B, G, R, A, ...] (4 bytes/pixel) Output: [B, G, R, B, G, R, ...] (3 bytes/pixel)

(src: &[u8], dst: &mut [u8])

Source from the content-addressed store, hash-verified

198/// Input: [B, G, R, A, B, G, R, A, ...] (4 bytes/pixel)
199/// Output: [B, G, R, B, G, R, ...] (3 bytes/pixel)
200pub fn bgra32_to_bgr(src: &[u8], dst: &mut [u8]) {
201 for (s, d) in src.chunks_exact(4).zip(dst.chunks_exact_mut(3)) {
202 d[0] = s[0]; // B
203 d[1] = s[1]; // G
204 d[2] = s[2]; // R
205 // s[3] = A, discarded
206 }
207}
208
209// ─── RGB → BGR ──────────────────────────────────────────────────────────────
210

Callers 1

decode_frameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected