|
Post by cybotao on Jan 23, 2019 7:36:15 GMT -8
I'm trying to load 2 different images, one to act as a start up screen and one to act as a general background, however I cant seem to get it to load correctly. When the first image should load, it does so missing its bottom half, which then appears when the next screen should appear at the top, pushed over slight to the right. The 2nd image is pushed off the bottom by this. Any idea what might be causing this and how to fix it?
void setup { GD.begin(); //ADM Start Gameduino
GD.Clear();
GD.BitmapHandle(0); //ADM Assigns a handle to bitmap '0'
GD.cmd_loadimage(0, 0); //ADM Tells GPU an image file will be loaded at memory address '0'
GD.load("start.jpg"); //ADM Loads image file from microSD
GD.BitmapHandle(1); //ADM Assigns a hndle to bitmap '1'
GD.cmd_loadimage(0, 0); //ADM Tells GPU an image file will be loaded in the next available memory space
GD.load("adam.jpg"); //ADM Loads image file from microSD
GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw
GD.Vertex2ii(0, 0, 0); //ADM Loads the image from the cache and draws it to the screen
GD.swap();
delay(2000); } void loop { GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw
GD.Clear();
GD.Vertex2ii(0, 0, 1); //ADM Loads the image from the cache and draws it to the screen
GD.swap(); }
|
|
|
Post by tftlcdcyg on Jan 23, 2019 9:34:59 GMT -8
Share with us your images in order to review your code
|
|
|
Post by cybotao on Jan 23, 2019 9:37:53 GMT -8
I've attached them here. They worked fine on their own so I figured it was just some error in how I was trying to load multiple. Apologies for not originally including them. Attachments:
|
|
|
Post by tftlcdcyg on Jan 23, 2019 15:18:05 GMT -8
Try this:
#include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin(); //ADM Start Gameduino GD.Clear();
GD.BitmapHandle(0); //ADM Assigns a handle to bitmap '0' GD.cmd_loadimage(0, 0); //ADM Tells GPU an image file will be loaded at memory address '0' GD.load("start.jpg"); //ADM Loads image file from microSD
GD.BitmapHandle(1); //ADM Assigns a hndle to bitmap '1' GD.cmd_loadimage(-1, 0); //ADM Tells GPU an image file will be loaded in the next available memory space GD.load("adam.jpg"); //ADM Loads image file from microSD
GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw GD.Vertex2ii(0, 0, 0); //ADM Loads the image from the cache and draws it to the screen GD.swap();
delay(2000); }
void loop() { GD.Clear(); GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw GD.Vertex2ii(0, 0, 1); //ADM Loads the image from the cache and draws it to the screen GD.swap(); }
|
|
|
Post by cybotao on Jan 24, 2019 6:37:09 GMT -8
Try this: #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin(); //ADM Start Gameduino GD.Clear();
GD.BitmapHandle(0); //ADM Assigns a handle to bitmap '0' GD.cmd_loadimage(0, 0); //ADM Tells GPU an image file will be loaded at memory address '0' GD.load("start.jpg"); //ADM Loads image file from microSD
GD.BitmapHandle(1); //ADM Assigns a hndle to bitmap '1' GD.cmd_loadimage(-1, 0); //ADM Tells GPU an image file will be loaded in the next available memory space GD.load("adam.jpg"); //ADM Loads image file from microSD
GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw GD.Vertex2ii(0, 0, 0); //ADM Loads the image from the cache and draws it to the screen GD.swap();
delay(2000); }
void loop() { GD.Clear(); GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw GD.Vertex2ii(0, 0, 1); //ADM Loads the image from the cache and draws it to the screen GD.swap(); }
Gave that a shot, but for some reason it just hangs and refuses to load anything. Not even a Coprocessor error.
|
|
|
Post by jamesbowman on Jan 24, 2019 7:06:13 GMT -8
Maybe instead of
GD.cmd_loadimage(-1, 0); //ADM Tells GPU an image file will be loaded in the next available memory space
do this, since the argument is 32-bit:
GD.cmd_loadimage(-1L, 0); //ADM Tells GPU an image file will be loaded in the next available memory space
|
|
|
Post by cybotao on Jan 24, 2019 8:18:52 GMT -8
Maybe instead of GD.cmd_loadimage(-1, 0); //ADM Tells GPU an image file will be loaded in the next available memory space
do this, since the argument is 32-bit: GD.cmd_loadimage(-1L, 0); //ADM Tells GPU an image file will be loaded in the next available memory space
I gave loading it like that a shot. On the start screen appears near the bottom and above it is the 2nd screen stretched diagonally, and then when the 2nd screen should appear it only does so at the top. Images included cause Im bad at describing. Attachments:
|
|
|
Post by jamesbowman on Jan 24, 2019 8:50:11 GMT -8
OK, good that it's no longer crashing.
Looking at the JPGs now, I can see that they are too big for GD3's 1 Mbyte RAM.
(They're also not quite the right size for the display. They should be exactly 800x480, but they are 802 and 803 pixels wide).
At 800x480, a JPG takes 768Kbytes, so one will fit in RAM, but two won't.
I'd suggest loading them as you need them. Load time from microSD should be about 1/4 second, so might not be too noticeable. Is that an option?
|
|
|
Post by cybotao on Jan 24, 2019 9:00:46 GMT -8
OK, good that it's no longer crashing. Looking at the JPGs now, I can see that they are too big for GD3's 1 Mbyte RAM. (They're also not quite the right size for the display. They should be exactly 800x480, but they are 802 and 803 pixels wide). At 800x480, a JPG takes 768Kbytes, so one will fit in RAM, but two won't. I'd suggest loading them as you need them. Load time from microSD should be about 1/4 second, so might not be too noticeable. Is that an option? If the sizes are off, thats probably paint messing with them. Will look at trimming them up. But yes just loading in/replacing the images will work for my purposes. On another note, what is a better option for making images for gameduino. It doesnt seem to like anything I make in paint.net and normal paint has odd quirks like randomly adding a pixel or two.
|
|
|
Post by jamesbowman on Jan 24, 2019 12:45:03 GMT -8
I use Gimp. Gimps "Exporting to .jpg" has a bunch of options, and I make sure they're set like this. No progressive (because the hardware can't handle it) and a few other switches to improve compression. Of course you can also "export to .png" - this is lossless but much slower. The hardware is really fast at loading jpg.
|
|
|
Post by cybotao on Jan 24, 2019 15:42:12 GMT -8
I use Gimp. Gimps "Exporting to .jpg" has a bunch of options, and I make sure they're set like this. No progressive (because the hardware can't handle it) and a few other switches to improve compression. Of course you can also "export to .png" - this is lossless but much slower. The hardware is really fast at loading jpg. I'll take a look into figuring out gimp then. Thanks for the help.
|
|
|
Post by tftlcdcyg on Jan 24, 2019 16:46:06 GMT -8
#include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin(); //ADM Start Gameduino
GD.Clear(); GD.cmd_loadimage(0, 0); //ADM Tells GPU an image file will be loaded at memory address '0' GD.load("start.jpg"); //ADM Loads image file from microSD GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw GD.Vertex2ii(0, 0); //ADM Loads the image from the cache and draws it to the screen GD.swap();
delay(2000);
MP(); } void loop(){}
void MP() { GD.cmd_loadimage(0, 0); //ADM Tells GPU an image file will be loaded at memory address '0' GD.load("adam.jpg"); //ADM Loads image file from microSD
while(1) { GD.Clear(); GD.Begin(BITMAPS); //ADM Tells the GPU what type of image to draw GD.Vertex2ii(0, 0); //ADM Loads the image from the cache and draws it to the screen GD.swap(); } }
|
|