-1

Can someone please help me write code that can read a 24-bit BMP file from an SD card, save converted to 8-bit BMP internally, and display the 8-bit BMP pixel values on Arduino terminal as a 2D matrix. The program should align the bytes as two HEX values on the Arduino terminal. I am new to this and not sure how to go about it. Your help will be much appreciated.

The image is present in the SD card and coded as:

include <SD.h>
include <SD_t3.h>

void setup() {
  Serial.begin (9600);
  delay (1000);
}

void loop() {
  if (!SD.begin (BUILTIN_SDCARD)) {
    Serial.println ("NO SDCARD");
    while (1);
  } else {
    Serial.println ("YES SDCARD");
  }
  delay (1000);
  if (SD.exists("filename.BMP")) {
    Serial.println ("filename.BMP exists");
  } else {
    Serial.println ("filename.BMP missing");
    while (1);
  }
  delay (1000);
  File hFi = SD.open ("filename.bmp", FILE_READ);
  if (hFi == false) {
    Serial.println ("File open failed");
    while (1);
  }
0

You have to writeyour own routines. To get you started Look at this source code
Add view-source:https://javl.github.io/image2cpp/. Although it is javascript, it can be transferred to C++ to a working conversion routine. The important part are the conversion routines.
A word of warning: As the memory os limited you will have to do a line by line read from SD card convert line and write line by line back or you use maximum 16x16 size.
Thats the reason why most converters run in browser or PC and the result is used in Arduino. An ESP8266 with 4MB memory would make life easier. For an implementation of graphic routines on Arduino Teensy look into this gaming library

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.