29 lines
		
	
	
		
			740 B
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			740 B
		
	
	
	
		
			C++
		
	
	
	
| // Here are the callback functions that the decPNG library
 | |
| // will use to open files, fetch data and close the file.
 | |
| 
 | |
| File pngfile;
 | |
| 
 | |
| void * pngOpen(const char *filename, int32_t *size) {
 | |
|   Serial.printf("Attempting to open %s\n", filename);
 | |
|   pngfile = FileSys.open(filename, "r");
 | |
|   *size = pngfile.size();
 | |
|   return &pngfile;
 | |
| }
 | |
| 
 | |
| void pngClose(void *handle) {
 | |
|   File pngfile = *((File*)handle);
 | |
|   if (pngfile) pngfile.close();
 | |
| }
 | |
| 
 | |
| int32_t pngRead(PNGFILE *page, uint8_t *buffer, int32_t length) {
 | |
|   if (!pngfile) return 0;
 | |
|   page = page; // Avoid warning
 | |
|   return pngfile.read(buffer, length);
 | |
| }
 | |
| 
 | |
| int32_t pngSeek(PNGFILE *page, int32_t position) {
 | |
|   if (!pngfile) return 0;
 | |
|   page = page; // Avoid warning
 | |
|   return pngfile.seek(position);
 | |
| }
 |