Skip to content

Commit 8a923b5

Browse files
Wayne Jialdesroches
Wayne Jia
authored andcommitted
tools: add gfx-convert
gfx-convert is a tool, usually to be run a Linux host PC, that converts SVG or PNG files into an eraw file. By doing this, EGT can render graphics faster. Signed-off-by: Wayne Jia <[email protected]> [[email protected]: style.sh script fixes] Tested-by: Ludovic Desroches <[email protected]>
1 parent 9fcec25 commit 8a923b5

File tree

3 files changed

+438
-0
lines changed

3 files changed

+438
-0
lines changed

tools/gfx-convert/Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CXX = g++
2+
CXXFLAGS = -std=c++17 $(shell pkg-config --cflags libegt) \
3+
-I../../src/detail/ -I../../external/cxxopts/include/ \
4+
-I../../external/rapidxml/ -Wall
5+
6+
LDFLAGS = $(shell pkg-config --libs libegt)
7+
8+
all: gfx-convert
9+
10+
gfx-convert: gfx-convert.cpp
11+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
12+
13+
clean:
14+
rm -f gfx-convert eraw.*

tools/gfx-convert/README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# gfx-convert tool
2+
3+
This tool is used to convert SVG or PNG file into eraw.bin which can be loaded
4+
by EGT code directly to make graphic render fast. Usually this tool is running
5+
on your Linux host PC, because it has no meaning if you convert graphics on
6+
embedded target.
7+
8+
## Usage Example
9+
10+
1. Before using this tool, please make sure that you've followed the egt build
11+
instruction to build egt library ready.
12+
```
13+
git clone --recursive https://github.com/linux4sam/egt.git
14+
cd egt
15+
./autogen.sh
16+
./configure
17+
make
18+
```
19+
2. Make the gfx-convert tool.
20+
```
21+
cd egt/tool/gfx-convert
22+
make
23+
```
24+
3. Start the gfx-convert, of course, you can run ./gfx-convert -h to get help.
25+
26+
```
27+
./gfx-convert -s
28+
./gfx-convert -i png picture1.png
29+
./gfx-convert -i png picture2.png
30+
......
31+
./gfx-convert -i png pictureN.png
32+
./gfx-convert file.svg
33+
./gfx-convert -e
34+
```
35+
4. When conversion finished, copy ./eraw.h to source code to include in your
36+
application cpp code, and copy ./eraw.bin to the target. At last your application
37+
will read eraw.bin on target to get the graphics data.
38+
39+
5. The generated eraw.h has an array inidicating the graphics id with offset and
40+
length, and it has an array index in the comment. So when you are coding, you could
41+
use the array index directly without iterating the array to find the graphics you
42+
want. There is an example in egt/examples/motorcycledash.cpp, please refer to that
43+
to learn how to use the eraw.h and eraw.bin.
44+
45+
## License
46+
47+
EGT is released under the terms of the `Apache 2` license. See the [COPYING](../COPYING)
48+
file for more information.

0 commit comments

Comments
 (0)