簡體   English   中英

如何在Android中水平/垂直滾動全景圖像?

[英]How to horizontal/Vertical scroll a panoramic image in Android?

我正在尋找某種方式來制作滾動,或在Android中掃描全景圖像。 我的意思是顯示我的圖像的一部分調整圖像的高度(或垂直寬度)並自動緩慢移動視圖滾動所有圖像。 例如:

在此輸入圖像描述

這個圖像是如此之大,試圖在16:9設備中看到它(我的意思是一些細節),所以我想做的事情如下:

在此輸入圖像描述

只需在屏幕上顯示該部分並將其緩慢向右移動直到圖像結束。 在整個圖像中實現“滾動”效果。

我最近幾天一直在尋找網站和互聯網,我剛剛找到了PanoramicGL庫或一些觀看360º圖像的方法。

這是滾動 點擊這里

您必須使用PanoramaClient(它是Google Play服務的一部分)才能打開PhotoSphere照片。

可以在此Android開發人員博客文章中找到如何執行此操作的示例:

// This listener will be called with information about the given panorama.
OnPanoramaInfoLoadedListener infoLoadedListener =
new OnPanoramaInfoLoadedListener() {
@Override
public void onPanoramaInfoLoaded(ConnectionResult result,
                                 Intent viewerIntent) {
    if (result.isSuccess()) {
        // If the intent is not null, the image can be shown as a
        // panorama.
        if (viewerIntent != null) {
            // Use the given intent to start the panorama viewer.
            startActivity(viewerIntent);
        }
    }

    // If viewerIntent is null, the image is not a viewable panorama.
 }
 };
 // Create client instance and connect to it.
 PanoramaClient client = ...
 ...
 // Once connected to the client, initiate the asynchronous check on whether
 //the image is a viewable panorama.
 client.loadPanoramaInfo(infoLoadedListener, panoramaUri);

感謝kishu,我制作了自己的方法來動態制作全景圖像,具體取決於它是在橫向還是縱向模式下。

您可以忽略方法的方向值,我只使用它來將視頻的動畫從X更改為Y,如果我想在橫向中看到圖像。

 public void animatePanorama(int orientation) {

    int duration;
    // The milisecons that we will use dinamically for the animation, been this is 1,31milisecons for pixel
    float miliseconsPixel = 1.31f;
    float imageWidth;

    //Delta X and Y values for the animation
    float deltaX = 0f;
    float deltaY = 0f;
    float aspectRatio;
    //We get the drawable from the container to calcule his real Width and Height
    final Drawable d = mImageContainer.getDrawable();
    final int origWidth = d.getIntrinsicWidth();
    final int origHeight = d.getIntrinsicHeight();
    //With that we get the real aspect ratio and a duration

    if (origWidth > origHeight) {
        aspectRatio = (float) origWidth / (float) origHeight;
        duration = (int) (miliseconsPixel * origWidth);
        imageWidth = mImageContainer.getMeasuredHeight() * aspectRatio;
    } else {
        aspectRatio = (float) origHeight / (float) origWidth;
        duration = (int) (miliseconsPixel * origHeight);
        imageWidth = mImageContainer.getMeasuredWidth() * aspectRatio;
    }

    //Set if the animation will be horizontal(Portrait) or Vertical(landscape)
    if (orientation == 0 || orientation == 180)
        deltaX = imageWidth / 2f - mImageContainer.getMeasuredWidth() / 2;
    else
        deltaY = imageWidth / 2f - mImageContainer.getMeasuredHeight() / 2;

    //New Animation
    Animation animation = new TranslateAnimation(deltaX, -deltaX, deltaY, -deltaY);
    //Add Duration
    animation.setDuration(duration);
    animation.setFillAfter(true);
    //Add cycle for repeating mode
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.REVERSE);
    mImageContainer.startAnimation(animation);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM