Archive of the Gamebuino Classic forum (2014-2018), rebuilt from the pages kept by the Wayback Machine: only part of the topics and pages were captured. Read-only. Removal on request: hi@gamebuino.com.
Loading bitmaps from SD card
albertinjo Tue Jun 17, 2014 7:16 pm
Has anyone thought of adding a function to library that loads bitmaps from an SD card?
jonnection Wed Jun 18, 2014 7:12 am
I've thought about it too, and I'm sure also others.
The Buinomon crew will definitely need this feature to support the huge number of monster graphics they have in mind.
On Arduino forums, there seems to be consensus that 300KB/s 'should' be possible out of an SD card. The problem is the parsing speed, not the actual reading. Let's give a fairly conservative estimate of 50 KB/s, means 6250 bytes/sec = ~12 84x48 1-bit frames per second.
So in any case, should be doable and would be a very useful feature indeed.
EDIT: TYPO: Meant 50 KB/s not 50000 KB per sec
The Buinomon crew will definitely need this feature to support the huge number of monster graphics they have in mind.
On Arduino forums, there seems to be consensus that 300KB/s 'should' be possible out of an SD card. The problem is the parsing speed, not the actual reading. Let's give a fairly conservative estimate of 50 KB/s, means 6250 bytes/sec = ~12 84x48 1-bit frames per second.
So in any case, should be doable and would be a very useful feature indeed.
EDIT: TYPO: Meant 50 KB/s not 50000 KB per sec
adekto Wed Jun 18, 2014 10:10 am
interesting any example code we can try out
apart from buinomon project it be awsome for "full motion video" stuff
apart from buinomon project it be awsome for "full motion video" stuff
ripper121 Wed Jun 18, 2014 10:49 am
For better performance i think a SRAM Extention module is needed to load all the Sprites to the module, so we can read faster
adekto Wed Jun 18, 2014 11:47 am
ok, how would i make one of those?
ripper121 Wed Jun 18, 2014 12:18 pm
Like this:
http://arduino-related.livejournal.com/1414.html
ore use a eeprom
http://www.emartee.com/product/41949/Ar ... K-AT24C512
SPI Versions 1Kb - 1Mb:
http://www.atmel.com/products/memories/serial/spi.aspx
I2C Versions 1Kb - 1Mb:
http://www.atmel.com/products/memories/serial/i2c.aspx
http://arduino-related.livejournal.com/1414.html
ore use a eeprom
http://www.emartee.com/product/41949/Ar ... K-AT24C512
SPI Versions 1Kb - 1Mb:
http://www.atmel.com/products/memories/serial/spi.aspx
I2C Versions 1Kb - 1Mb:
http://www.atmel.com/products/memories/serial/i2c.aspx
jonnection Wed Jun 18, 2014 2:03 pm
Wait a moment... we were talking about a simple addition to the Gamebuino library that will work with any Gamebuino.
Now we're talking about serial SRAM.
One is a software modification, the other requires hardware changes to the Gamebuino / a hardware module.
While both are a solution to memory limitations, they are answers to 2 totally different questions.
Now we're talking about serial SRAM.
One is a software modification, the other requires hardware changes to the Gamebuino / a hardware module.
While both are a solution to memory limitations, they are answers to 2 totally different questions.
jonnection Thu Jun 19, 2014 1:07 pm
Youtube finally processed my video. It took more than 24 hours ... I do not know whats wrong with YT nowadays.
This is a short clip from a tech demo I did in 2011, 128x64 1bit streaming video on Arduino over serial link.
Sd card streaming video should therefore be very doable on Gamebuino.
The serial link baud rate was 57.6 KB/s or 115.2 KB/s. I can't remember. Frames per second was around 8-10 fps. I remember though that I had to limit the speed due to serial comms errors, so possibly it was as low as 57.6 KB/s.
This is a short clip from a tech demo I did in 2011, 128x64 1bit streaming video on Arduino over serial link.
Sd card streaming video should therefore be very doable on Gamebuino.
The serial link baud rate was 57.6 KB/s or 115.2 KB/s. I can't remember. Frames per second was around 8-10 fps. I remember though that I had to limit the speed due to serial comms errors, so possibly it was as low as 57.6 KB/s.
rodot Sun Jun 22, 2014 9:57 am
Take a look at this :)
mougino Sat Sep 26, 2015 7:45 am
This is an old topic, but I found it while looking for a code example to load a bitmap from SD (adekto asked it in the comments but there was no answer).
It happens I just wrote my own routine, to be used with petitFatFs. It is specific to my gamebook engine because the bitmap data is in the middle of a big file on SD (the book itself) and I use 0xff as marker to tell my engine there's a bitmap and not a text paragraph.
I'll write a dedicated sketch for loading a single bitmap file from SD. But the basics are here:
Note that in any way the bitmap needs to be converted first (Paintuino will soon be able to do that via an export button).
For this to work you'll also need an enhanced drawBitmap function inside "Display.cpp" (and declare it in "Display.h"), to be able to draw a bitmap from a (variable) char array:
Display.h addition:
Display.cpp addition:
Nicolas
It happens I just wrote my own routine, to be used with petitFatFs. It is specific to my gamebook engine because the bitmap data is in the middle of a big file on SD (the book itself) and I use 0xff as marker to tell my engine there's a bitmap and not a text paragraph.
I'll write a dedicated sketch for loading a single bitmap file from SD. But the basics are here:
- Code: Select all
Serial.begin(9600); PFFS.begin(10, rx, tx); // initialize petit_fatfs
pf_open("test.bmp");
char bmp[13]; // 1 byte for width + 1 byte for height + 11 bytes for 1 line of bitmap data (84/8 rounded-up)
gb.display.persistence=true; // stop clearing screen at every gb.update()
gb.display.clear();
bmp[0]=84; bmp[1]=1; // get bitmap data line by line i.e. bmp dimension is 84x1
WORD br;
for(byte y=0; y<48; y++) {
pf_lseek(y*11);
pf_read((void*)&bmp[2], 11, &br);
gb.display.drawBitmap(0, y, bmp); // and draw it!
}
Note that in any way the bitmap needs to be converted first (Paintuino will soon be able to do that via an export button).
For this to work you'll also need an enhanced drawBitmap function inside "Display.cpp" (and declare it in "Display.h"), to be able to draw a bitmap from a (variable) char array:
Display.h addition:
- Code: Select all
void drawBitmap(int8_t x, int8_t y, char *bitmap);
Display.cpp addition:
- Code: Select all
void Display::drawBitmap(int8_t x, int8_t y, char *bitmap) {
byte w = bitmap[0];
byte h = bitmap[1];
#if (ENABLE_BITMAPS > 0)
int8_t i, j, byteNum, bitNum, byteWidth = (w + 7) >> 3;
for (i = 0; i < w; i++) {
byteNum = i / 8;
bitNum = i % 8;
for (j = 0; j < h; j++) {
if ((bitmap[2 + j * byteWidth + byteNum]) & (B10000000 >> bitNum)) {
drawPixel(x + i, y + j);
}
}
}
#else
drawRect(x, y, w, h);
#endif
}
Nicolas
mougino Tue Sep 29, 2015 5:06 pm
Well ;) I went the extra mile...
Here is a sketch with a function drawBitmapFromSd(x,y,"SdPicture.bmp") that allows to draw a bitmap from a genuine monochrome bitmap on SD-Card!
So any black and white bitmap saved from MsPaint for example can be read and drawn anywhere on the screen. No need to convert the image beforehand.
Getting the data to display the bitmap is a little slow, so this isn't something to be used for fast streaming of pictures. Only a proof of concept that it can be done, and something useful to start from for anyone wanting to load a bitmap from SD :mrgreen:
Don't hesitate to give feedback!
Cheers,
Nicolas
Here is a sketch with a function drawBitmapFromSd(x,y,"SdPicture.bmp") that allows to draw a bitmap from a genuine monochrome bitmap on SD-Card!
So any black and white bitmap saved from MsPaint for example can be read and drawn anywhere on the screen. No need to convert the image beforehand.
Getting the data to display the bitmap is a little slow, so this isn't something to be used for fast streaming of pictures. Only a proof of concept that it can be done, and something useful to start from for anyone wanting to load a bitmap from SD :mrgreen:
Don't hesitate to give feedback!
Cheers,
Nicolas
Attachments: drawBitmapFromSd.zip (not archived)