多媒体工作难题总结

问题描述:

             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天的时间,但如果从外面往里找,也许就半天解决了。

 思维方式有问题,以后要从简单想起。






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值