多媒體工作難題總結

問題描述:

             Camera中拍攝圖片後,通過主Activity中的public void gotoGallery()進入圖片廊,發現豎屏拍攝的圖片與上一張拍攝的圖片不對稱,但橫屏拍攝的圖片不會這樣。橫屏拍攝的圖片與上一張水平方向很對稱。


分析問題的步驟:

            <1>通過手動public  abstract  class LocalMediaData implements LocalData

 VideoData d = new VideoData(id, title, mimeType, dateTakenInSeconds,
                    dateModifiedInSeconds, path, width, height, sizeInBytes,
                    latitude, longitude, durationInSeconds);//這個方法主要對數據進行處理

              自己手動修改圖片的大小把小圖(320*240)改成大圖(3420*1200) 後,圖片正常顯示了。但這繼續分析下去,不能解決根本問題。

            <2>發現通過手動滑動到Gallery圖庫,圖片顯示正常;準備模仿側滑的方法來處理圖片,是圖片先正常

顯示,給出一個解決方案,等項目在測試的時候,在想最好的解決方案。(急於1天左右拿出解決方案)

            <3>通過一天的打adb log 發現一些問題,最終解決。

                       adb logcat -v time *:V > test.log

                   

                        通過從裏到外,慢慢發現時PhotoModule.java 中的問題

                        1》首先研究側滑類()public class FilmStripView extends ViewGroup implements BottomControlsListener {

<span style="font-size:18px;">/**
         * Layouts the view in the area assuming the center of the area is at a
         * specific point of the whole filmstrip.
         *
         * @param drawArea The area when filmstrip will show in.
         * @param refCenter The absolute X coordination in the whole filmstrip
         *            of the center of {@code drawArea}.
         * @param scale The current scale of the filmstrip.
         */
        public void layoutIn(Rect drawArea, int refCenter, float scale) {
            final float translationX = (mTranslationXAnimator.isRunning() ?
                    (Float) mTranslationXAnimator.getAnimatedValue() : 0f);
            int left = (int) (drawArea.centerX() + (mLeftPosition - refCenter + translationX) * scale);
            int top = (int) (drawArea.centerY() - (mView.getMeasuredHeight() / 2) * scale);
            Log.i(TAG, getId()+"+layoutIn ===top=== "+top+"==left==="+left );
            layoutAt(left, top);
            
            mView.setScaleX(scale);
            mView.setScaleY(scale);

            // update mViewArea for touch detection.
            int l = mView.getLeft();
            int t = mView.getTop();
            mViewArea.set(l, t,
                    l + mView.getMeasuredWidth() * scale,
                    t + mView.getMeasuredHeight() * scale);
        }

        /** Returns true if the point is in the view. */
        public boolean areaContains(float x, float y) {
            return mViewArea.contains(x, y);
        }</span>

研究LayoutIn 並打印一些關鍵的變量值,發現top的值與正常情況(側滑進入圖片)的值明顯大了許多。


    2》此時並不知道爲什麼這個top值會變大,(但卻忘了橫屏的時候值是對的),大腦一直侷限在側滑情況是對的。

想把側滑的代碼放入gotoGallery()方法中,來實現進入gallery圖庫。

             結果發現是找到的解決方案,但發現但不能解決根本問題,而且很麻煩。(思維的侷限性)

 

            最後在保存圖片的方法打印log  發現 在豎屏時 寬和高傳入方法的值是顛倒的。

           爲什麼顛倒呢?

             發現

         

<span style="font-size:14px;">private void GIFencode(){
       mGIFstatus = GIF_ENCODING;
       String title = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(System.currentTimeMillis()));
       String giffilename = PIC_PATH + title + ".gif";
       startGifencoding(mPiclist,giffilename,(int)count_num);
       Size PreviewSize = mParameters.getPreviewSize();
       
       if(mGIFOrientation == 90 || mGIFOrientation == 270){
           mActivity.getMediaSaveService().addGIFImage(title,
                   System.currentTimeMillis(), null,
                   PreviewSize.width/IN_SAMPLE_SIZE, PreviewSize.height/IN_SAMPLE_SIZE
                   , 0, mOnMediaSavedListener, mContentResolver);
       }else{
           mActivity.getMediaSaveService().addGIFImage(title,
                   System.currentTimeMillis(), null,
                   PreviewSize.height/IN_SAMPLE_SIZE, PreviewSize.width/IN_SAMPLE_SIZE
                   , 0, mOnMediaSavedListener, mContentResolver);   
       }
    }</span>
           傳入的值有問題。立馬 興奮了。


總結: 這個Cr解決用了接近2天的時間,但如果從外面往裏找,也許就半天解決了。

 思維方式有問題,以後要從簡單想起。






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章