convert image code(Arduino image code) to bmp image

hello

I'm looking for a way to convert binary coded arduino image back into bmp
All programs convert bmp photos into code
Is this possible?

Man i am getting better at visual studio, i have spent the afternoon working out how to make a program to read either a binary file or raw hex file "containing the headers and stuff i.e. const unsigned program mem" and display it in a preview box plus the ability to save it as a bmp.

And after 3 1/2 hours i am finished

Man i know its not much but no joke there is none on the web that work, being from HEX - BIN to BMP, i am happy and i shall attach the release version this week once i have tested it more and made it look nice.

Note how the entire box and preview resizes depending on the pixel width entered
:slight_smile: it defiantly needs a touch up but its works.

The image file looks like it it is in XBM format. If that is the case then with a few edits (to add the width and height plus remove the PROGMEM) image programs like GIMP and IrfanView etc will convert the file for you. If you search for XBM To BMP in Google you will also find online conversion tools that convert between many formats.

The bad news is that true XBM format has the first pixel in the least significant bit of the first byte, sadly many Arduino bitmaps break this format by putting the first bit in the most significant bit. I suspect your file is in the latter format. You could write a simple sketch to reverse the bit order and output a new copy of the array in the correct format to the Serial Monitor window for copy and pasting into a file, then use the online conversion tool.

Life would have been much easier if you had copy-pasted the code to your message.
Using a JPG or PNG image is not copy-paste-able.

90% of TFT libraries use Adafruit_GFX style methods.

You can display monochrome bitmaps with several methods:

    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),

Note that XBM format data can be read from PROGMEM. The more "comfortable" MSB-first format data can be read from SRAM or PROGMEM.

Olikraus's U8g2lib favours XBM format with more methods. And only displays MSB format from SRAM not PROGMEM.

The obvious conclusion is: select the appropriate format when creating the data array in the first place.

Which TFT library are you using?

Did you create the arrays yourself? e.g. from a JPG with an online tool on the PC

Just re-create with the suitable format.
Or paste your arrays here (in a CODE window). And someone might convert them for you.

David.

Hi,

try this:

http://javl.github.io/image2cpp/

BG

KawasakiZx10r:
Man i am getting better at visual studio, i have spent the afternoon working out how to make a program to read either a binary file or raw hex file "containing the headers and stuff i.e. const unsigned program mem" and display it in a preview box plus the ability to save it as a bmp.

And after 3 1/2 hours i am finished

Man i know its not much but no joke there is none on the web that work, being from HEX - BIN to BMP, i am happy and i shall attach the release version this week once i have tested it more and made it look nice.

Note how the entire box and preview resizes depending on the pixel width entered
:slight_smile: it defiantly needs a touch up but its works.

thanks
please add link for this app converter

KawasakiZx10r:
Man i am getting better at visual studio, i have spent the afternoon working out how to make a program to read either a binary file or raw hex file “containing the headers and stuff i.e. const unsigned program mem” and display it in a preview box plus the ability to save it as a bmp.

And after 3 1/2 hours i am finished

Man i know its not much but no joke there is none on the web that work, being from HEX - BIN to BMP, i am happy and i shall attach the release version this week once i have tested it more and made it look nice.

Note how the entire box and preview resizes depending on the pixel width entered
:slight_smile: it defiantly needs a touch up but its works

can you post the github link, plz and thank-you

I have this same issue with adafruit glx and is bit pain to reverse order of pixels.
There is another easier solution for Linux user to convert bitmap? I know about image2app, but I don't like use browser for tips suppose. I will be happy to use some ui program to convert with proper bit order for arduino.

I need write a update me my post, I think that I found a solution to my problem with xbm files generated from gimp.
Adafruit glx have option to read properly that string of reversed bits.
Function is called
“drawXbitmap”
I can’t wait when I come to home and I try use that.
On internet I dig everywhere and no one was mentioning that this function could be availbe.

UPDATE.
Yes! It works beautifully. :slight_smile: