Skip to content
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

Slow zoom #142

Open
salamanders opened this issue Apr 2, 2019 · 0 comments
Open

Slow zoom #142

salamanders opened this issue Apr 2, 2019 · 0 comments

Comments

@salamanders
Copy link

I'd like to create a "slow zoom to center of photo" BufferedImage sequence, and I think this library can do it without using external hacks, but when I tried, it came out all janky.

val scaled =
        Canvas(maxRes.width, maxRes.height, Positions.CENTER).apply(
                Thumbnails.of(file)
                        .size(maxRes.width, maxRes.height)
                        .asBufferedImage())

for (i in 0 until maxFrames) {
    // not proportional :/
    val trimmed = scaled.getSubimage(i, i, scaled.width - (2 * i), scaled.height - (2 * i))
    var t = Thumbnails.of(trimmed).size(maxRes.width, maxRes.height)
    if (orientation != 0) {
        t = t.rotate(orientation.toDouble())
    }
    yield(t.asBufferedImage())
}

Is there a better way to do the Canvas trim and a proportional edge-trim as the frames progress? I've got the two Thumbnails.of which smells wrong, and I know the 2 * i doesn't respect the image ratio, so... ya. But I'm hopeful because I just found out about Canvas. Not sure how to incorporate it into ThumbnailBuilder chain yet, but still looking!

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

No branches or pull requests

1 participant