Speed up zoom feature in ImageView

女生的网名这么多〃 提交于 2019-12-23 15:36:52

问题


I'm currently dealing with really big images (7-10mb) that cannot be resized or compressed for multiple reasons.

Now, the idea is to show them in a custom ImageView that enables the user to do the double-tap zoom, pinch to zoom, etc.

I used this library for the job: https://github.com/MikeOrtiz/TouchImageView

I've tried also other libraries but every other library is still really slow. Can someone give me some pointers/suggestion to make it faster (even writing my own C++ implentation)?

I'm a bit lost with all this "Matrix", "flig", "scale" thing and I have no idea of what I should touch to make it faster. If you know also other faster libraries (or how to use the custom Android implementation, that works really fast) it would be great.


回答1:


Have you tried using the DeepZoom feature of the Ion library?

https://github.com/koush/ion

https://www.youtube.com/watch?v=yIMltNEAKZY

If you don't want to to use opengl, or the above library does not work, you can also try playing with the http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html class. That is, keep track of "where" the user is (the viewport & zoom level) and decode that region off the main thread, pushing it into a canvas each time the user changes the input.




回答2:


Try a library called openCV or use it in matlab and then port the code into c/c++ for the image enhancement




回答3:


You could try manually implementing "mipmaps" -- different sizes of the same image, and then just use the most appropriately sized image for displaying.... thus when zoomed out, you'll be manipulating a relatively small image (but will still get the full detail of the large one when zoomed in).




回答4:


Try a library called PhotoView. When used together with picasso, i was able to achieve Onlick functionality enabling the user to click a smaller image and have it pop up the full image on a custom view complete with zoom functionality..It's really easy to implement




回答5:


One way of solving it is by using a WebView, which has support for panning, pinch-zooming etc. I think that image quality may be an issue though.

android-local-image-in-webview

android-add-image-to-webview-from-a-drawable

etc. You can also generate and load the html dynamically




回答6:


In TouchImageView.java class DoubleTapZoom set a lower or higher value for ZOOM_TIME

private class DoubleTapZoom implements Runnable {
 ......
 private static final float ZOOM_TIME = 500 //(lower - faster)
 ......


来源:https://stackoverflow.com/questions/32142204/speed-up-zoom-feature-in-imageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!