Skip to content

Commit

Permalink
breaking-change: Remove canvasing from lower resolution (>32px) in Wi…
Browse files Browse the repository at this point in the history
…ndows Cursor

Related to ful1e5/Bibata_Cursor#149
  • Loading branch information
ful1e5 committed Feb 19, 2024
1 parent 486d9fb commit aa9ea8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Important Changes

- Remove canvasing from lower resolution (>32px) in Windows Cursor

### Issue Fixes

- Fixed python string template in Windows uninstallation script, reported on: https://github.com/ful1e5/clickgen/commit/4fbf21b1d04755c9a6bd2b77b5b69f9ad1c1b56b.
Expand Down
9 changes: 1 addition & 8 deletions src/clickgen/writer/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,8 @@ def to_cur(frame: CursorFrame) -> bytes:
if width > 256 or height > 256:
raise ValueError(f"Image too big for CUR format: {width}x{height}")

# Place cursor image in 32x32 canvas if png is smaller.
# Otherwise Cursors looks blurry
blob = BytesIO()
if width <= 32 or height <= 32:
canvas = Image.new("RGBA", (32, 32), (0, 0, 0, 0))
canvas.paste(clone, (0, 0))
canvas.save(blob, "PNG")
else:
image.image.save(blob, "PNG")
image.image.save(blob, "PNG")

blob.seek(0)
image_data.append(blob.read())
Expand Down

1 comment on commit aa9ea8a

@stanio
Copy link

@stanio stanio commented on aa9ea8a Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm getting it right. It could be a preparation for a bigger change but I would like to clarify.

The previous behavior appears o.k. Windows doesn't use bitmap canvases smaller than 32x32 for cursors. I speculate this change targets my ful1e5/Bibata_Cursor#149 (comment):

There's no possibility to download higher resolution (>= 32) of a "Regular" or "Large" size schemes

Every dimension >= 32 produces just an "Extra-Large" scheme cursors

It is contrary to this change. When a size of "32" or larger is generated it is always an "Extra-Large" (meaning full canvas) size scheme. I've tried to clarify the distinction between "Regular", "Large", and "Extra-Large" sizing schemes, and the output resolutions (pixel/canvas sizes) previously. Each of these sizing schemes has the same resolutions (canvas sizes):

Regular Large Extra-Large
32 32 32
48 48 48
64 64 64
96 96 96
128 128 128

The difference is how much of the canvas the cursor shape is occupying. With "Extra-Large" the cursor shape occupies the full canvas – the other sizing schemes occupy a smaller part of the full canvas. Just what has been previously achieved with rendering 22px size, placing it on a 32px canvas – achieves a Regular scheme, 32x32 (standard) resolution. However, any size >= 32 generated by Bibata is always full canvas and thus "Extra-Large". There's no possibility of generating a Regular scheme, 64x64 resolution, for example.

In any case, in ful1e5/Bibata_Cursor#149 I'm arguing the generated Windows cursors should contain all standard resolutions (32, 48, 64, 96, 128). There would be three Pointer.cur variants for each scheme (Regular, Large, Extra-Large), and each variant would contain "all" resolutions.

Please sign in to comment.