|
Post by NeX on Sept 22, 2015 6:49:50 GMT -8
Hi there,
I am trying to display Jpgs and assets at the same time but i cant figure it out.
i want to use a JPG as a background, and then display assets over the top, but it seems that using GD.load fills the video memory with the jpg and then trying to call assets results on glitches on the screen.
is it possible to use a JPG as a background and then display assets over the top?
thanks
|
|
|
Post by NeX on Oct 3, 2015 1:30:26 GMT -8
bump,
anyone? i am sure there must be an order in which data is loaded into the graphics memory but I can't figure it out, thanks
|
|
|
Post by jamesbowman on Oct 4, 2015 8:48:33 GMT -8
Yes, when mixing assets with loaded jpegs you have to take care that: (1) they use different places in video memory (2) they use different bitmap handles The asset converter always starts using bitmap handles from zero, and video memory from zero. So the easiest way is to load the assets, THEN load the JPEGs. The asset converter always defines a symbol ASSETS_END that is the address of the first free byte in video memory, so taking the 'walk' example and loading a JPEG:  #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
static int a[256];
#include "walk_assets.h"
void setup() { GD.begin(); LOAD_ASSETS(); for (int i = 0; i < 256; i++) a[i] = GD.random(512);
// Load the JPG into handle 1, *above* the assets in memory GD.BitmapHandle(1); GD.cmd_loadimage(ASSETS_END, 0); GD.load("healsky3.jpg"); }
void loop() { GD.ClearColorRGB(0x000050); GD.Clear(); GD.Begin(BITMAPS); GD.Vertex2ii(0, 0, 1); for (int i = 0; i < 256; i++) { GD.ColorRGB(i, i, i); GD.Vertex2ii(a[i], i, WALK_HANDLE, (a[i] >> 2) & 7); a[i] = (a[i] + 1) & 511; } GD.swap(); }
|
|
|
Post by jamesbowman on Oct 4, 2015 8:55:39 GMT -8
And going a bit further with a second JPG:  #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
static int a[256];
#include "walk_assets.h"
void setup() { GD.begin(); LOAD_ASSETS(); for (int i = 0; i < 256; i++) a[i] = GD.random(512);
// Load the JPG into handle 1, *above* the assets in memory GD.BitmapHandle(1); GD.cmd_loadimage(ASSETS_END, 0); GD.load("healsky3.jpg");
// Another JPG into handle 2, address '-1' tells the loader to append into memory GD.BitmapHandle(2); GD.cmd_loadimage(-1, 0); GD.load("sunrise.jpg"); }
void loop() { GD.ClearColorRGB(0x000050); GD.Clear(); GD.Begin(BITMAPS); GD.Vertex2ii(0, 0, 1); // draw 'healsky3.jpg' GD.Vertex2ii(100, 100, 2); // draw 'sunrise.jpg' for (int i = 0; i < 256; i++) { GD.ColorRGB(i, i, i); GD.Vertex2ii(a[i], i, WALK_HANDLE, (a[i] >> 2) & 7); a[i] = (a[i] + 1) & 511; } GD.swap(); }
|
|
|
Post by NeX on Oct 5, 2015 8:46:30 GMT -8
Perfect thanks James, ASSETS_END was the missing piece to the puzzle, thanks!
|
|
|
Post by tftlcdcyg on Nov 16, 2015 23:27:04 GMT -8
Is it possible to load two group of assets? for example iconsb.h and iconsc.h icons.rar (41.97 KB)
|
|
|
Post by tftlcdcyg on Nov 17, 2015 0:12:39 GMT -8
sorry, answer in bad post 
|
|