Generates a simple valid BMP file (a red square).
(filename: str)
| 45 | |
| 46 | |
| 47 | def generate_bmp(filename: str): |
| 48 | """Generates a simple valid BMP file (a red square).""" |
| 49 | width, height = 100, 100 |
| 50 | file_size = 54 + 3 * width * height |
| 51 | bmp_header = b"BM" + struct.pack( |
| 52 | "<III IiiHHIIiiII", |
| 53 | file_size, |
| 54 | 0, |
| 55 | 54, |
| 56 | 40, |
| 57 | width, |
| 58 | height, |
| 59 | 1, |
| 60 | 24, |
| 61 | 0, |
| 62 | 0, |
| 63 | 0, |
| 64 | 0, |
| 65 | 0, |
| 66 | 0, |
| 67 | ) |
| 68 | pixel_data = b"\x00\x00\xFF" * (width * height) # Red pixels in BGR |
| 69 | with open(filename, "wb") as f: |
| 70 | f.write(bmp_header + pixel_data) |
| 71 | |
| 72 | |
| 73 | def generate_video(filename: str): |
no test coverage detected