|
Post by mmtbaris on Nov 19, 2015 2:14:05 GMT -8
Hi there,
I need to use lossless and alpha channel activated too many images in my project, so I can't use ".jpg" files and have to use asset converter to add images to my project. However, the problem is that the flash memory of ATmega is not enough to store all the converted image arrays inside. Are there any other methods to store asset arrays in SD card as data files and read them in run time?
If yes: - What should be the extension of such files that contains asset array data in sd card? - How can I handle these image files in source code?
Thank you, mmtbaris
|
|
|
Post by jamesbowman on Nov 19, 2015 18:04:49 GMT -8
Right. Say you have raw data in the SDcard files. The extension ".bin" is usual for this. This threads talks about how to create and load a raw bitmap: gameduino2.proboards.com/thread/243/display-array-uncompressed-bitmap-dataSo putting it together... with two monochrome images on SDcard, "picture1.bin" and "picture2.bin". Each is 320x240 = 76800 bytes long. This sketch loads them into a bitmap at address 0 in GPU memory. #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin();
// Set up a 320x240 L8 bitmap starting at 0 GD.BitmapSource(0); GD.BitmapLayout(L8, 320, 240); GD.BitmapSize(NEAREST, BORDER, BORDER, 320, 240);
GD.Clear(); GD.Begin(BITMAPS); GD.Vertex2ii((480 - 320) / 2, (272 - 240) / 2); GD.swap(); }
void load_picture(const char* filename) { GD.cmd_memwrite(0, 1L * 320 * 240); // For L8 320x240 bitmap GD.load(filename); }
void loop() { load_picture("picture1.bin"); delay(1000); load_picture("picture2.bin"); delay(1000); }
GD.load() is a useful function. It copies a file directly to the GPU's command stream. Because load_picture() first issues cmd_memwrite(), the following 76800 bytes get copied into the bitmap. Here is a version for RGB565 bitmap data: #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin();
// Set up a 320x240 RGBA4 bitmap starting at 0 GD.BitmapSource(0); GD.BitmapLayout(RGBA4, 320, 240); GD.BitmapSize(NEAREST, BORDER, BORDER, 320, 240);
GD.Clear(); GD.Begin(BITMAPS); GD.Vertex2ii((480 - 320) / 2, (272 - 240) / 2); GD.swap(); }
void load_picture(const char* filename) { GD.cmd_memwrite(0, 2L * 320 * 240); // For RGBA4 320x240 bitmap GD.load(filename); }
void loop() { load_picture("picture1.bin"); delay(1000); load_picture("picture2.bin"); delay(1000); }
|
|
|
Post by mmtbaris on Jan 26, 2016 11:16:05 GMT -8
One more question, how can I derive these binary files from ".gd2 files"? For example, by using a hex editor, where should I edit in ".gd2" file, and how (delete/add/change bytes)?
|
|
|
Post by jamesbowman on Jan 27, 2016 7:18:19 GMT -8
Well, gd2 files (the files produced by the asset converter, and included with the GD2 library) are actually just raw instructions for the FT800 GPU. So in order to tell what a .gd2 does, you would have to duplicate all the actions of an FT800. This would be tricky!
So reversing a .gd2 file back to raw memory is not feasible.
|
|