Giter Club home page Giter Club logo

Comments (8)

saket avatar saket commented on May 29, 2024

… gave a weirdly scaled image in case the image is smaller than screen resolution.

Interesting. ZoomableImage uses scaledInsideAndCenterAligned to support this same use case -- images that are smaller than layout bounds. Can you share some code, the images you're using and your device resolution?

from telephoto.

AntsyLich avatar AntsyLich commented on May 29, 2024

In case of ZoomableImage the underline Image's content scale is ContentScale.Inside using ContentScale.Inside with scaledInsideAndCenterAligned doesn't produce any issue but in my case i want to use ContentScale.Fit which with scaledInsideAndCenterAligned and an image smaller than screen resolution makes the displayed image weirdly zoomed in. In my case I tested with the small image below on a 720x1600 resolution device

Untitled

from telephoto.

AntsyLich avatar AntsyLich commented on May 29, 2024

@saket any update?

from telephoto.

saket avatar saket commented on May 29, 2024

from telephoto.

saket avatar saket commented on May 29, 2024

I tried out the above image on a 720x1600 display but I'm unable to reproduce the problem. @AntsyLich please share a screenshot and some code? A reproducer project would be the best if you've got time.

ZoomableAsyncImage(
  model = R.drawable.check_pattern,
  contentDescription = …,
  contentScale = ContentScale.Fit,
)

Screenshot_1689732925

from telephoto.

AntsyLich avatar AntsyLich commented on May 29, 2024

I also used.

var canvasSize by remember { mutableStateOf(Size.Zero) }
LaunchedEffect(canvasSize) {
    if (canvasSize == Size.Zero) return@LaunchedEffect
    zoomState.setContentLocation(
        ZoomableContentLocation.scaledInsideAndCenterAligned(),
    )
}

If you still can't reproduce I'll get a reproducible code up

from telephoto.

saket avatar saket commented on May 29, 2024

If you still can't reproduce I'll get a reproducible code up

Yes please! The code snippet you shared is incomplete. It doesn't show how canvasSize is populated.

I'm also curious to know why you aren't using ZoomableImage / ZoomableAsyncImage directly? Is that because they are incorrectly scaling your image?

from telephoto.

saket avatar saket commented on May 29, 2024

FWIW I've added ZoomableContentLocation.scaledToFitAndCenterAligned(), but you shouldn't need to use it if you're using ZoomableAsyncImage() / ZoomableGlideImage().

* Describes a zoomable content's location that is positioned in the center of its layout
* and is already scaled to fit the layout bounds while maintaining its original aspect ratio.
*
* That is, its alignment is [Alignment.Center] and scale is [ContentScale.Fit].
*
* In most cases [ZoomableContentLocation.scaledInsideAndCenterAligned] should be preferred over
* this because telephoto works best when [ZoomableState.contentScale] is the source of truth of
* the content's scale.
*/
@Stable
fun scaledToFitAndCenterAligned(size: Size?): ZoomableContentLocation {

It'll be available in the next release.

from telephoto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.