Fix typos in PNG examples

This commit is contained in:
Bodmer
2023-02-17 16:00:17 +00:00
parent 5288630ba6
commit b4427d6895
5 changed files with 14 additions and 14 deletions

View File

@@ -18,7 +18,7 @@
PNG png; // PNG decoder inatance
#define MAX_IMAGE_WDITH 240 // Adjust for your images
#define MAX_IMAGE_WIDTH 240 // Adjust for your images
int16_t xpos = 0;
int16_t ypos = 0;
@@ -50,7 +50,7 @@ void loop()
{
int16_t rc = png.openFLASH((uint8_t *)panda, sizeof(panda), pngDraw);
if (rc == PNG_SUCCESS) {
Serial.println("Successfully png file");
Serial.println("Successfully opened png file");
Serial.printf("image specs: (%d x %d), %d bpp, pixel type: %d\n", png.getWidth(), png.getHeight(), png.getBpp(), png.getPixelType());
tft.startWrite();
uint32_t dt = millis();
@@ -72,7 +72,7 @@ void loop()
// you will need to adapt this function to suit.
// Callback function to draw pixels to the display
void pngDraw(PNGDRAW *pDraw) {
uint16_t lineBuffer[MAX_IMAGE_WDITH];
uint16_t lineBuffer[MAX_IMAGE_WIDTH];
png.getLineAsRGB565(pDraw, lineBuffer, PNG_RGB565_BIG_ENDIAN, 0xffffffff);
tft.pushImage(xpos, ypos + pDraw->y, pDraw->iWidth, 1, lineBuffer);
}

View File

@@ -24,7 +24,7 @@
PNG png; // PNG decoder instance
#define MAX_IMAGE_WDITH 240 // Sets rendering line buffer lengths, adjust for your images
#define MAX_IMAGE_WIDTH 240 // Sets rendering line buffer lengths, adjust for your images
// Include the TFT library - see https://github.com/Bodmer/TFT_eSPI for library information
#include "SPI.h"
@@ -60,7 +60,7 @@ void loop()
int16_t rc = png.openFLASH((uint8_t *)bob, sizeof(bob), pngDraw);
if (rc == PNG_SUCCESS) {
Serial.println("Successfully png file");
Serial.println("Successfully opened png file");
pngw = png.getWidth();
pngh = png.getHeight();
Serial.printf("Image metrics: (%d x %d), %d bpp, pixel type: %d\n", pngw, pngh, png.getBpp(), png.getPixelType());

View File

@@ -7,8 +7,8 @@
// This function will be called during decoding of the png file to render each image
// line to the TFT. PNGdec generates the image line and a 1bpp mask.
void pngDraw(PNGDRAW *pDraw) {
uint16_t lineBuffer[MAX_IMAGE_WDITH]; // Line buffer for rendering
uint8_t maskBuffer[1 + MAX_IMAGE_WDITH / 8]; // Mask buffer
uint16_t lineBuffer[MAX_IMAGE_WIDTH]; // Line buffer for rendering
uint8_t maskBuffer[1 + MAX_IMAGE_WIDTH / 8]; // Mask buffer
png.getLineAsRGB565(pDraw, lineBuffer, PNG_RGB565_BIG_ENDIAN, 0xffffffff);

View File

@@ -17,7 +17,7 @@
#include <PNGdec.h>
PNG png;
#define MAX_IMAGE_WDITH 240 // Adjust for your images
#define MAX_IMAGE_WIDTH 240 // Adjust for your images
int16_t xpos = 0;
int16_t ypos = 0;
@@ -67,7 +67,7 @@ void loop()
tft.startWrite();
Serial.printf("image specs: (%d x %d), %d bpp, pixel type: %d\n", png.getWidth(), png.getHeight(), png.getBpp(), png.getPixelType());
uint32_t dt = millis();
if (png.getWidth() > MAX_IMAGE_WDITH) {
if (png.getWidth() > MAX_IMAGE_WIDTH) {
Serial.println("Image too wide for allocated line buffer size!");
}
else {
@@ -93,7 +93,7 @@ void loop()
// you will need to adapt this function to suit.
// Callback function to draw pixels to the display
void pngDraw(PNGDRAW *pDraw) {
uint16_t lineBuffer[MAX_IMAGE_WDITH];
uint16_t lineBuffer[MAX_IMAGE_WIDTH];
png.getLineAsRGB565(pDraw, lineBuffer, PNG_RGB565_BIG_ENDIAN, 0xffffffff);
tft.pushImage(xpos, ypos + pDraw->y, pDraw->iWidth, 1, lineBuffer);
}

View File

@@ -22,7 +22,7 @@
#include <PNGdec.h>
PNG png;
#define MAX_IMAGE_WDITH 240 // Adjust for your images
#define MAX_IMAGE_WIDTH 240 // Adjust for your images
int16_t xpos = 0;
int16_t ypos = 0;
@@ -73,7 +73,7 @@ void loop()
tft.startWrite();
Serial.printf("image specs: (%d x %d), %d bpp, pixel type: %d\n", png.getWidth(), png.getHeight(), png.getBpp(), png.getPixelType());
uint32_t dt = millis();
if (png.getWidth() > MAX_IMAGE_WDITH) {
if (png.getWidth() > MAX_IMAGE_WIDTH) {
Serial.println("Image too wide for allocated lin buffer!");
}
else {
@@ -99,8 +99,8 @@ void loop()
// you will need to adapt this function to suit.
// Callback function to draw pixels to the display
void pngDraw(PNGDRAW *pDraw) {
uint16_t lineBuffer[MAX_IMAGE_WDITH];
static uint16_t dmaBuffer[MAX_IMAGE_WDITH]; // static so buffer persists after fn exit
uint16_t lineBuffer[MAX_IMAGE_WIDTH];
static uint16_t dmaBuffer[MAX_IMAGE_WIDTH]; // static so buffer persists after fn exit
png.getLineAsRGB565(pDraw, lineBuffer, PNG_RGB565_BIG_ENDIAN, 0xffffffff);
tft.pushImageDMA(xpos, ypos + pDraw->y, pDraw->iWidth, 1, lineBuffer, dmaBuffer);