martinberlin / eink-calendar

A very easy, almost zero-configuration, ESP8266/ESP32 E-ink calendar. Caution: UNMAINTAINED Please use CalEPD / Cale-idf
http://cale.es
MIT License
103 stars 9 forks source link

8/9 BMP image headers and imageOffset #11

Closed martinberlin closed 4 years ago

martinberlin commented 4 years ago

Yesterday a small Eink with ESP32 included arrived from China and I started to do some tests and see if I can correct the slight image shift bug we have with the current firmware. So I compared TTGO T5 SPIFFs file base reading with our reading and this is what I found. To see the Bug just watch this short 9 seconds video

TEST A) Reading image from WiFi client stream: BMP starts here. File size: 4050 Image Offset: 146 Header size: 124 Width * Height: 250 x 122 / Bit Depth: 1

TEST B) File based example: Loading image '/test.bmp' File size: 3966 Image Offset: 62 Header size: 40 Bit Depth: 1 Image size: 250x122

El filesize is different when reading it on stream mode: 4050 vs 3966 = 84

Image Offset: 62 + 84 = 146

So the image Offset seemed Ok but our own calculation to move the Client pointer to the start of the image was wrong. Updating this seemed to do the trick, I was starting to read the image binary too soon, that caused a shift in the X axis you can see in this video:

long bytesRead = 32; // summing the whole BMP info headers

long bytesRead = 34; // new value with the 2 start bytes of BMP signature added 0x4D42

Target test branch: https://github.com/martinberlin/eink-calendar/tree/c/research @IoTPanic

martinberlin commented 4 years ago

Resolved!