how do bitmaps work on a touch screen?

Hi,
I have a 3.5" tft touch screen shield with a micro sd card like this one.
I am trying to get bmp's to appear on it, I can draw lines, squares and circles.
It uses the adafruit_gfx library which shows

    drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color),

but every way I try to get it to implement this it fails.

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>
#define MINPRESSURE 200
#define MAXPRESSURE 1000
//CONTROLLER ili9481 ili9468, ili9488 hx8357, or r61581
//ID = 0x6814
// ALL Touch panels and wiring are DIFFERENT
// copy-paste results from TouchScreen_Calibr_native.ino
const int XP = 6, XM = A2, YP = A1, YM = 7; //ID=0x9341  (input pins)
//const int TS_LEFT = 912, TS_RT = 189, TS_TOP = 912, TS_BOT = 176;//portrait
//const int TS_LEFT = 912, TS_RT = 176, TS_TOP = 189, TS_BOT = 821;//landscape
const int TS_LEFT = 950, TS_RT = 206, TS_TOP = 189, TS_BOT = 921;//landscape
//this last calculation means touch is directly over drawn boxes.
//is this needed to correct different types of display? screen for my display is 480 x 320
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

Adafruit_GFX_Button on_btn, off_btn, top_left_btn, top_rt_btn, bot_left_btn, bot_rt_btn;

int pixel_x, pixel_y;     


#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

void setup(void)
{
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    Serial.print("TFT ID = 0x");
    Serial.println(ID, HEX);
    Serial.println("Calibrate for your Touch Panel");
    //if (ID == 0xD3D3) ID = 0x9486; // write-only shield
    if (ID == 0xD3D3) ID = 0x9486; // write-only shield
    tft.begin(ID);
    tft.setRotation(1);            //0=portrait,1=landscape
    tft.fillScreen(BLACK);
    //on_btn.initButton(&tft, 60 ,200 , 100 , 40   , WHITE,  CYAN,BLACK, "ON", 2  );
    on_btn.initButton(&tft, 60 ,200 , 100 , 40   , WHITE,  CYAN,BLACK, "ON", 2  );
    //          (     ? ,  in , down,width,height,border,bkgrnd,text,  text,size)
    //                                                   colour,colour,colour,
    //319 is bottom row, 0 is left edge. Buttons(in and down above) number from centre of box 
    
    //put a spot in each corner
    top_left_btn.initButton(&tft, 0 , 0 , 1 , 1   , WHITE,  CYAN,BLACK, "", 2  );
    bot_left_btn.initButton(&tft, 0 , 319 , 1 , 1   , WHITE,  CYAN,BLACK, "", 2  );
    top_rt_btn.initButton(&tft, 479 , 0 , 1 , 1   , WHITE,  CYAN,BLACK, "", 2  );
    bot_rt_btn.initButton(&tft, 479 , 319 , 1 , 1   ,  WHITE,  CYAN, BLACK,"",  2  );
    
    off_btn.initButton(&tft,180 ,200 ,100  , 40   , WHITE, CYAN , BLACK, "OFF", 2  );
    
    on_btn.drawButton(false);
    top_left_btn.drawButton(false);
    bot_left_btn.drawButton(false);
    top_rt_btn.drawButton(false);
    bot_rt_btn.drawButton(false);
    off_btn.drawButton(false);
   // on_btn
    tft.fillRect(40, 80, 160, 80, RED);
    tft.drawCircle(240,240,60, RED);
    tft.drawCircle(360,240,40, BLUE);
    tft.fillCircle (360,120,40,RED);
    tft.drawBitmap(360,120,*woof.bmp,25,25,RED);
    tft.fillRect(240, 0, 1, 1, RED);//puts a red spot middle of top row.
    tft.fillRect(240, 0, 1, 319, RED);//put a red line down the middle.
}
/* two buttons are quite simple
 */
void loop(void)
{
    bool down = Touch_getXY();
    on_btn.press(down && on_btn.contains(pixel_x, pixel_y));
    off_btn.press(down && off_btn.contains(pixel_x, pixel_y));
    if (on_btn.justReleased())
        on_btn.drawButton();//renews button background colour
    if (on_btn.justPressed()) {
        on_btn.drawButton(true);//deletes button background colour
        tft.fillRect(40, 80, 160, 80, GREEN);
               //,  in , down,width,height
    }
    if (off_btn.justReleased())
        off_btn.drawButton();//renews button background colour
    if (off_btn.justPressed()) {
        off_btn.drawButton(true);//deletes button background colour
        tft.fillRect      (  40   , 80    ,  160 , 80   , RED        );
        //box drawn from (top lft,bot lft,top rt,bot rt,bkgrnd colour
    }
}
bool Touch_getXY(void)//Touch_getXY() updates global vars
{
    TSPoint p = ts.getPoint();
    pinMode(YP, OUTPUT);      //restore shared pins
    pinMode(XM, OUTPUT);
    digitalWrite(YP, HIGH);   //because TFT control pins
    digitalWrite(XM, HIGH);
    bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
    if (pressed) {
        pixel_x = map(p.y, TS_LEFT, TS_RT, 0, 480); //landscape
        //pixel_x = map(p.y, LEFT=716, RT=591, 0, 480); //landscape
        //pixel_x = map(p.x, TS_LEFT, TS_RT, 0, 320); //portrait
        //TS_LEFT, TS_RT,
        pixel_y = map(p.x, TS_TOP, TS_BOT, 0, 320);//landscape
        //pixel_y = map(p.x, TOP=385, BOT=462, 0, 320);//landscape
        //pixel_y = map(p.y, TS_TOP, TS_BOT, 0, 480);//portrait
        //TS_TOP, TS_BOT,
    }
    return pressed;
}

I have added all my code but the line I am trying to get working is the third from the bottom of the setup.
I have a bitmap called woof.bmp on the micro sd card in the reader.

Would someone mind pointing me in a direction that can help me show bitmaps on the screen?
Thanks,
Bob.

It is a bit confusing.

Adafruit_GFX has a method called drawBitmap() that is designed for monochrome bitmaps.

PCs have coloured images in "Windows BMP" format stored in files with extension .BMP e.g. woof.BMP

You need to use the showBMP_kbv_Uno.ino example to display a .BMP file from the SD.

Or use the drawBitmap_kbv.ino to see how to use GFX methods like drawBitmap(), drawXBitmap(), drawRGBBitmap(), ...

Oh, grown-up formats like .BMP, .JPG, .PNG, ... contain information about geometry, colours, ... which means that any O.S. or micro can display them.

Arduino "bitmaps" have no standardised format. You have to "know" the geometry in advance. Different GLCD, OLED, TFT libraries might expect their own style, padding, ...

David.

Mm, Yes I agree that is a bit confusing.

How can I make 'monochrome' bitmaps and if I had one would it work with this programme do you think?

I tried showBMP_kbv_Uno.ino and after altering the name of the bitmap to woof it came back with 'can't start sd card' ?

drawBitmap_kbv.ino has two more libraries it uses 'bitmap_mono.h and bitmap_RGB.h if I added these do you think it would allow me to show my bitmaps?

thanks,
Bob.

I tried showBMP_kbv_Uno.ino and after altering the name of the bitmap to woof it came back with 'can't start sd card' ?

The example should work fine on a Uno. Put the SD Card into your PC. Do the .BMP files display on the PC ?

drawBitmap_kbv.ino has two more libraries it uses 'bitmap_mono.h and bitmap_RGB.h if I added these do you think it would allow me to show my bitmaps?

Those H files contain raw image data. They are not "library headers". A Library header contains declarations for a C++ class.

Please study the images shown in the example. e.g. size, colours, time, ...
Study the example code.

If you have an image that you would like to display, attach a regular .JPG, .PNG, .BMP file to your message. i.e. a file that can be clicked on your PC

Then we can show you the easiest / best way to display on your Arduino Uno.
This might involve using a PC program like IrfanView, Paint, ... or an online web program.

David.