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])
| 198 | /// Input: [B, G, R, A, B, G, R, A, ...] (4 bytes/pixel) |
| 199 | /// Output: [B, G, R, B, G, R, ...] (3 bytes/pixel) |
| 200 | pub 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 |