-
Notifications
You must be signed in to change notification settings - Fork 40
Zoom to specific pixel on image? #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hmmm you're right, this is confusing because the coordinate space of telephoto/zoomable/src/commonMain/kotlin/me/saket/telephoto/zoomable/RealZoomableState.kt Line 445 in 6d0ab81
Can you try converting your point on the image to the viewport's space? Here's something that might be useful: Lines 71 to 92 in fa16133
|
I've made some progress on this by introducing a coordinate system to differentiate between the two coordinate spaces (viewport vs zoomable content). Could you try this out in val imageCenter = SpatialOffset(
offset = unscaledImageSize.center,
space = CoordinateSpace.ZoomableContent,
)
zoomableState.zoomTo(
zoomFactor = zoomFactor,
centroid = imageCenter,
) FWIW this zooms while retaining the centroid's position fixed on screen -- just like what would happen if you double clicked at that point. I understand that this isn't exactly what you're looking for, and I'll be following up on that soon. You can find more details on the new APIs here: telephoto/zoomable/src/commonMain/kotlin/me/saket/telephoto/zoomable/ZoomableState.kt Lines 109 to 133 in 03b89d6
telephoto/zoomable/src/commonMain/kotlin/me/saket/telephoto/zoomable/SpatialOffset.kt Lines 13 to 36 in 8806fe4
|
Perhaps I'm being a bit dim here, but is 0.16.0-SNAPSHOT something I should be able to access from within Android studio directly? i.e. Because that version doesn't appear to be available and I can't find any reference to it anywhere. |
I think you need
in the repositories in your settings.gradle |
I have added the repository but it's not importing... settings.gradle.kts
libs.versions.toml
|
I think it needs to be in the |
I have a use case were I need to be able to programmatically zoom to a specific pixel on an image. I was hoping the
zoomTo
function would help me with this, but thecentroid
offset doesn't make sense to me.I was trying to zoom to the desired pixel using the following code:
When I do that, it just zooms to some location that doesn't match my expectations.
When I query the
zoomableState.contentTransformation.centroid
it seems to keep its values fairly contained to some small numbers. Perhaps to the size of the viewport?zf[1.0] c[Offset(362.2, 713.0)] csz[Size(3604.0, 3444.0)]
Is there some way to achieve my desired goal of centering the pixel that I want at the desired zoom level? I understand that if the pixel can't be centered, such as the image is at its bounds, the closest appropriate pixel would be centered.
The text was updated successfully, but these errors were encountered: