PhotoView is used to zoom in PNG images. When zooming, FPS sags even on my galaxy s6 edge. Here is the activation code:

`public class PortfolioFullScreenActivity extends AppCompatActivity {

ImageView fullScreenImage; PhotoViewAttacher photoViewAttacher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.portfolio_page_activity); fullScreenImage = (ImageView) findViewById(R.id.image_full_screen); Intent intent = getIntent(); int position = intent.getIntExtra("position", 100); switch (position){ case 0: fullScreenImage.setImageResource(R.drawable.social_trading); break; case 1: fullScreenImage.setImageResource(R.drawable.social_trading); break; case 2: fullScreenImage.setImageResource(R.drawable.social_trading); break; case 3: fullScreenImage.setImageResource(R.drawable.social_trading); break; case 4: fullScreenImage.setImageResource(R.drawable.social_trading); break; case 5: fullScreenImage.setImageResource(R.drawable.social_trading); break; default: Toast.makeText(PortfolioFullScreenActivity.this, "Что-то пошло не так", Toast.LENGTH_SHORT).show(); } photoViewAttacher = new PhotoViewAttacher(fullScreenImage,true); } 

} `And the layout file:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".Activities.PortfolioFullScreenActivity"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/image_full_screen"/> </RelativeLayout>

    3 answers 3

    Listen up I know what you need !!! I recommend skelit display image (On Picasso) As I understand it, you are trying to display a very high resolution image. Well, in fact, if you blew off an image for FullHD resolution (1080x1080) using the centerInstance method, you will not notice any visual changes. But it will work many times faster)))

     Picasso.with(context) .load(new File(picPath)) .resize(MAX_WIDTH, MAX_HEIGHT) .centerInside() .into(imageView, new Callback() { @Override public void onSuccess() { Bitmap bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); imageView.setImageBitmap(bmp); progressBar.setVisibility(visible); } @Override public void onError() { progressBar.setVisibility(visible); } }); 
    • one
      Yes, you're right, thank you very much! - newakkoff

    How to optimize I can suggest using this design:

     imageView.setDrawingCacheEnabled(true); bitmap = Bitmap.createBitmap(v1.getDrawingCache()); 

    And further - we display the fixed bitmap instead of the original image enlarged by the tool.

    If a zoom event occurs again - we take the result again - we fix it in the bitmap and display it.

    True, then there will be problems - when to remove from view the PhotoView display container and when to return it and in what condition.

    But the solution also seems to be obvious: since PhotoView is doing well with events, we just remember the last scaling parameters and save them to a buffer variable. When a zoom event occurs, we restore PhotoView with the zoom option and frame position, remove the Bitmap “snapshot” and wait for the new snapshot to be taken again.

    Drawdowns in FPS will be only at the moments of zoom.

    • UPD: still FPS braking can be due to the fact that fragments of the scene "crawl out" beyond the screen (the scalable image can "creep away") - but this relates more to game development and is hardly applicable in this matter. - DimXenon
    • one
      Thanks for the help, but I think just to use lower resolution pictures (2000x2300 - now). - newakkoff

    I also used this library. It works very poorly when it comes to uploading files from outside and using inside ViewPager. Maybe off topic (I can’t tell you why your FPS is slowing you down), but I can recommend something else. Namely, this is View

    TouchImageView.java

     vh.photoView = (TouchImageView) layout.findViewById(R.id.photo); vh.photoView.setImageBitmap(bmp); 

    I do not watch any fps in the Sony Xperia Z1

    Update

    I recommend to glue the displayed image (for example, on Picasso). As I understand it, you are trying to display a very high resolution image. Well, in fact, if you cut off the image to FullHD resolution (1080x1080) using the centerInstance method, you will not notice any visual changes. But it will work many times faster.

    • I tried, unfortunately the effect is the same, which is very strange. - newakkoff