![]() For example, it may turn out to be as simple as: pos = pixel_array_offset + row_size * y + pixel_size * xįinally, once you've changed your red pixels to white, you can save it with: with open('eggs. Now, once you've found the "pixel array" portion of the BMP, and you've figured out how to interpret it from the DIB header, you can just set pixels to white at whichever positions you want by setting the values at the appropriate indexes of the bytearray. But you might want to ask your teacher for feedback on that. In fact, you can probably just assume that all of the headers will specify the most common variant and only code for that. I'm guessing you can ignore all the options for BMP compression-otherwise, this would be way too hard an assignment. and re-combining them into a 32-bit number. The struct module in the standard library will be very helpful for interpreting the headers it's much easier to read a 32-bit little-endian number with struct.unpack_from('
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |