Drawing Bitmaps

Hey everyone,

I have:

#include <UTFT.h>
#include <avr/pgmspace.h>

extern unsigned int radio1[0x400];

myGLCD.drawBitmap (0,0,32,32,radio1);

But I get an error

“C:\Users\Callum\Desktop_________\Code/Code.ino:44: undefined reference to `radio1’”

I have tried lots of things but nothing seems to work. There is more code but I have shortened it for this example.

Thanks

(Mega2560)

I have shortened it for this example.

You have shortened it so much that it could never compile.

#include <UTFT.h>
#include <avr/pgmspace.h>

extern unsigned int radio1[0x400];


UTFT myGLCD(CTE32HR,38,39,40,41);


void loop()
{
myGLCD.drawBitmap (0,0,32,32,radio1);

}

radio1 has to actually be defined somewhere

wg0z:
radio1 has to actually be defined somewhere

and how do i do that? I have "extern unsigned int radio1[0x400];" and i have the "radio1.C" file saved in the folder.

if you change the filename to radio1.h then you can just change "external unsigned int radio1" to
#include "radio1.h"

poof; your bitmap is still a physically separate file but no longer a separate compilation unit.

wg0z:
if you change the filename to radio1.h then you can just change "external unsigned int radio1" to
#include "radio1.h"

poof; your bitmap is still a physically separate file but no longer a separate compilation unit.

'radio1' was not declared in this scope - do I need an additional line to declare it?

#include "radio1.h"

show us the first few lines of radio1.h

// Image Size     : 48x48 pixels
// Memory usage   : 4608 bytes

#if defined(__AVR__)
    #include <avr/pgmspace.h>
#elif defined(__PIC32MX__)
    #define PROGMEM
#elif defined(__arm__)
    #define PROGMEM
#endif

const unsigned short radioactive1_M[2304] PROGMEM={
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFDF, 0xFFFF,   // 0x0010 (16) pixels
0xFFFF, 0xFFFF, 0xFFFF, 0xEF7D, 0xCE58, 0xA534, 0x8C51, 0x73AF, 0x73AF, 0x7BCF, 0x8C51, 0xAD55, 0xCE79, 0xF79D, 0xFFFF, 0xFFFF,   // 0x0020 (32) pixels
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,   // 0x0030 (48) pixels
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,   // 0x0040 (64) pixels
0xD6BA, 0x8410, 0x3188, 0x0002, 0x0000, 0x0000, 0x0000, 0x0020, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0023, 0x39E9, 0x8C72,   // 0x0050 (80) pixels
0xDEFB, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,   // 0x0060 (96) pixels
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xAD55, 0x31A8,   // 0x0070 (112) pixels
0x0000, 0x0000, 0x31A0, 0x7BC0, 0xB580, 0xD6A0, 0xEF40, 0xF7A1, 0xF7A1, 0xF7A0, 0xEF40, 0xD680, 0xAD40, 0x6B60, 0x2940, 0x0000,   // 0x0080 (128) pixels
0x0001, 0x4229, 0xBDF7, 0xFFFF, 0xFFFF, 0xFFDF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,   // 0x0090 (144) pixels
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xB5B6, 0x2946, 0x0000, 0x2120,   // 0x00A0 (160) pixels
0x9480, 0xE700, 0xFFE1, 0xFFE3, 0xFFE5, 0xFFE6, 0xFFE6, 0xFFE7, 0xFFE7, 0xFFE7, 0xFFE6, 0xFFE6, 0xFFE4, 0xFFE3, 0xFFE1, 0xDEC0,   // 0x00B0 (176) pixels

The name used in the .h file must match the name used in your loop() code.
for now don't use the PROGMEM keyword, either.

Code:45: error: invalid conversion from ‘const short unsigned int*’ to ‘unsigned int*’ [-fpermissive]

Help. Please.

First part of radio1.h Code:

// Image Size     : 48x48 pixels
// Memory usage   : 4608 bytes

#if defined(__AVR__)
    #include <avr/pgmspace.h>
#elif defined(__PIC32MX__)
    #define PROGMEM
#elif defined(__arm__)
    #define PROGMEM
#endif

const unsigned short radio1[2304] ={
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFDF, 0xFFFF,   // 0x0010 (16) pixels
0xFFFF, 0xFFFF, 0xFFFF, 0xEF7D, 0xCE58, 0xA534, 0x8C51, 0x73AF, 0x73AF, 0x7BCF, 0x8C51, 0xAD55, 0xCE79, 0xF79D, 0xFFFF, 0xFFFF,   // 0x0020 (32) pixels
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,   // 0x0030 (48) pixels

Almost all Arduino Code:

#include <UTFT.h>
#include <avr/pgmspace.h>


extern uint8_t BigFont[];
extern uint8_t SmallFont[];
extern uint8_t GroteskBold24x48[];



UTFT myGLCD(CTE32HR,38,39,40,41);

void setup()
{

}

void loop()
{

int A0v = digitalRead(A0);
int A1v = digitalRead(A1);
int A2v = digitalRead(A2);
int A3v = digitalRead(A3);
int A4v = digitalRead(A0);

#include "radio1.h"[];
myGLCD.drawBitmap (0,0,32,32,radio1);

//while (true) {};
}

in the header file, change ‘const unsigned short’ to ‘unsigned int’

wg0z:
in the header file, change 'const unsigned short' to 'unsigned int'

Code:45: error: too many initializers for 'short unsigned int [2304]' :frowning:

progress. Try adding 'const' and/or 'PROGMEM' back in...

PROGRESS!
By doing this:

extern unsigned int radio1[];

I can print a bitmap

However...

It looks like this:

What have I done wrong haha.

no picture visible butt note that if a bitmap is X by Y you need to render it as such. if yo have the oraiiganl .bmp file the dimensions are buried in the header.
typical layout for such is as follows:

simplified .bmp file header decode
  

Offset (hex), offset (decimal),  field size, descriptin



Purpose

00   0  2  always ASCII "BM" to specify bitmap BM  (0x42, 0x4d)
02   2  4  The size of the BMP file in bytes 
06   6  2  Reserved; actual value depends on the application that creates the image 
08   8  2  Reserved; actual value depends on the application that creates the image 
0A  10  4  The offset, i.e. starting address, of the byte where the bitmap image data (pixel array) can be found. 
0E  14  4  the size of this header (40 bytes for this example) 
12  18  4  the bitmap width in pixels (signed integer) 
16  22  4  the bitmap height in pixels (signed integer) 
1A  26  2  the number of color planes (must be 1) 
1C  28  2  the number of bits per pixel, which is the color depth of the image. 
           Typical values are 1, 4, 8, 16, 24 and 32. 
1E  30  4  the compression method being used. See the next table for a list of possible values 
22  34  4  the image size. This is the size of the raw bitmap data; 
           a dummy 0 can be given for BI_RGB bitmaps. 
26  38  4  the horizontal resolution of the image. (pixel per meter, signed integer) 
2A  42  4  the vertical resolution of the image. (pixel per meter, signed integer) 
2E  46  4  the number of colors in the color palette, or 0 to default to 2n 
32  50  4  the number of important colors used, or 0 when every color is important; 
           generally ignored

Better Image:

First Lines:

// Generated by  : ImageConverter 565 v2.3
// Generated from: Test1.png
// Time generated: 28/12/2016 17:38:04
// Dimensions    : 32x32 pixels
// Size          : 2,048 Bytes

#include <avr/pgmspace.h>
unsigned int radio1[0x0400] ={
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,   // 0x0010 (16)

your latest image is a classic example of trying to draw an XbyY image as 1.25X by 0.8Y, or something like that

your original radioactive_M1 bitmap array was 2304 integers, supposedly a 48x48 image, each pixel rgb565 format.
take the first 25% (or 33%, or 50%) of that and try to draw it as a 48x12 ( or a 48x16, or 48x24 ) image.

try drawing the following as an 8x8 bitmap

unsigned int testimage[] =
{
  0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF, 
  0xFFFF,   0x0000,   0x1f,     0x1f,     0x1f,     0x1f,     0x1f,     0xffff,
  0xFFFF,   0x0000,   0x1f,     0x1f,     0x1f,     0x1f,     0x1f,     0xffff,
  0xFFFF,   0x0000,   0x1f,     0x1f,     0x1f,     0x1f,     0x1f,     0xffff,
  0xFFFF,   0x0000,   0xf000,   0xf000,   0xf000,   0xf000,   0xf000,   0xffff,
  0xFFFF,   0x0000,   0xf000,   0xf000,   0xf000,   0xf000,   0xf000,   0xffff,
  0xFFFF,   0x0000,   0xf000,   0xf000,   0xf000,   0xf000,   0xf000,   0xffff,  
  0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF,   0xFFFF    
};