Recommendations for scalable representation of one large image?

I want to display a large image, about 800 x 800 pixels. I would like to be able to pan it in all four directions by dragging it with my finger. I would also like to be able to zoom in and out. I need to know the panorama values ​​and the zoom values ​​because I have to draw small text lines in certain places from the image.

For example, if the panorama is 100 pixels to the right, I need to know that I can add this offset to all my elements.

I wonder what a good way to do this. Do I have to implement it myself in the paint method in the View I view? Is there any other standard method? Essentially, it looks like a Google map view, only one big tile, but I need to draw my contacts on it using pan and zoom,

thank

+3
source share
1 answer

Hi guys, I tried a few months ago without success, finally I just uploaded the images inside a web browser, allowing me to control the zoom, and I was able to pan my image ...

public class PhotoZoom extends Activity  {

    private static final FrameLayout.LayoutParams ZOOM_PARAMS =
        new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT,
                Gravity.BOTTOM);

    private WebView PhotoZoom;
    private long lastTouchTime = -1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.photo_zoom);                  

        PhotoZoom = (WebView) findViewById(R.id.PhotoZoom);        
        PhotoZoom.setBackgroundColor(Color.BLACK);

        Bundle bundle = getIntent().getExtras();
        String Photoname = bundle.getString("URLPhoto");        
        PhotoZoom.loadUrl("content://com.jorgesys.pan/sdcard/myimages/" +fotoname);  

        WebSettings webSettings = PhotoZoom.getSettings();
        webSettings.setSavePassword(false);
        webSettings.setSaveFormData(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);       

        FrameLayout mContentView = (FrameLayout) getWindow().getDecorView().findViewById(android.R.id.content);
        View zoom = PhotoZoom.getZoomControls();

        mContentView.addView(zoom, ZOOM_PARAMS);
        zoom.setVisibility(View.VISIBLE);

    }
}
0
source

Source: https://habr.com/ru/post/1735133/


All Articles