Yeah, I've read through that post before. I'm a bit surprised that someone hasn't written a library for this purpose already. As near as I can tell, the process would be as follows:
Makea BMP sprite in a some drawing software and pick a color for transparent pixels
Load the bg image into memory
Load the sprite into memory
Use the sprite's origin point to find that location in the bg image memory array
Step through the sprite memory array and bg image memory array together
If the color of the sprite pixel is the color declared as transparent, replace the value in the sprite array with the value in the bg image array
Once done, draw the sprite. Or maybe just draw each pixel as you go along.
I wonder what the speed constraints would be with this technique. Do you think iterating through both those locations in memory for each frame would create a noticeable delay in animation?
Does anyone know of a better method?
Also, would someone be able to show how to read the bytes in an Adafruit_Image? I have been able to print the value in each index of a small hard coded byte array to the serial monitor, but when I try to look at an Adafruit_Image I get a type error.
Something like this would be awesome:
Code: Select all
#include <Adafruit_ImageReader.h>
#include <SdFat.h>
SdFat SD;
Adafruit_ImageReader reader(SD);
Adafruit_Image image;
int len;
void setup() {
Serial.begin(9600);
reader.loadBMP("/sprite.bmp", image);
len = some magical way to get the length of image
for (int i = 0; i < len; i++) {
Serial.println(some fancy trickery to print the value of each index in image)
}
}
void loop() {
}