center image/logo

Understanding the language, error messages, etc.

center image/logo

Postby nomisre » Sun Oct 05, 2014 9:21 am

I haven't worked on my Gamebuino for quite a while now, so I'm getting back into it.
Last time I was trying to center an image I created, but somehow only the S from SIM is displayed on the right side of the screen.
How can I center this to the middle of the screen?

Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

const byte PROGMEM logo[] =
{
  72,19,
 B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11100000,
 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
 B01111111,B11111111,B00111111,B11111111,B11001111,B11111111,B00000001,B11111111,B11100000,
 B11111111,B11111111,B00111111,B11111111,B11001111,B11110111,B10000011,B11011111,B11100000,
 B11111111,B11111111,B00111111,B11111111,B11001111,B11110011,B11000111,B10011111,B11100000,
 B11111111,B00000000,B00000011,B11111100,B00001111,B11110001,B11111111,B00011111,B11100000,
 B11111111,B00000000,B00000011,B11111100,B00001111,B11110000,B11111110,B00011111,B11100000,
 B11111111,B00000000,B00000011,B11111100,B00001111,B11110000,B01111100,B00011111,B11100000,
 B11111111,B11111110,B00000011,B11111100,B00001111,B11110000,B00111000,B00011111,B11100000,
 B11111111,B11111111,B00000011,B11111100,B00001111,B11110000,B00010000,B00011111,B11100000,
 B01111111,B11111111,B00000011,B11111100,B00001111,B11110000,B00000000,B00011111,B11100000,
 B00000000,B11111111,B00000011,B11111100,B00001111,B11110000,B00000000,B00011111,B11100000,
 B00000000,B11111111,B00000011,B11111100,B00001111,B11110000,B00000000,B00011111,B11100000,
 B00000000,B11111111,B00000011,B11111100,B00001111,B11110000,B00000000,B00011111,B11100000,
 B11111111,B11111111,B00111111,B11111111,B11001111,B11110000,B00000000,B00011111,B11100000,
 B11111111,B11111111,B00111111,B11111111,B11001111,B11110000,B00000000,B00011111,B11100000,
 B11111111,B11111110,B00111111,B11111111,B11001111,B11110000,B00000000,B00011111,B11100000,
 B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
 B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11100000,
};

void setup() {
  gb.begin();
  gb.setFrameRate(30);
  gb.titleScreen(F("by nomisre"));
}

void loop() {
  if(gb.update()){
    gb.display.drawBitmap(72,19,logo);
  }
}
nomisre
 
Posts: 6
Joined: Sat Jul 26, 2014 9:52 am

Re: center image/logo

Postby rodot » Sun Oct 05, 2014 4:16 pm

When you call gb.display.drawBitmap(x, y, bitmap), x and y are the coordinates of the top left corner. So if you want to center your bitmap you can do this:
Code: Select all
gb.display.drawBitmap((LCDWIDTH-67)/2, 0, logo);

where 67 is the actual width of your bitmap (as there is 5 empty columns on the right, 72 - 5 = 68)
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: center image/logo

Postby nomisre » Sun Oct 05, 2014 5:14 pm

Hmm, I see, but what do the 2 and 0 refer to?

Thanks
nomisre
 
Posts: 6
Joined: Sat Jul 26, 2014 9:52 am

Re: center image/logo

Postby DFX2KX » Mon Oct 06, 2014 3:43 am

nomisre wrote:Hmm, I see, but what do the 2 and 0 refer to?

Thanks

2 because you're cutting the difference between the screen and the logo in half (to center it) and 0 is for y because with Rodot's code, it'll be in the top-center. you could do the same with height if you wanted to.
DFX2KX
 
Posts: 250
Joined: Mon Apr 14, 2014 3:48 am


Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 46 guests

cron