Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FS.h"
- #include "SPIFFS.h"
- //#include<SPIFlash.h>
- #define TRUE 1
- #define FALSE 0
- //SPIFlash flash(SS1, &SPI1); //Use this constructor if using an SPI bus other than the default SPI. Only works with chips with more than one hardware SPI bus
- //SPIFlash flash(4,&SPI);
- #define SPI2_NSS_PIN 28
- #include "SPI.h"
- #include <Adafruit_GFX.h>
- //#include <ILI9488.h>
- // Use hardware SPI (on Uno, #13, #12, #11) and the above for Enable,CS/DC,Reset
- void setup() {
- unsigned long micross = micros();
- // transparentImage(Startbyte Pic,Startbyte background,x,y, width, height, Transparency Color);
- transparentImage(0,198900,0,0, 100, 100, 0xFFFFFF);
- Serial.println((micros() - micross) / 1000);
- }
- int z = 0;
- int p = 0;
- void loop() {
- }
- void transparentImage(uint32_t startpic, uint32_t startbackground, int x, int y, int width, int height, uint32_t tcolor) {
- //read background clipping
- File f = SPIFFS.open( "/pics.bin", "r");
- char *buf = (char*)malloc(width * height * 3);
- char *temp = (char*)malloc(width * 3);
- // Serial.println("1");
- unsigned long offset = 0;
- for (int i; i < height; i++) {
- unsigned long offset = startbackground + (x * width - (width - y) + (i * width * 3));
- f.seek(offset, SeekSet);
- f.readBytes((char*)temp, width * 3) ;
- memcpy( buf + (i * width), temp, (width * 3) );
- }
- // Inhalt der Textdatei wird gelesen...
- f.close();
- File fc = SPIFFS.open( "/pics.bin", "r");
- for (int i; i < height; i++) {
- unsigned long offset = startpic+i*width;
- fc.seek(offset, SeekSet);
- fc.readBytes((char*)temp, width * 3) ;
- for(int h=0;h<width*3;h=h+3)
- {
- uint32_t b = temp[h];
- b = (b<<8) | temp[h+1];
- b = (b<<8) | temp[h+2];
- uint32_t bp = buf[width*i+h];
- bp = (b<<8) |buf[width*i+h+1];
- bp = (b<<8) |buf[width*i+h+2];
- if(b!=bp){
- buf[width*i+h]=temp[h];
- buf[width*i+h+1]=temp[h+1];
- buf[width*i+h+2]=temp[h+2];
- }
- //memcpy( buf + (i * width), temp, (width * 3) );
- }
- // Inhalt der Textdatei wird gelesen...
- fc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment