from PIL import Image import numpy as np # Create an RGB pixel array (example) width = 256 height = 256 rgb = np.zeros((height, width, 3), dtype=np.uint8) for i in range(256): # y for j in range(8): # x rgb[i, j] = [255, 0, 0] # red rgb[i, j + 8] = [0, 255, 0] # green rgb[i, j + 16] = [0, 0, 255] # blue rgb[i, j + 24] = [255, 255, 255] # white # Create an image from the RGB array image = Image.fromarray(rgb, 'RGB') # Save the image in BMP format image.save('output_image.bmp')