MCPcopy Index your code
hub / github.com/google/adk-python / generate_bmp

Function generate_bmp

contributing/samples/core/artifacts/agent.py:47–70  ·  view source on GitHub ↗

Generates a simple valid BMP file (a red square).

(filename: str)

Source from the content-addressed store, hash-verified

45
46
47def 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
73def generate_video(filename: str):

Callers 1

generate_media_artifactFunction · 0.85

Calls 2

openFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected