Inkplate 6 Image Converter only outputs Arduino format, need MicroPython bytearray

Customer:

I want to convert a .bmp file for MicroPython. However, the Image Converter (Image Converter) only outputs data for the Arduino IDE.

How can I convert a bitmap for MicroPython into a bytearray?

Original message (German)

ich würde gerne ein .bmp für micropython konvertieren. Der Image converter (Image Converter) gibt aber nur die Daten für die Arduino IDE aus.

Wie kann ich eine Bitmap für Micropython in ein bytearray konvertieren?

Herzlichen Dank

Originally submitted via email support on 7 October 2023. Migrated to the forum for community visibility.

Soldered Support:

Currently that is the only image converter we have. If you only need a byte array in Python for a 1-bit image, it is converted in the same way, just written differently. Note that 3-bit mode does not work because Python grayscale is 2-bit.

I have personally used the image converter to convert images for Python and used the find-and-replace function in VSCode to reformat the raw byte array to match Python syntax.

It takes a few minutes, but it is doable. For an example of how images are written in Python as byte arrays, see image.py: https://github.com/SolderedElectronics/Inkplate-micropython/blob/master/image.py

The data is essentially the same. In Python, “x03\xe0\xf0\x03” is equivalent to “0x03, 0xe0, 0xf0, 0x03” in Arduino/cpp.

One of our goals is to create a better image converter that also supports direct conversion for Python, once we get to it.

Original message (German)

Hallo [name removed], momentan ist das der einzige Bildkonverter, den wir haben. Wenn du lediglich ein Byte-Array in Python für ein 1-Bit-Bild haben möchtest, wird es auf dieselbe Weise konvertiert, nur anders geschrieben. Beachte, dass der 3-Bit-Modus nicht funktioniert, da Python-Graustufen 2-Bit sind.

Ich habe den Bildkonverter persönlich verwendet, um Bilder für Python zu konvertieren und habe die Suchen-und-Ersetzen-Funktion in VSCode verwendet, um das rohe Byte-Array so umzuformatieren, dass es zur Syntax von Python passt.

Es dauert ein paar Minuten, aber es ist machbar. Für ein Beispiel, wie Bilder in Python als Byte-Arrays geschrieben werden, sieh dir image.py an. https://github.com/SolderedElectronics/Inkplate-micropython/blob/master/image.py

Die Daten sind im Grunde genommen die gleichen. In Python ist “x03\xe0\xf0\x03” äquivalent zu “0x03, 0xe0, 0xf0, 0x03” in Arduino/cpp.

Eines unserer Ziele ist es, einen besseren Bildkonverter zu schaffen, der auch eine direkte Konvertierung für Python unterstützt, sobald wir dazu kommen.