notisrac / filetocarray Goto Github PK
View Code? Open in Web Editor NEWCoverts any file to a C style array. (It can also do image color format and size coversion)
Home Page: https://notisrac.github.io/FileToCArray
License: MIT License
Coverts any file to a C style array. (It can also do image color format and size coversion)
Home Page: https://notisrac.github.io/FileToCArray
License: MIT License
Hello, a TFT display control library has an example of using this PNG image to binary file converter. But it only works when the image is small.
// This example renders a png file that is stored in a FLASH array
// using the PNGdec library (available via library manager).// Note: The PNGDEC required lots of RAM to work (~40kbytes) so
// this sketch is will not run on smaller memory processors (e.g.
// ESP8266, STM32F103 etc.)// Image files can be converted to arrays using the tool here:
// https://notisrac.github.io/FileToCArray/
// To use this tool:
// 1. Drag and drop file on "Browse..." button
// 2. Tick box "Treat as binary"
// 3. Click "Convert"
// 4. Click "Save as file" and move the header file to sketch folder
// 5. Open the sketch in IDE
// 6. Include the header file containing the array (panda.h in this example)
https://github.com/Bodmer/TFT_eSPI/blob/master/examples/PNG%20Images/Flash_PNG/Flash_PNG.ino
If I take the basic 50x50 image that is attached here, both my C++ (Arduino) and an online tool are showing data corruption.
Basically a vertical line | is being skewed to /.
This can be tested my uploading the attached 50x50 jpg to the online example https://notisrac.github.io/FileToCArray/ then taking the HEX output and test the conversion back to an image online here https://mischianti.org/images-to-byte-array-online-converter-cpp-arduino/.
Oddly, the example Google.ico in the readme seems to work perfectly.
I have tested both jpg and bmp and was thinking it was me for 2 days until I started to count bits and tested the github test against converters.
Expected output can be created here https://www.digole.com/tools/PicturetoC_Hex_converter.php
These are the expected and actual arrays.
I'm happy to help out in any way that I can, this is a great tool to have JS get images into the correct format for e-Ink displays.
file size 143kB
see https://notisrac.github.io/FileToCArray/
When selecting "Code format" "Decimal (000)" and NOT "unsigned" (i.e. it should be signed values) and
"Data type" "char" or "int8_t", then the Result should NEVER contain values like 250, 202, etc - since these should be
negative numbers! (or there should at least be an option to allow that output)
Very good tool!
I add include guards into the generated header files directly adding them to my project.
It would be nice having them added by the tool.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.