Tft help program is drawing second half of image first

im using the tft.drawXBitmap function to draw an image to screen.

what i have working is 8x8 pixel images, but if i step up to 16 x 16 bit images it draws the second half of the image first, its really weird. it only does this on the esp 32 and not on the arduino mega (same exact code)

i don't want to draw images and then convert them to hex. i wanna do it in binary. its easier and more fun for me this way and the end product is only 2 colors anyway (white pixels on black background)

this works and draws a 8 pixel x 8 pixel image fine on the screen at the location i want.

  tft.drawXBitmap(65, 65, Chest8b, 8, 8, TFT_WHITE);

this works fine on the arduino mega but not on the esp32, instead it draws the second half of the image first but does not flip flop the top or bottom half.

tft.drawXBitmap(50, 50, Potion16b, 16, 16, TFT_WHITE);

this is the data used to draw the image,

//8x8 pixel image
 static const unsigned char PROGMEM Chest8b[] =  //Rounded chest
{0b00111100, 
 0b01000010,
 0b10000001,
 0b10111001, 
 0b11101111,
 0b10010001, 
 0b10000001,
 0b11111111 };

//16x16 pixel image
static const unsigned char PROGMEM Potion16b[] =
{ 0b00000011, 0b11000000,
  0b00000100, 0b00100000,
  0b00001000, 0b00010000,
  0b00010100, 0b00101000,
  0b00010011, 0b11001000,
  0b00011000, 0b00010000,
  0b00010111, 0b11001000,
  0b00101000, 0b00100100,
  
  0b00100000, 0b00000100,
  0b00100000, 0b00010100,
  0b00100000, 0b00010100,
  0b00100000, 0b00010100,
  0b00100000, 0b00000100,
  0b00010000, 0b00001000,
  0b00001100, 0b00110000,
  0b00000011, 0b11000000 };  

in the 16x16 version there are 4 blocks of 8x8 a top left, top right bottom left and bottom right and all 4 make a 16x16 pixel black and white image.

the issue im having is it draws both colums on the right hand side first and then both left hand colums second splitting the image. its weird as hell i don't get why its doing this.

i have come to the conclusion i need to port over to the esp32 from the mega because text takes allot of space... i only have to draw a handful of images for the story that's being written. i suppose i could draw all of them second half first but that's just as annoying as converting everything to hex....

ideally id like to draw custom images 24 x 24 pixels in size, how can i do this in binary and not have to convert to hex...

Try...

  • Change the order of the blocks.
  • There might be a keyword in your code, MSBFIRST or LSBFIRST. If there is, change them.

Remember that the micro only understands binary, hexadecimal exists to "make life easier" for us humans. So if you find it easier to use binary, what's the problem?

the problem is on the esp32 it is drawing the images split in half with the second half before the first half and i cant figure out why...

What type of display, which library are you using, etc.
Would help if you could post a small sketch demonstrating the problem.

Are you running short of dynamic memory (ram) or program memory on the mega?

I have not had that problem but I have worked with images in RGB565 format using the TFT_eSPI library, I have not tried with monochrome images.
What library and what display do you use?

tft_espi library

ili9488 3.5 inch display (480 x 320)

im using maybe 6 % of available ram and about 20 % of code space

the issue doesnt exist on the mega, it displays just fine. i ported everything over to the esp32 to take advantage of the additional code space but now i have this weird graphic bug

Does it draw the image correctly if you use drawBitmap() instead of drawXBitmap()?

yes... Thank you. :man_facepalming:

Ok, then the problem was that your image is in bitmap format, not Xbitmap (XBM) format.
Xbitmap format has the bit order within each byte reversed compared to a bitmap image.
What you were seeing was not the right and left sides of the images swapped, but each byte of the image was reversed. The 8x8 image was also drawn reversed, but it is nearly symmetrical so it is hard to see.

1 Like

That makes sense. hey i appreciate the explanation on that also, all my graphics are in black and white, just simple stuff so its easy to code a 1 for pixel on and 0 for pixel off. makes drawing stuff from my graph book way easy to.

Damn man thank you !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.