当前位置: 首页>>代码示例>>C#>>正文


C# PhotoCamera.Dispose方法代码示例

本文整理汇总了C#中PhotoCamera.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# PhotoCamera.Dispose方法的具体用法?C# PhotoCamera.Dispose怎么用?C# PhotoCamera.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhotoCamera的用法示例。


在下文中一共展示了PhotoCamera.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UninitializeCamera

        void UninitializeCamera(PhotoCamera camera)
        {
            if (camera == null)
                return;

            camera.Initialized -= CollectCameraCaps;
            camera.Dispose();
        }
开发者ID:seriema,项目名称:WP7Caps,代码行数:8,代码来源:CameraInfo.cs

示例2: Init

        /**
         * Initializing the ioctls.
         */
        public void Init(Ioctls ioctls, Core core, Runtime runtime)
        {
            mCamera = new PhotoCamera(mCameraType);
            mVideoBrush = new VideoBrush();

            runtime.RegisterCleaner(delegate()
            {
                if (null != mCamera)
                {
                    mCamera.Dispose();
                    mCamera = null;
                }
            });

            // this should be set according to the orientation of
            // the device I guess.

            // we need to handle the camera orientation by hand
            PhoneApplicationPage currentPage = (((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage);

            // we need to handle the initial page orientation
            double rotation = mCamera.Orientation;
            if (currentPage.Orientation == PageOrientation.LandscapeLeft)
            {
                rotation -= 90;
            }
            else if (currentPage.Orientation == PageOrientation.LandscapeRight)
            {
                rotation += 90;
            }
            mVideoBrush.RelativeTransform = new CompositeTransform()
            {
                CenterX = 0.5,
                CenterY = 0.5,
                Rotation = rotation
            };

            // on orientation changed, we need to rotate the video brush
            currentPage.OrientationChanged += new System.EventHandler<OrientationChangedEventArgs>(
                delegate(object o, OrientationChangedEventArgs args)
                {
                    rotation = mCamera.Orientation;
                    if (args.Orientation == PageOrientation.LandscapeLeft)
                    {
                        rotation -= 90;
                    }
                    else if (args.Orientation == PageOrientation.LandscapeRight)
                    {
                        rotation += 90;
                    }

                    mVideoBrush.RelativeTransform = new CompositeTransform()
                    {
                        CenterX = 0.5,
                        CenterY = 0.5,
                        Rotation = rotation
                    };
                });

            /**
             * Stores an output format in fmm parameter.
             * @param _index int the index of the required format.
             * @param _fmt int the momory address at which to write the output format dimensions.
             *
             * Note: the _index should be greater than 0 and smaller than the number of camera formats.
             */
            ioctls.maCameraFormat = delegate(int _index, int _fmt)
            {
                System.Windows.Size dim;
                if (GetCameraFormat(_index, out dim) == false)
                    return MoSync.Constants.MA_CAMERA_RES_FAILED;

                core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.width,
                    (int)dim.Width);
                core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.height,
                    (int)dim.Height);

                return MoSync.Constants.MA_CAMERA_RES_OK;
            };

            /**
            * Returns the number of different output formats supported by the current device's camera.
            * \< 0 if there is no camera support.
            * 0 if there is camera support, but the format is unknown.
            */
            ioctls.maCameraFormatNumber = delegate()
            {
                // if the camera is not initialized, we cannot access any of its properties
                if (!isCameraInitialized)
                {
                    // because the cammera is supported but not initialized, we return 0
                    return 0;
                }

                IEnumerable<System.Windows.Size> res = mCamera.AvailableResolutions;
                if (res == null) return 0;
                IEnumerator<System.Windows.Size> resolutions = res.GetEnumerator();
//.........这里部分代码省略.........
开发者ID:NiklasNummelin,项目名称:MoSync,代码行数:101,代码来源:MoSyncCameraModule.cs

示例3: Init

        public void Init(Ioctls ioctls, Core core, Runtime runtime)
        {
            mCamera = new PhotoCamera(CameraType.Primary);
            mVideoBrush = new VideoBrush();
            mVideoBrush.SetSource(mCamera);
            mVideoBrush.Stretch = Stretch.Uniform;

            runtime.RegisterCleaner(delegate()
            {
                mCamera.Dispose();
                mCamera = null;
            });

            // this should be set according to the orientation of
            // the device I guess.
            mVideoBrush.RelativeTransform = new CompositeTransform()
            {
                CenterX = 0.5,
                CenterY = 0.5,
                Rotation = 90
            };

            ioctls.maCameraFormat = delegate(int _index, int _fmt)
            {
                System.Windows.Size dim;
                if (GetCameraFormat(_index, out dim) == false)
                    return MoSync.Constants.MA_CAMERA_RES_FAILED;

                core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.width,
                    (int)dim.Width);
                core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.height,
                    (int)dim.Height);

                return MoSync.Constants.MA_CAMERA_RES_OK;
            };

            ioctls.maCameraFormatNumber = delegate()
            {
                IEnumerable<System.Windows.Size> res = mCamera.AvailableResolutions;
                if (res == null) return 0;
                IEnumerator<System.Windows.Size> resolutions = res.GetEnumerator();
                resolutions.MoveNext();
                int number = 0;
                while (resolutions.Current != null)
                {
                    number++;
                }
                return number;
            };

            ioctls.maCameraStart = delegate()
            {
                return 0;
            };

            ioctls.maCameraStop = delegate()
            {
                return 0;
            };

            ioctls.maCameraSetPreview = delegate(int _widgetHandle)
            {
                // something like
                // videoBrush = ((CameraViewFinder)runtime.GetModule<MoSyncNativeUIModule>.GetWidget(_widgetHandle)).GetBrush();
                // videoBrush.SetSource(mCamera)
                IWidget w = runtime.GetModule<NativeUIModule>().GetWidget(_widgetHandle);
                if (w.GetType() != typeof(MoSync.NativeUI.CameraPreview))
                {
                    return MoSync.Constants.MA_CAMERA_RES_FAILED;
                }
                NativeUI.CameraPreview prev = (NativeUI.CameraPreview)w;
                System.Windows.Controls.Canvas canvas = prev.GetViewFinderCanvas();
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    canvas.Background = mVideoBrush;
                });

                return 0;
            };

            ioctls.maCameraSelect = delegate(int _cameraNumber)
            {
                CameraType cameraType = CameraType.Primary;
                if(_cameraNumber == MoSync.Constants.MA_CAMERA_CONST_BACK_CAMERA)
                {
                    cameraType = CameraType.Primary;
                }
                else if(_cameraNumber == MoSync.Constants.MA_CAMERA_CONST_FRONT_CAMERA)
                {
                    cameraType = CameraType.FrontFacing;
                }

                if(mCamera==null || mCamera.CameraType != cameraType)
                {
                    mCamera = new PhotoCamera(cameraType);
                    if(mVideoBrush == null)
                        mVideoBrush = new VideoBrush();
                    mVideoBrush.SetSource(mCamera);
                }

//.........这里部分代码省略.........
开发者ID:patrickbroman,项目名称:MoSync,代码行数:101,代码来源:MoSyncCameraModule.cs

示例4: Init

        /**
         * Initializing the ioctls.
         */
        public void Init(Ioctls ioctls, Core core, Runtime runtime)
        {
            mCamera = new PhotoCamera(mCameraType);
            mVideoBrush = new VideoBrush();

            runtime.RegisterCleaner(delegate()
            {
                if (null != mCamera)
                {
                    mCamera.Dispose();
                    mCamera = null;
                }
            });

            PhoneApplicationPage currentPage = (((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage);

            // set the initial camera orientation in respect to the current page orientation
            SetInitialCameraOrientation(currentPage);
            // handle current page orientation and adjust the camera orientation accordingly
            HandleDeviceOrientation(currentPage);

            /**
             * Stores an output format in fmm parameter.
             * @param _index int the index of the required format.
             * @param _fmt int the momory address at which to write the output format dimensions.
             *
             * Note: the _index should be greater than 0 and smaller than the number of camera formats.
             */
            ioctls.maCameraFormat = delegate(int _index, int _fmt)
            {
                System.Windows.Size dim;
                if (GetCameraFormat(_index, out dim) == false)
                    return MoSync.Constants.MA_CAMERA_RES_FAILED;

                core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.width,
                    (int)dim.Width);
                core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.height,
                    (int)dim.Height);

                return MoSync.Constants.MA_CAMERA_RES_OK;
            };

            /**
            * Returns the number of different output formats supported by the current device's camera.
            * \< 0 if there is no camera support.
            * 0 if there is camera support, but the format is unknown.
            */
            ioctls.maCameraFormatNumber = delegate()
            {
                // if the camera is not initialized, we cannot access any of its properties
                if (!isCameraInitialized)
                {
                    // because the cammera is supported but not initialized, we return 0
                    return 0;
                }

                IEnumerable<System.Windows.Size> res = mCamera.AvailableResolutions;
                if (res == null) return 0;
                IEnumerator<System.Windows.Size> resolutions = res.GetEnumerator();
                resolutions.MoveNext();
                int number = 0;
                while (resolutions.Current != null)
                {
                    number++;
                    resolutions.MoveNext();
                    if (resolutions.Current == new System.Windows.Size(0, 0))
                        break;
                }
                return number;
            };

            /**
             * Starts the viewfinder and the camera
             */
            ioctls.maCameraStart = delegate()
            {
                InitCamera();

                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    mCameraPrev.StartViewFinder();
                });

                return 0;
            };

            /**
             * stops the view finder and the camera.
             */
            ioctls.maCameraStop = delegate()
            {
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    mCameraPrev.StopViewFinder();
                });

                return 0;
//.........这里部分代码省略.........
开发者ID:milesm,项目名称:MoSync,代码行数:101,代码来源:MoSyncCameraModule.cs


注:本文中的PhotoCamera.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。