Skip to content

Commit

Permalink
Add *broken* delta info
Browse files Browse the repository at this point in the history
  • Loading branch information
elpekenin committed Mar 28, 2023
1 parent 7b94c4c commit 93e0543
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
20 changes: 19 additions & 1 deletion lib/python/qmk/painter.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ def _render_image_metadata(metadata):
f"// Delta: {_render_values(metadata, 'delta')}",
])

deltas = []
for i, v in enumerate(metadata):
# Not a delta frame, go to next one
if not v["delta"]:
continue

# Unpack rect's coords
l, t, r, b = v["delta_rect"]

delta_px = (r - l) * (b - t)
px = size["width"] * size["height"]

# FIXME: May need need more chars here too
deltas.append(f"// Frame {i:3d}: ({l:3d}, {t:3d}) - ({r:3d}, {b:3d}) >> {delta_px:4d}/{px:4d} pixels ({100*delta_px/px:.2f}%)")

if deltas:
lines.append("// Areas on delta frames")
lines.extend(deltas)

return "\n".join(lines)


Expand Down Expand Up @@ -192,7 +211,6 @@ def render_header(subs):

source_file_template = """\
${license}
${metadata}
#include <qp.h>
Expand Down
12 changes: 10 additions & 2 deletions lib/python/qmk/painter_qgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,19 @@ def rgb888_to_qmk_hsv888(e):
delta_descriptor.write(fp)

# Add metadata, showed later in a comment in the generated file
metadata.append({
frame_metadata = {
"compression": frame_descriptor.compression,
"delta": frame_descriptor.is_delta,
"delay": frame_descriptor.delay,
})
}
if frame_metadata["delta"]:
frame_metadata.update({"delta_rect": [
delta_descriptor.left,
delta_descriptor.top,
delta_descriptor.right,
delta_descriptor.bottom,
]})
metadata.append(frame_metadata)

# Write out the data for this frame to the output
data_descriptor = QGFFrameDataDescriptorV1()
Expand Down

0 comments on commit 93e0543

Please sign in to comment.