#54 refactor image decoder

pull/1/head
Thomas Ballmann 3 years ago
parent 76106e7afe
commit 647a19c4c4

@ -1,7 +1,7 @@
#include <Arduino.h>
#include <SPIFFS.h>
#include <JPEGDecoder.h>
#include "imageJPEG.h"
#include "JPEG.h"
#include "display.h"
File tmpFileBuffer;
@ -13,11 +13,6 @@ int16_t *blockDelta;
uint16_t displayWidth;
uint16_t blockDeltaSize;
// TODO uint32_t auf uint16_t ändern um speicher zu sparen
// https://os.mbed.com/handbook/C-Data-Types#integer-data-types
// image size limit prüfen damit alles in ein int16_t passt !
// dann ist genug speicher da :D
#define minimum(a, b) (((a) < (b)) ? (a) : (b))
void setupImageJPEG()
@ -28,14 +23,10 @@ void setupImageJPEG()
displayWidth = displayGetWidth();
blockDeltaSize = BLOCK_SIZE * displayWidth + 1;
blockDelta = new int16_t[blockDeltaSize];
Serial.println(sizeof(blockDelta[0]) * blockDeltaSize);
}
void jpegOpenFramebuffer()
{
displayOpen();
SPIFFS.remove("/tmp.jpeg");
tmpFileBuffer = SPIFFS.open("/tmp.jpeg", FILE_WRITE);
@ -171,10 +162,9 @@ void jpegFlushFramebuffer()
// print information about the image to the serial port
//jpegInfo();
// TODO use display size
if (JpegDec.width > 800 || JpegDec.height > 480)
if (JpegDec.width > displayGetWidth() || JpegDec.height > displayGetHeight())
{
Serial.println("image to big! skip rendering");
Serial.println("image resolution to big! skip rendering");
}
else
{

@ -4,9 +4,7 @@
#include "image.h"
extern structImageProcess ImageProcess;
// @see http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html
const char ImageHeaderJPEG[] = "\xFF\xD8\xFF\xE0\x00\x10\x4A\x46\x49\x46\x00";
// FF E0 00 10 4A 46 , 49 46 00
void setupImageJPEG();
void jpegOpenFramebuffer();

@ -1,5 +1,5 @@
#include <Arduino.h>
#include "imagePNG.h"
#include "PNG.h"
#include "pngle.h"
#include "display.h"
@ -20,7 +20,6 @@ void setupImagePNG()
void pngOpenFramebuffer()
{
displayOpen();
pngle_reset(pngle);
}

@ -1,6 +1,6 @@
#include "image.h"
#include "imagePNG.h"
#include "imageJPEG.h"
#include "format/JPEG.h"
#include "format/PNG.h"
#include "display.h"
structImageProcess ImageProcess;
@ -18,6 +18,7 @@ void setupImage()
ditheringNextRowDelta = new int16_t[ditheringBufferSize];
setupImageJPEG();
//setupImagePNG();
}
void ImageNew(int x, int y, int w, int h, bool dithering)
@ -39,7 +40,7 @@ void ImageWriteBuffer(uint8_t buff[], size_t c)
// initial detect format
if (ImageProcess.format == 0)
{
if (memcmp(buff, ImageHeaderPNG, sizeof(ImageHeaderPNG) - 1) == 0)
if (memcmp(buff, ImageHeaderPNG, sizeof(ImageHeaderPNG) - 1) == 0 && false)
{
Serial.println(" image format: PNG");
ImageProcess.format = 3;
@ -151,5 +152,6 @@ void ImageProcessPixel(uint16_t x, uint16_t y, uint8_t rgba[4])
}
}
displayWritePixel(ImageProcess.x + x, ImageProcess.y + y, blackOrWhite);
GFXcanvas1 *displayCanvas;
displayCanvas->drawPixel(ImageProcess.x + x, ImageProcess.y + y, (uint16_t)blackOrWhite);
}
Loading…
Cancel
Save