-->
Page 9 of 12

Re: ESP8266WebServer example

PostPosted: Sun Jul 19, 2015 8:53 am
by matkar
To correct the missing images substitute function:
void handle_image() with
Code: Select allvoid handle_image() {
  WiFiClient client = server.client();
  client.write(image, sizeof(image));
  server.send(200, "image/png", "");
}


I was searching for an application that would transform png images to the necessary byte array. Unfortunately I couldn't find any. If anybody knows where to get one, please let us know.

For smaller pictures the parsing can be done manually with the help of some tools. I used http://www.fileformat.info/tool/hexdump.htm online service to convert my PNG to hex. I copied the result to libreoffice writer where I removed the unnecessary portions (columns) and added "0x" columns and commas to the array. This way it takes only a few minutes for a small picture to adapt it to the correct format.

Regards,
Mat

Re: ESP8266WebServer example

PostPosted: Sun Jul 19, 2015 12:19 pm
by martinayotte
matkar wrote:I was searching for an application that would transform png images to the necessary byte array. Unfortunately I couldn't find any. If anybody knows where to get one, please let us know.


There is Hexy : https://github.com/tristan2468/Hexy/

But, unfortunately, the Linux binary isn't there any more.

Re: ESP8266WebServer example

PostPosted: Sun Jul 19, 2015 12:27 pm
by matkar
Thank you martinayotte! This is exactly what was needed :)

Re: ESP8266WebServer example

PostPosted: Sun Jul 19, 2015 12:47 pm
by martinayotte
For those on Linux, you will need to install "lazarus" and compile it yourself. Since I didn't want to mess around "lazarus-ide", I've used the following command line to get it compiled :

Code: Select all/usr/bin/fpc  -MObjFPC -Scgi -CX -O3 -OoREGVAR -Xs -XX -vewnhi -l -Fibuild -Fu/usr/lib/lazarus/0.9.30.2/lcl/units/x86_64-linux -Fu/usr/lib/lazarus/0.9.30.2/lcl/units/x86_64-linux/gtk2 -Fu/usr/lib/lazarus/0.9.30.2/packager/units/x86_64-linux -Fu. -FUbuild/ -FEbuild/ -ohexy -dLCL -dLCLgtk2 hexy.lpr