Skip to content

Commit

Permalink
v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
melianmiko committed Jun 4, 2023
1 parent e6d3657 commit 6dd4ef6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ in application folder and just run:

./zmake file_to_process

**But in first of all, set `encode_mode` for your device.**
Different Amazfit devices has some differences in their graphic encoding formats.
By default, ZMake is configured to work with Mi Band 7, but if you want to use them with other
device, change `encode_mode` in `zmake.json` to match your device:

| `encode_mode` | Devices |
|---------------------|----------------------------------------------------|
| `dialog` | Mi Band 7, Amazfit Band 7, Amazfit GTS 4 Mini |
| `nxp` | GTS 3/4, GTR 3/4, GTR 3 Pro, T-Rex 2/Ultra, Falcon |
| Not supported (MHS) | GTR Mini |

What they can do?
-----------------

Expand Down
9 changes: 9 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
zmake (1.9-1) bookworm jammy kinetic lunar; urgency=medium

* Fix image encoding for some devices
* BREAKING CHANGE: `swap_red_and_blue` config option isn't actual anymore
Now, it's combined with some other options to `encode_mode` option. Please,
after installing update configure them with table from README.md

-- MelianMiko <[email protected]> Sun, 04 Jun 2023 17:01:07 +0700

zmake (1.8.2-1) bookworm jammy kinetic lunar; urgency=medium

* Some minor fixes
Expand Down
2 changes: 1 addition & 1 deletion zmake/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from pathlib import Path

VERSION = "v1.8.2"
VERSION = "v1.9"

GUIDE = f"""zmake {VERSION} by melianmiko
Expand Down
19 changes: 11 additions & 8 deletions zmake/tga_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ def save_truecolor_tga(img: Image.Image, path: Path, depth, encode_mode="dialog"
img = img.convert("RGBA")
data = bytearray()

# TGA Width fix
real_width = img.width
if encode_mode == "nxp" and real_width % 16 != 0:
tga_width = real_width + 16 - (real_width % 16)
assert tga_width % 16 == 0
new_img = Image.new(img.mode, (tga_width, img.height))
new_img.paste(img)
img = new_img

data.append(46) # ID len
data.append(0) # Has colormap
data.append(2) # Mode
Expand All @@ -18,7 +27,7 @@ def save_truecolor_tga(img: Image.Image, path: Path, depth, encode_mode="dialog"

# ID data
data.extend(b"\x53\x4f\x4d\x48")
data.extend(img.width.to_bytes(2, byteorder="little"))
data.extend(real_width.to_bytes(2, byteorder="little"))
data.extend(b"\0" * 40)

# Image data
Expand All @@ -28,17 +37,11 @@ def save_truecolor_tga(img: Image.Image, path: Path, depth, encode_mode="dialog"
g = round(63/255 * pixel[1])
b = round(31/255 * pixel[2])

if encode_mode == "nxp":
r, b = b, r

data.append(((g & 0b111) << 5) + b)
data.append((r << 3) + (g >> 3))
elif depth == 32:
for r, g, b, a in img.getdata():
if encode_mode == "nxp":
data.extend([r, g, b, a])
else:
data.extend([b, g, r, a])
data.extend([b, g, r, a])
else:
raise ValueError("Not supported")

Expand Down
2 changes: 1 addition & 1 deletion zmake/zmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"auto_rgba": true,
"target_dir_override": "",

"encode_mode": "nxp",
"encode_mode": "dialog",
"package_extension": "zip",

"esbuild": false,
Expand Down

0 comments on commit 6dd4ef6

Please sign in to comment.