64x64 bitmap images top line incorrection - Sometimes


Why do some of my images show up perfect. Where as others screw up the top line.
64X64 panel using Teensy 3.6 and shield attached to back of LED matrix panel.

I build this in Gimp. On a 64x64 pixel image. https://i.imgur.com/SDHB2U8.jpg. export it as a C file. Copy paste it into my code (see gimp_image.c below) Upload. And this is the result: https://i.imgur.com/fQRZiNF.jpg
I loose the top line in some sort of fashion. Or it gets scrambled up.

Now I have drawn a gradient image in gimp. Exported it out. And sometimes It will be all correct. And others, it will also fail. Same Gimp File. (just different layers).

This is based off using the Bitmaps Example that is included with the source code. I just trimmed it down to only use one .c image file while I try and figure out why this won’t display correctly. I would like to say it is only with images that use the top line, but that is untrue. It is because gimp spits out a 377 value for pixels. Or will spit out what looks like gibberish with random character?

Has anyone else had this experience or can see what I am doing wrong?

Source Code:

#include <SmartLEDShieldV4.h>  // comment out this line for if you're not using SmartLED Shield V4 hardware (this line needs to be before #include <SmartMatrix3.h>)
#include <SmartMatrix3.h>

#include "gimpbitmap.h"
#include "gimp_image.c"

#define COLOR_DEPTH 24                  // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
const uint8_t kMatrixWidth = 64;        // known working: 16, 32, 48, 64
const uint8_t kMatrixHeight = 64;       // known working: 32, 64, 96, 128
const uint8_t kRefreshDepth = 36;       // known working: 24, 36, 48
const uint8_t kDmaBufferRows = 4;       // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_64ROW_MOD32SCAN; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels, or use SMARTMATRIX_HUB75_64ROW_MOD32SCAN for common 64x64 panels
const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE);      // see http://docs.pixelmatix.com/SmartMatrix for options
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);

SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);

int led = 13;

void drawBitmap(int16_t x, int16_t y, const gimp32x32bitmap* bitmap) {
  for (unsigned int i = 0; i < bitmap->height; i++) {
    for (unsigned int j = 0; j < bitmap->width; j++) {
      SM_RGB pixel = { bitmap->pixel_data[(i * bitmap->width + j) * 3 + 0],
                       bitmap->pixel_data[(i * bitmap->width + j) * 3 + 1],
                       bitmap->pixel_data[(i * bitmap->width + j) * 3 + 2]
      backgroundLayer.drawPixel(x + j, y + i, pixel);

void setup() {

  matrix.setBrightness(38); //128 original

  pinMode(led, OUTPUT);

void loop() {
  int x, y;

  backgroundLayer.fillScreen({0, 0, 0});
  x = (kMatrixWidth / 2) - (gimp_image.width / 2);
  y = (kMatrixHeight / 2) - (gimp_image.height / 2);
  drawBitmap(x, y, (const gimp32x32bitmap*)&gimp_image);

  //  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  //  delay(1000);
  //  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  //  delay(1000);



gimp_image.c source code: https://pastebin.com/X1wqbg14 (too long top post in this thread)


Hi, I think you’re trying to save the image without unchecking all the boxes. I can only reproduce something similar to your C file containing \377 values if I leave the “Save Alpha Channel” box checked.



I can confirm that all check boxes are not checked. https://i.imgur.com/ekTR9iK.jpg
If the box is checked, then the image at that is displayed is all kinds of messed up. not just the top line.

If I leave it low. All is well. https://i.imgur.com/RAwdcWb.jpg But if I move it up I get the errors https://i.imgur.com/dFdUw5W.jpg

Code: https://pastebin.com/YbfC5Wj1