Skip to content

Commit

Permalink
add end addr text for each region
Browse files Browse the repository at this point in the history
  • Loading branch information
cracked-machine committed Feb 4, 2024
1 parent 8a86913 commit 2f84793
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
10 changes: 5 additions & 5 deletions doc/example/report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![memory map diagram](report.png)
|name|origin|size|remaining|
|:-|:-|:-|:-|
|<span style='color:lime'>dtb</span>|0x90|0x100|0x258|
|<span style='color:seagreen'>kernel</span>|0x10|0x60|0x0|
|<span style='color:turquoise'>rootfs</span>|0x70|0x10|0x10|
|name|origin|size|remaining|collisions
|:-|:-|:-|:-|:-|
|<span style='color:navy'>dtb</span>|0x90|0x100|0x258|{}|
|<span style='color:lime'>kernel</span>|0x10|0x60|0x0|{}|
|<span style='color:lightskyblue'>rootfs</span>|0x70|0x10|0x10|{'kernel': '0x70'}|
Binary file modified doc/example/report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions mmdiagram/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,21 @@ def _create_diagram(self, region_list: List[mmdiagram.types.Region]):

img_main.paste(region_img, (self._legend_width + region_offset, region.origin), region_img)

# add origin text for the region
text_img = PIL.Image.new("RGB", (30, 10), color=(255, 255, 0))
text_canvas = PIL.ImageDraw.Draw(text_img)
text_canvas.text((0, 0), str(region._origin), fill="black")
text_img = text_img.rotate(180)
img_main.paste(text_img, (0, region.origin))
text_font = PIL.ImageFont.load_default(8)
# add text for the region origin
origin_text_img = PIL.Image.new("RGB", (30, 10), color=(255, 255, 255))
origin_text_canvas = PIL.ImageDraw.Draw(origin_text_img)
origin_text_canvas.text((0, 0), region._origin, fill="black", font=text_font)
origin_text_img = origin_text_img.rotate(180)
# add text for the region end
endaddr = region.origin + region.size
endaddr_text_img = PIL.Image.new("RGB", (30, 10), color=(255, 255, 255))
endaddr_text_canvas = PIL.ImageDraw.Draw(endaddr_text_img)
endaddr_text_canvas.text((0, 0), hex(endaddr), fill="black", font=text_font)
endaddr_text_img = endaddr_text_img.rotate(180)

img_main.paste(endaddr_text_img, (0, endaddr - 6))
img_main.paste(origin_text_img, (0, region.origin - 4))

# horizontal flip and write to file
img_main = img_main.rotate(180)
Expand Down

0 comments on commit 2f84793

Please sign in to comment.