This is a project for a programming exercise required for an interview. A excutable is built to generate png files which can be recognised by a LCD model from a set of 4 digits IDs listed in text file.
The project is built via CMake in C++(gcc on both linux and Windows(mingw)) with unit test. libpng is used to generate png file and also being applied in unit test for image verification.
A python application has been added since 0.2 release.
folder discription ./src contains source code and cmake configuration file ./test a unit test program supporting ctest ./docs contains documents generated by doxygen, hopefull it will be helpful to understand the code ./python source file for python version of the application
I was trying to use stb image library which provide header file only implementation for png writting and reading(https://github.com/nothings/stb), because it doesn't need to install dependencies and would be great to support on different OS or environment. It was good at beggining to create png file but I figured out later that it seems not support 1 bit-depth png, somehow it upscale to 8bit grayscale image and wrong. Another library 'spng'(simple png) also doesn't support 1 bit-depth too, so the official libpng got its chance to prove its the right one, typical!
- install cmake: sudo apt-get install cmake
- install libpng: sudo apt-get install libpng-dev
- install zlib: sudo apt-get install zlib1g-dev
- download cmake installer via https://cmake.org/download/
- install cmake and add $CMAKE_Installed_DIR\bin into system paths
- install msys2(for mingw-w64 gcc) from https://www.msys2.org/#installation, following the instruction, somehow easy and clear to follow
- install libpng via mysys console: pacman -S mingw-w64-ucrt-x86_64-libpng
- install zlib via mysys console: pacman -S mingw-w64-ucrt-x86_64-zlib
- Install python 3.x
- Install pypng: pip install pypng
- unzip the zip file to a folder
- open a terminal and access to the root foler in the terminal
- configure cmake build by command: 'cmake -S . -B build'
- go into build directory, and build the program by command: 'make'
- unzip the zip file to a folder
- open a command console and access to the root folder
- FINDPNG and FINDZLIB in CMakeLists is not working on my case, but you may be lucker than me 3.1 set PNG and ZLIB variables manually in CMakeLists.txt like following(E:/msys64/ is where I installed msys2):
set(PNG_INCLUDE_DIR "E:/msys64/mingw64/include") set(PNG_LIBRARIES "E:/msys64/mingw64/lib/libpng.dll.a") set(ZLIB_LIBRARIES "E:/msys64/mingw64/lib/libz.dll.a")
- configure cmake build by command: 'cmake -S . -B build -G "MinGW Makefiles"'
- go into build directory, and build the program by command: 'mingw32-make.exe'
Easy life, you don't need to compile anything unless...
- in terminal, goto
$project_dir$ /build/src folder - run: 'LngPngGenerator ../../resource/test.txt'
- a set of png files will be generated under current folder
- in command console, goto
$project_dir$ \build\src folder - run: 'LngPngGenerator.exe ....\resource\test.txt'
- a set of png files will be generated under current folder
- go to
$project_dir$ /python folder - run: "python PyIdToLcdPng.py -f ..\resource\test.txt -o .\results"
ex. Xing JIN
- 0.1
- Initial Release
Free without any license required
Inspiration, code snippets, etc.