Fixed double freeing.
This commit is contained in:
parent
a17e1e0c69
commit
1e635111d0
|
@ -26,8 +26,8 @@ void loop()
|
|||
// Display the maze
|
||||
void showMaze(const char *maze, int width, int height)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
for (int x = 0; x < width; x++)
|
||||
for (int y = 0; y < height; ++y)
|
||||
for (int x = 0; x < width; ++x)
|
||||
if (maze[x + y * width] == 1)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
|
|
|
@ -37,10 +37,7 @@ class Image : virtual public NetworkClient, virtual public Adafruit_GFX
|
|||
const char *fileName, int x, int y, bool dither = 0, bool invert = 0);
|
||||
bool drawBitmapFromSd(SdFile *p, int x, int y, bool dither = 0, bool invert = 0);
|
||||
|
||||
[[deprecated("Use drawImage, as this will soon become a private method.")]] bool drawBitmapFromWeb(const char *url,
|
||||
int x, int y,
|
||||
bool dither = 0,
|
||||
bool invert = 0);
|
||||
bool drawBitmapFromWeb(const char *url, int x, int y, bool dither = 0, bool invert = 0);
|
||||
bool drawBitmapFromWeb(WiFiClient *s, int x, int y, int32_t len, bool dither = 0, bool invert = 0);
|
||||
|
||||
bool drawJpegFromBuffer(uint8_t *buf, int32_t len, int x, int y, bool dither, bool invert);
|
||||
|
|
|
@ -109,7 +109,7 @@ bool Image::drawBitmapFromSd(SdFile *p, int x, int y, bool dither, bool invert)
|
|||
bool Image::drawBitmapFromWeb(const char *url, int x, int y, bool dither, bool invert)
|
||||
{
|
||||
bool ret = 0;
|
||||
int32_t defaultLen = 800 * 600 * 4;
|
||||
int32_t defaultLen = 800 * 600 * 4 + 150;
|
||||
uint8_t *buf = downloadFile(url, &defaultLen);
|
||||
|
||||
ret = drawBitmapFromBuffer(buf, x, y, dither, invert);
|
||||
|
@ -132,6 +132,7 @@ bool Image::drawBitmapFromWeb(WiFiClient *s, int x, int y, int32_t len, bool dit
|
|||
bool Image::drawBitmapFromBuffer(uint8_t *buf, int x, int y, bool dither, bool invert)
|
||||
{
|
||||
bitmapHeader bmpHeader;
|
||||
|
||||
readBmpHeader(buf, &bmpHeader);
|
||||
|
||||
if (!legalBmp(&bmpHeader))
|
||||
|
@ -148,7 +149,6 @@ bool Image::drawBitmapFromBuffer(uint8_t *buf, int x, int y, bool dither, bool i
|
|||
bufferPtr += ROWSIZE(bmpHeader.width, bmpHeader.color);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ void Image::displayBmpLine(int16_t x, int16_t y, bitmapHeader *bmpHeader, bool d
|
|||
switch (c)
|
||||
{
|
||||
case 1:
|
||||
writePixel(x + j, y, (invert ^ (palette[0] < palette[1])) ^ !!(pixelBuffer[j >> 3] & (1 << (7 - (j & 7)))));
|
||||
writePixel(x + j, y, (invert ^ (palette[0] > palette[1])) ^ !!(pixelBuffer[j >> 3] & (1 << (7 - (j & 7)))));
|
||||
break;
|
||||
// as for 2 bit, literally cannot find an example online or in PS, so skipped
|
||||
case 4: {
|
||||
|
|
|
@ -29,7 +29,7 @@ void setup()
|
|||
|
||||
display.begin();
|
||||
|
||||
display.joinAP("", "");
|
||||
display.joinAP("e-radionica.com", "croduino");
|
||||
|
||||
Serial.println();
|
||||
delay(500);
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
#include "Inkplate.h"
|
||||
#include "SdFat.h"
|
||||
|
||||
const int n = 500;
|
||||
|
||||
Inkplate display(INKPLATE_3BIT);
|
||||
Inkplate display(INKPLATE_1BIT);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
display.begin();
|
||||
|
||||
display.joinAP("", "");
|
||||
Serial.println(display.joinAP("e-radionica.com", "croduino"));
|
||||
|
||||
delay(500);
|
||||
}
|
||||
|
@ -20,8 +16,7 @@ void loop()
|
|||
{
|
||||
display.clearDisplay();
|
||||
|
||||
display.sdCardInit();
|
||||
display.drawPngFromSd("png.png", 0, 0, 1, 0);
|
||||
Serial.println(display.drawBitmapFromWeb("http://img.cale.es/bmp/fasani/5e5ff140694ee", 0, 0, 1, 0));
|
||||
|
||||
display.display();
|
||||
delay(5000);
|
||||
|
|
Loading…
Reference in New Issue