0

Suppose I already read binary data from a binary file, how can I create a BMP image from that binary data?

1 Answer 1

1

You can find a definition of the bitmap file format on Wikipedia among other places. Use the struct module to create the necessary headers. Because the format is uncompressed it is very easy to write out. The color information must come in BGR order, bottom line to top line, and each line must be padded with zeros to a multiple of 4 bytes.

Or if you'd rather do it the easy way, PIL knows how to read and write BMP.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.