Skip to content

fix: rotate origin in drawImage#557

Merged
daveallie merged 1 commit intocrosspoint-reader:masterfrom
maeveynot:rotate-drawimage
Jan 27, 2026
Merged

fix: rotate origin in drawImage#557
daveallie merged 1 commit intocrosspoint-reader:masterfrom
maeveynot:rotate-drawimage

Conversation

@maeveynot
Copy link
Contributor

@maeveynot maeveynot commented Jan 26, 2026

Summary

This was originally a comment in #499, but I'm making it its own PR, because it doesn't depend on anything there and then I can base that PR on this one.

Currently, drawBitmap is used for covers and sleep wallpaper, and drawImage is used for the boot logo. drawBitmap goes row by row and pixel by pixel, so it respects the renderer orientation. drawImage just calls the EInkDisplay's drawImage, which works in the eink panel's native display orientation.

drawImage rotates the x,y coordinates where it's going to draw the image, but doesn't account for the fact that the northwest corner in portrait orientation becomes, the southwest corner of the image rectangle in the native orientation. The boot and sleep activities currently work around this by calculating the northeast corner of where the image should go, which becomes the northwest corner after rotateCoordinates.

I think this wasn't really apparent because the CrossPoint logo is rotationally symmetrical. The EInkDisplay drawImage always draws the image in native orientation, but that looks the same for the "X" image.

If we rotate the origin coordinate in GfxRenderer's drawImage, we can use a much clearer northwest corner coordinate in the boot and sleep activities. (And then, in #499, we can actually rotate the boot screen to the user's preferred orientation).

This does not yet rotate the actual bits in the image; it's still displayed in native orientation. This doesn't affect the rotationally-symmetric logo, but if it's ever changed, we will probably want to allocate a new u8int[] and transpose rows and columns if necessary.

Additional Context

I've created an additional branch on top of this to demonstrate by replacing the logo with a non-rotationally-symmetrical image:

Cat-in-a-pan-128-bw

master...maeveynot:rotated-cat

(many thanks to https://notisrac.github.io/FileToCArray/)

As you can see, it is always drawn in native orientation, which makes it sideways (turned clockwise) in portrait.


AI Usage

No

@daveallie daveallie enabled auto-merge (squash) January 27, 2026 11:59
@daveallie daveallie disabled auto-merge January 27, 2026 11:59
@daveallie daveallie merged commit 51c5c3c into crosspoint-reader:master Jan 27, 2026
6 checks passed
@maeveynot maeveynot deleted the rotate-drawimage branch January 27, 2026 16:35
jdk2pq added a commit to jdk2pq/crosspoint-reader that referenced this pull request Jan 28, 2026
* master: (33 commits)
  feat: add HalDisplay and HalGPIO (crosspoint-reader#522)
  feat: Display epub metadata on Recents (crosspoint-reader#511)
  chore: Cut release 0.16.0
  fix: Correctly render italics on image alt placeholders (crosspoint-reader#569)
  chore: .gitignore: add compile_commands.json & .cache (crosspoint-reader#568)
  fix: Render keyboard entry over multiple lines (crosspoint-reader#567)
  fix: missing front layout in mapLabels() (crosspoint-reader#564)
  refactor: Re-work for OTA feature (crosspoint-reader#509)
  perf: optimize large EPUB indexing from O(n^2) to O(n) (crosspoint-reader#458)
  feat: Add Spanish hyphenation support (crosspoint-reader#558)
  feat: Add support to B&W filters to image covers (crosspoint-reader#476)
  feat(ux): page turning on button pressed if long-press chapter skip is disabled (crosspoint-reader#451)
  feat: Add status bar option "Full w/ Progress Bar" (crosspoint-reader#438)
  fix: Validate settings on read. (crosspoint-reader#492)
  fix: rotate origin in drawImage (crosspoint-reader#557)
  feat: Extract author from XTC/XTCH files (crosspoint-reader#563)
  fix: add txt books to recent tab (crosspoint-reader#526)
  docs: add font generation commands to builtin font headers (crosspoint-reader#547)
  docs: Update README with supported languages for EPUB  (crosspoint-reader#530)
  fix: Fix KOReader document md5 calculation for binary matching progress sync (crosspoint-reader#529)
  ...
Jessica765 pushed a commit to Jessica765/crosspoint-reader that referenced this pull request Feb 3, 2026
## Summary

This was originally a comment in crosspoint-reader#499, but I'm making it its own PR,
because it doesn't depend on anything there and then I can base that PR
on this one.

Currently, `drawBitmap` is used for covers and sleep wallpaper, and
`drawImage` is used for the boot logo. `drawBitmap` goes row by row and
pixel by pixel, so it respects the renderer orientation. `drawImage`
just calls the `EInkDisplay`'s `drawImage`, which works in the eink
panel's native display orientation.

`drawImage` rotates the x,y coordinates where it's going to draw the
image, but doesn't account for the fact that the northwest corner in
portrait orientation becomes, the southwest corner of the image
rectangle in the native orientation. The boot and sleep activities
currently work around this by calculating the north*east* corner of
where the image should go, which becomes the northwest corner after
`rotateCoordinates`.

I think this wasn't really apparent because the CrossPoint logo is
rotationally symmetrical. The `EInkDisplay` `drawImage` always draws the
image in native orientation, but that looks the same for the "X" image.

If we rotate the origin coordinate in `GfxRenderer`'s `drawImage`, we
can use a much clearer northwest corner coordinate in the boot and sleep
activities. (And then, in crosspoint-reader#499, we can actually rotate the boot screen
to the user's preferred orientation).

This does *not* yet rotate the actual bits in the image; it's still
displayed in native orientation. This doesn't affect the
rotationally-symmetric logo, but if it's ever changed, we will probably
want to allocate a new `u8int[]` and transpose rows and columns if
necessary.

## Additional Context

I've created an additional branch on top of this to demonstrate by
replacing the logo with a non-rotationally-symmetrical image:

<img width="128" height="128" alt="Cat-in-a-pan-128-bw"
src="https://github.com/user-attachments/assets/d0b239bc-fe75-4ec8-bc02-9cf9436ca65f"
/>


crosspoint-reader/crosspoint-reader@master...maeveynot:rotated-cat

(many thanks to https://notisrac.github.io/FileToCArray/)

As you can see, it is always drawn in native orientation, which makes it
sideways (turned clockwise) in portrait.

---

### AI Usage

No

Co-authored-by: Maeve Andrews <[email protected]>
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
## Summary

This was originally a comment in crosspoint-reader#499, but I'm making it its own PR,
because it doesn't depend on anything there and then I can base that PR
on this one.

Currently, `drawBitmap` is used for covers and sleep wallpaper, and
`drawImage` is used for the boot logo. `drawBitmap` goes row by row and
pixel by pixel, so it respects the renderer orientation. `drawImage`
just calls the `EInkDisplay`'s `drawImage`, which works in the eink
panel's native display orientation.

`drawImage` rotates the x,y coordinates where it's going to draw the
image, but doesn't account for the fact that the northwest corner in
portrait orientation becomes, the southwest corner of the image
rectangle in the native orientation. The boot and sleep activities
currently work around this by calculating the north*east* corner of
where the image should go, which becomes the northwest corner after
`rotateCoordinates`.

I think this wasn't really apparent because the CrossPoint logo is
rotationally symmetrical. The `EInkDisplay` `drawImage` always draws the
image in native orientation, but that looks the same for the "X" image.

If we rotate the origin coordinate in `GfxRenderer`'s `drawImage`, we
can use a much clearer northwest corner coordinate in the boot and sleep
activities. (And then, in crosspoint-reader#499, we can actually rotate the boot screen
to the user's preferred orientation).

This does *not* yet rotate the actual bits in the image; it's still
displayed in native orientation. This doesn't affect the
rotationally-symmetric logo, but if it's ever changed, we will probably
want to allocate a new `u8int[]` and transpose rows and columns if
necessary.

## Additional Context

I've created an additional branch on top of this to demonstrate by
replacing the logo with a non-rotationally-symmetrical image:

<img width="128" height="128" alt="Cat-in-a-pan-128-bw"
src="https://github.com/user-attachments/assets/d0b239bc-fe75-4ec8-bc02-9cf9436ca65f"
/>


crosspoint-reader/crosspoint-reader@master...maeveynot:rotated-cat

(many thanks to https://notisrac.github.io/FileToCArray/)

As you can see, it is always drawn in native orientation, which makes it
sideways (turned clockwise) in portrait.

---

### AI Usage

No

Co-authored-by: Maeve Andrews <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants