Noob seeking help with programming display

I am trying to make my son aPKE meter for Halloween. I started converting a code I found that used different hardware than what I am using. I am new to coding but I have it working with my hardware. My issue is that I can not get all the images to display. I have ensured they are 24bit and 128 x 128. Some are distorted, the boot images fill the screen but do not fill the screen during functions, and some are in the wrong orientation. Also, the PKE readout is in wrong orientation. I am trying to get everything vertical vs landscape.

I am trying figure how to get everything in the same orientation, to fill the screen, and understand why some images are distorted, just lines, or static looking. The code was originally for an adafruit feather and oled of 1.2. I am using a nano and a 1.44 tft lcd.

PKE_17_pub1.ino (31.1 KB)

void openbmpFile(char *filename) {

You assume that this function will ALWAYS work. What kind of dream world do you live in?

  uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer

The current position is just beyond the end of the array. Is that REALLY a good idea?

    (void)read32(bmpFile); // Read & ignore creator bytes

Why do you need to cast the value returned by the function before you discard it?

  //for (row=0; row<(h/2); row++) { // For each scanline... MVS up to middle
  for (row=0; row<128; row++) { // For each scanline... MVS up to middle

Does that comment mean anything to you? Why is there commented out code? Clearly, that code didn’t work, so why are you keeping it?

  int      w, h, row, col;

  // Crop area to be loaded
  w = bmpWidth;
  h = bmpHeight;
  if((x+w-1) >= tft.width())  w = tft.width()  - x;
  if((y+h-1) >= tft.height()) h = tft.height() - y;

When the last two lines are executed, what are the initial values of w and h? The ONLY correct answer is “I do not have a clue”. And, why are you writing code that has that as the answer?

You ask why some files on the SD card, that we can’t see, are not drawn the way you want, with no clue as to how they are drawn, how you want, where the image came from, or anything we can use to help you.