Skip to content

Commit 1628803

Browse files
committed
Fix header position and remove networkController dependency
1 parent 69d69a4 commit 1628803

File tree

6 files changed

+43
-21
lines changed

6 files changed

+43
-21
lines changed

src/graphics/Image/Image.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
*
1616
* @authors Soldered
1717
***************************************************/
18-
19-
#include "Image.h"
2018
#include "Inkplate.h"
19+
#include "Image.h"
2120
#include "TJpeg/TJpg_Decoder.h"
2221
#include "pgmspace.h"
2322

src/graphics/Image/Image.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,35 @@
2020
#define __IMAGE_H__
2121

2222
#include "../../features/SdFat/SdFat.h"
23-
#include "../../system/NetworkController/NetworkController.h"
23+
#include "WiFi.h"
2424

2525
class Inkplate;
2626

27+
/**
28+
* @brief BitmapHeader structure that includes standard bitmap parameters
29+
*/
30+
struct bitmapHeader
31+
{
32+
uint16_t signature; // Is picture a legal BMP
33+
uint32_t fileSize; // Size of image in bytes
34+
uint32_t startRAW; // Address where raw data (pixel array) can be found/is started
35+
uint32_t dibHeaderSize; // Size of the header in bytes
36+
uint32_t width; // Width of image
37+
uint32_t height; // Height of image
38+
uint16_t color; // The number of bits per pixel, which is the color depth of
39+
// the image. Typical values are 1, 4, 8, 16, 24 and 32
40+
uint32_t compression; // The compression method being used. See the next table
41+
// for a list of possible values
42+
};
43+
2744
/**
2845
* @brief Image basic class for work with images
2946
*/
30-
class Image : virtual public NetworkController
47+
class Image
3148
{
3249
public:
50+
51+
3352
typedef enum
3453
{
3554
BMP,

src/graphics/Image/ImageDither.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
*
1616
* @authors Soldered
1717
***************************************************/
18-
#include "Image.h"
1918
#include "Inkplate.h"
19+
#include "Image.h"
20+
2021

2122
/**
2223
* @brief ditherGetPixelBmp calculates dither for given pixel in bmp

src/graphics/Image/bmpHelpers/ImageBMP.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
*
1616
* @authors Soldered.com
1717
***************************************************/
18-
#include "../Image.h"
1918
#include "Inkplate.h"
19+
#include "../Image.h"
20+
2021

2122

2223
/**
@@ -216,11 +217,11 @@ bool Image::drawBitmapFromWeb(const char *url, int x, int y, bool dither, bool i
216217

217218
if (strncmp(url, "http://", 7) == 0)
218219
{
219-
buf = downloadFile(url, &defaultLen);
220+
buf = _inkplate->downloadFile(url, &defaultLen);
220221
}
221222
else if (strncmp(url, "https://", 8) == 0)
222223
{
223-
buf = downloadFileHTTPS(url, &defaultLen);
224+
buf = _inkplate->downloadFileHTTPS(url, &defaultLen);
224225
}
225226

226227
// Image sometimes doesn't download, so
@@ -255,7 +256,7 @@ bool Image::drawBitmapFromWeb(const char *url, int x, int y, bool dither, bool i
255256
bool Image::drawBitmapFromWeb(WiFiClient *s, int x, int y, int32_t len, bool dither, bool invert)
256257
{
257258
bool ret = 0;
258-
uint8_t *buf = downloadFile(s, len);
259+
uint8_t *buf = _inkplate->downloadFile(s, len);
259260

260261
// Image sometimes doesn't download, so
261262
// check if buffer is empty to avoid trying to draw an empty image
@@ -452,7 +453,7 @@ bool Image::drawBmpFromWebAtPosition(const char *url, const Position &position,
452453
{
453454
bool ret = 0;
454455
int32_t defaultLen = E_INK_WIDTH * E_INK_HEIGHT * 4 + 150;
455-
uint8_t *buf = downloadFileHTTPS(url, &defaultLen);
456+
uint8_t *buf = _inkplate->downloadFileHTTPS(url, &defaultLen);
456457

457458
// Image sometimes doesn't download, so
458459
// check if buffer is empty to avoid trying to draw an empty image

src/graphics/Image/jpegHelpers/ImageJPEG.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
* @authors Soldered
1717
***************************************************/
1818
#include "../../../system/defines.h"
19+
#include "Inkplate.h"
1920
#include "../Image.h"
2021
#include "../TJpeg/TJpg_Decoder.h"
21-
#include "Inkplate.h"
22+
2223

2324
extern Image *_imagePtrJpeg;
2425

@@ -126,11 +127,11 @@ bool Image::drawJpegFromWeb(const char *url, int x, int y, bool dither, bool inv
126127

127128
if (strncmp(url, "http://", 7) == 0)
128129
{
129-
buf = downloadFile(url, &defaultLen);
130+
buf = _inkplate->downloadFile(url, &defaultLen);
130131
}
131132
else if (strncmp(url, "https://", 8) == 0)
132133
{
133-
buf = downloadFileHTTPS(url, &defaultLen);
134+
buf = _inkplate->downloadFileHTTPS(url, &defaultLen);
134135
}
135136

136137
// Image sometimes doesn't download, so
@@ -169,11 +170,11 @@ bool Image::drawJpegFromWebAtPosition(const char *url, const Position &position,
169170
uint8_t *buff = 0;
170171
if (strncmp(url, "http://", 7) == 0)
171172
{
172-
buff = downloadFile(url, &defaultLen);
173+
buff = _inkplate->downloadFile(url, &defaultLen);
173174
}
174175
else if (strncmp(url, "https://", 8) == 0)
175176
{
176-
buff = downloadFileHTTPS(url, &defaultLen);
177+
buff = _inkplate->downloadFileHTTPS(url, &defaultLen);
177178
}
178179

179180
// Image sometimes doesn't download, so
@@ -296,7 +297,7 @@ bool Image::drawJpegFromSdAtPosition(const char *fileName, const Position &posit
296297
bool Image::drawJpegFromWeb(WiFiClient *s, int x, int y, int32_t len, bool dither, bool invert)
297298
{
298299
bool ret = 0;
299-
uint8_t *buff = downloadFile(s, len);
300+
uint8_t *buff = _inkplate->downloadFile(s, len);
300301

301302
// Image sometimes doesn't download, so
302303
// check if buffer is empty to avoid trying to draw an empty image

src/graphics/Image/pngHelpers/ImagePNG.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
* @authors Soldered.com
1717
***************************************************/
1818
#include "../../../system/defines.h"
19+
#include "Inkplate.h"
1920
#include "../Image.h"
2021
#include "../pngle/pngle.h"
21-
#include "Inkplate.h"
22+
2223

2324
extern Image *_imagePtrPng;
2425

@@ -211,11 +212,11 @@ bool Image::drawPngFromWeb(const char *url, int x, int y, bool dither, bool inve
211212

212213
if (strncmp(url, "http://", 7) == 0)
213214
{
214-
buf = downloadFile(url, &defaultLen);
215+
buf = _inkplate->downloadFile(url, &defaultLen);
215216
}
216217
else if (strncmp(url, "https://", 8) == 0)
217218
{
218-
buf = downloadFileHTTPS(url, &defaultLen);
219+
buf = _inkplate->downloadFileHTTPS(url, &defaultLen);
219220
}
220221

221222
// Image sometimes doesn't download, so
@@ -265,7 +266,7 @@ bool Image::drawPngFromWeb(WiFiClient *s, int x, int y, int32_t len, bool dither
265266
_pngY = y;
266267
pngle_set_draw_callback(pngle, pngle_on_draw);
267268

268-
uint8_t *buff = downloadFile(s, len);
269+
uint8_t *buff = _inkplate->downloadFile(s, len);
269270

270271
// Image sometimes doesn't download, so
271272
// check if buffer is empty to avoid trying to draw an empty image
@@ -312,7 +313,7 @@ bool Image::drawPngFromWebAtPosition(const char *url, const Position &position,
312313
pngle_set_draw_callback(pngle, pngle_on_draw);
313314

314315
int32_t defaultLen = E_INK_WIDTH * E_INK_HEIGHT * 4 + 100;
315-
uint8_t *buff = downloadFile(url, &defaultLen);
316+
uint8_t *buff = _inkplate->downloadFile(url, &defaultLen);
316317

317318
// Image sometimes doesn't download, so
318319
// check if buffer is empty to avoid trying to draw an empty image

0 commit comments

Comments
 (0)