代码之家  ›  专栏  ›  技术社区  ›  Jamey McElveen

如何在Windows Phone 7中以编程方式设置锁屏图像?

  •  1
  • Jamey McElveen  · 技术社区  · 16 年前

    如何在Windows Phone 7中以编程方式设置锁屏图像?如果这是不可能的,我如何添加一个图像到相机辊编程?

    2 回复  |  直到 16 年前
        1
  •  5
  •   Noah Witherspoon    16 年前

    不要认为你可以直接这样做,但你可以保存图像到用户的图片 用户可以选择将图像用于其锁屏图像的库:

    Photos, Photos, Photos - How To Save, Load And Iterate Pictures With Windows Phone 7

    // Saves the WriteableBitmap encoded as JPEG to the Media library.
    // The quality for JPEG encoding has to be in the range 0-100,
    // where 100 is the best quality with the largest size.
    void SaveToMediaLibrary(this WriteableBitmap bitmap, string name, int quality);
    
    // Saves the WriteableBitmap encoded as JPEG to the Media library
    // using the best quality of 100.
    void SaveToMediaLibrary(this WriteableBitmap bitmap, string name);
    
        2
  •  0
  •   mattStroshane    15 年前

    我不知道你是否可以通过编程设置锁屏图像。但在WindowsPhoneOS7.1(“Mango”)中,您可以使用 照相照相机 类以编程方式访问相机并将捕获的图像保存到 SavePictureToCameraRoll保存图片 方法。完整的详细信息见以下主题:

    How to: Create a Base Camera Application for Windows Phone

    这段代码显示初始化摄像头、连接事件处理程序以及将摄像头提要应用到名为的页面上的矩形对象 :

        //Code for initialization, image availability events anbd setting the source for the viewfinder
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
    
            // Initialize camera
            cam = new Microsoft.Devices.PhotoCamera();
    
            // Event is fired when the capture sequence is complete and an image is available.
            cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable);
    
            //Set the VideoBrush source to the camera.
            viewfinderBrush.SetSource(cam);
        }
    

    photoCamera类在执行捕获时提供两个图像:完整图像和缩略图。您可以通过两种方式访问图像-使用名为ContentReadyEventArgs的参数 . 如果你处理好 CaptureImageAvailable可用 Captumbnail可用

        // Informs when full resolution picture has been taken, saves to local media library        void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
        {
    
            try
            {
               // Save picture to the device media library.
                library.SavePictureToCameraRoll(fileName, e.ImageStream);
            }
            finally
            {
                // Close image stream
                e.ImageStream.Close();
            }
    

    希望有帮助。干杯

    推荐文章