Images

Creations

Max

NEW 6 years ago

Hello when I tried to dispay this little png (a man) I used the magenta color for transparancy but I my image is not correctly. I used index color palette. But with rgb565 it works well. Why ?

My original png

#include <Gamebuino-Meta.h>

const int8_t manData[] = {7, 17, 1, 0, 1, 0xee, 1, 0x00, 0x00,0x00, 0xef,0xff, 0xff,0xfe, 0xf0,0xff, 0x0f,0xef, 0x0f,0xf0, 0xfe,0xff, 0xff,0xff, 0xef,0xff, 0xff,0xfe, 0xee,0x77, 0x7e,0xef, 0x11,0x11, 0x1f,0xf7, 0x77,0x77, 0xff,0x11, 0x11,0x1f, 0xf7,0x77, 0x77,0xff, 0x11,0x11, 0x1f,0xfc, 0xcc,0xcc, 0xfe,0xcc, 0xcc,0xce, 0xec,0xce, 0xcc,0xee, 0x00,0xe0, 0x0e,0xe0, 0x0e,0xe000};
Image man = Image(manData);

void setup() {
  gb.begin();
}

void loop() {
  while(!gb.update());
  gb.display.clear();
  // now we can draw the image to the display, at x=0 and y=0
  gb.display.drawImage(0, 0, man);
}

the result with index color

Aurélien Rodot

6 years ago

Look like you have an odd with, can you make it 8 pixels wide ?

As Sorunome said earlier :

I'm sorry to say that the tool you linked has a bug with indexed images having an odd width! Try making your image one pixel wider, so that it is 26 pixels wide, put it through the tool, and then in the output image header change the width back to 25

Sorunome

6 years ago

Also your transparent color is set to 0xee instead of 0x0e......i'll go right ahead and add that to the tutorial as multiple people made that mistake now

Aurélien Rodot

NEW 6 years ago

Max Max

Look like you have an odd with, can you make it 8 pixels wide ?

As Sorunome said earlier :

I'm sorry to say that the tool you linked has a bug with indexed images having an odd width! Try making your image one pixel wider, so that it is 26 pixels wide, put it through the tool, and then in the output image header change the width back to 25

Sorunome

NEW 6 years ago

Max Max

Also your transparent color is set to 0xee instead of 0x0e......i'll go right ahead and add that to the tutorial as multiple people made that mistake now

Max

6 years ago

Yeah that's works well, thank a lot !

Max

NEW 6 years ago

Sorunome Sorunome

Yeah that's works well, thank a lot !

ragnarok93

NEW 6 years ago

Hmm I have one question - I tried to set my own custom color palette. But when i try use this function:

gb.display.setPalette(myPalette);

I get error message - 'class Gamebuino_Meta::Image' has no member named 'setPalette'


Why i get such message ? :<

Sorunome

6 years ago

That function only exists in the git version currently, it didn't get pushed as update to the normal arduino library manager thing yet. You are always free to manually install the git repository

ragnarok93

NEW 6 years ago

Hmm I have one question - I tried to set my own custom color palette. But when i try use this function:

gb.display.setPalette(myPalette);

I get error message - 'class Gamebuino_Meta::Image' has no member named 'setPalette'


Why i get such message ? :<

Sorunome

NEW 6 years ago

ragnarok93 ragnarok93

That function only exists in the git version currently, it didn't get pushed as update to the normal arduino library manager thing yet. You are always free to manually install the git repository

ragnarok93

NEW 6 years ago

Thanks for reply :). I will wait for version to download from IDE :D.

strangenikolai

NEW 6 years ago

Hi, I think I'm hitting the upper limit for an integer array trying to create a tilemap. I have 50 tiles at 16x16 that I want to pick from. It worked when I only had 25 tiles.


The Arduino IDE just doesn't compile it, and through Visual Studio it compiles but then I get a crash when it loads onto the Gambuino. 


Any suggestions? I'm currently not using indexed (I don't understand it 100%..) so I could try that but I think I will run out again once I create a few more tiles...


The other thing I could do is create a few separate tilemaps but I need to work out how to point each "Tile" to the correct image. (I haven't worked with pointers since high-school... 20 years ago). Or would there be significant overhead building the Image inside the draw function each time?

Sorunome

6 years ago

What do you mean "it just doesn't compile"? What are the errors?

Reuben uses images as tilemaps and it uses like 400 unique tiles, it should work in theory with up to 65535 different tiles.

ragnarok93

NEW 6 years ago

First question - do You really need int for tilemap ? Couldn't it be something smaller like char ?

Sorunome

NEW 6 years ago

strangenikolai strangenikolai

What do you mean "it just doesn't compile"? What are the errors?

Reuben uses images as tilemaps and it uses like 400 unique tiles, it should work in theory with up to 65535 different tiles.

strangenikolai

6 years ago

I have a file called tiles.ino which has the following code (this is my test code to narrow down the issue so it just drawa 1 tile)

const uint16_t tilesetData[] = {16,16, 51, 0, 0xffff, 0, 0x3388,0x3388,0x3388,0x3388,0x3388,0x3388,0x3388,0x3388
                               };

Image tileset = Image(tilesetData);

void drawTiles(){
  tileset.setFrame(1);
  
  gb.display.drawImage(16, 16, tileset);
}

I generated the tilesetData[] from the Image to Code Converter. When I had 25 tile this worked fine. Once I added more to the tileset image (and re-ran through the converter) I got an error trying to call drawTiles().

drawTiles() is not defined in this scope.


My tiles are 16 x 16 pixels (too big probably) and when I found the page below I thought I had too many elements - as 51*16*16 = 13,056 and I guessed that uint16_t would be bigger than the int listed here.  

 http://arduino.land/FAQ/content/6/7/en/what-is-the-maximum-number-of-elements-an-array-can-have.html

strangenikolai

NEW 6 years ago

Sorunome Sorunome

I have a file called tiles.ino which has the following code (this is my test code to narrow down the issue so it just drawa 1 tile)

const uint16_t tilesetData[] = {16,16, 51, 0, 0xffff, 0, 0x3388,0x3388,0x3388,0x3388,0x3388,0x3388,0x3388,0x3388
                               };

Image tileset = Image(tilesetData);

void drawTiles(){
  tileset.setFrame(1);
  
  gb.display.drawImage(16, 16, tileset);
}

I generated the tilesetData[] from the Image to Code Converter. When I had 25 tile this worked fine. Once I added more to the tileset image (and re-ran through the converter) I got an error trying to call drawTiles().

drawTiles() is not defined in this scope.


My tiles are 16 x 16 pixels (too big probably) and when I found the page below I thought I had too many elements - as 51*16*16 = 13,056 and I guessed that uint16_t would be bigger than the int listed here.  

 http://arduino.land/FAQ/content/6/7/en/what-is-the-maximum-number-of-elements-an-array-can-have.html

strangenikolai

6 years ago

Ok - I think it might just be an issue with the Arduino IDE and long lines of text. I've worked out what my issue was with Visual Studio (I had in in Debug mode, Release mode works ok) and it seems to work now. Sorry for the red herring.

Also, I've made a change to consider for the Image to Code Converter but will go post there...

strangenikolai

NEW 6 years ago

strangenikolai strangenikolai

Ok - I think it might just be an issue with the Arduino IDE and long lines of text. I've worked out what my issue was with Visual Studio (I had in in Debug mode, Release mode works ok) and it seems to work now. Sorry for the red herring.

Also, I've made a change to consider for the Image to Code Converter but will go post there...

strangenikolai

NEW 6 years ago

Hello again,


I can't work out what I'm doing wrong trying to load a bitmap. Below is my code, backg.bmp is in the same folder as the .ino. It doesn't error, it just doesn't display.

#include <Gamebuino-Meta.h>

Image bg("backg.bmp");

void setup() {
  gb.begin(); 
}

void loop() {
  while(!gb.update());
  
  gb.display.clear();
  gb.display.drawImage(1,1,bg);  
}


Sorunome

6 years ago

the file needs to be on the SD card, in the folder of the name of your sketch

Sorunome

NEW 6 years ago

strangenikolai strangenikolai

the file needs to be on the SD card, in the folder of the name of your sketch

strangenikolai

6 years ago

Do you know what the upper size of the bitmap can be? If I make it really small it works, but over a certain size it just shows as a black box. I haven't quite narrowed down the size that breaks.