Skip to content

fix(android): scale about the view pivot when capturing TextureView/SurfaceView content - #676

Open
Nodonisko wants to merge 1 commit into
gre:masterfrom
Nodonisko:fix/android-scale-pivot
Open

fix(android): scale about the view pivot when capturing TextureView/SurfaceView content#676
Nodonisko wants to merge 1 commit into
gre:masterfrom
Nodonisko:fix/android-scale-pivot

Conversation

@Nodonisko

Copy link
Copy Markdown

Capturing a scaled TextureView/SurfaceView produces content at the correct size but anchored to the view's top-left corner instead of where it appears on screen. Cause: in applyTransformations the canvas scale is applied about the canvas origin, while Android renders view scale about the view's pivot (default: center) and the rotation call one line above already passes the pivot. Fix: pass the pivot to Canvas.scale (and the mirrored Matrix.postScale). Verified on a device against a scaled TextureView.

Minimal repro:

<ViewShot ref={ref}>
  <View style={{ transform: [{ scale: 0.7 }] }}>
    <Video source={...} />  {/* any TextureView-backed view */}
  </View>
</ViewShot>

On screen the video appears scaled about its center; in the captured image it is scaled about the top-left corner.

Co-Authored-By: Claude noreply@anthropic.com

https://claude.ai/code/session_018o7Mf9BAF9qMStB698ab1L

…urfaceView content

Canvas.scale was applied about the canvas origin while rotation already
uses the view's pivot, so captures of scaled TextureView/SurfaceView
content came out anchored at the top-left corner instead of where they
appear on screen. Pass the pivot to scale, matching how Android renders
view scale.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018o7Mf9BAF9qMStB698ab1L
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.

1 participant