本文介绍了使用时间戳捕获-为什么ImageStream消失了?!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到我遗漏的东西.请帮助我

I can't find some i misstake or missing. Please help me

出现时间戳,相机图像消失.

Timestamp appear, Camera image disappear.

非常感谢,请....

Thankyou so much, Please....

        void camera_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
        {
            startVal++;
            string filename = startVal.ToString();

            {
                // Decode the JPEG stream.
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    // load photo to writable bitmap
                    WriteableBitmap writeableBitmap = PictureDecoder.DecodeJpeg(e.ImageStream);
                    var renderText = new TextBlock
                    {
                        Text = "TimeStamp - " + DateTime.Now.ToString(),
                        FontSize = 72,
                        Foreground = new SolidColorBrush(Colors.White),
                        FontWeight = FontWeights.Black,
                        Width = 500,
                        Height = 100
                    };

                    writeableBitmap.Render(renderText, new TranslateTransform() { X = 100, Y = 300 });
                    writeableBitmap.Invalidate();

                    using (var ms = new MemoryStream())
                    {
                        writeableBitmap.SaveJpeg(ms, 1024, 768, 0, 100);
                        ms.Seek(0, SeekOrigin.Begin);

                        mediaLibrary.SavePictureToCameraRoll(filename, ms);
                    }

                    e.ImageStream.Close();
                });

                Deployment.Current.Dispatcher.BeginInvoke(delegate(){textBoxStatus.Text = "Image saved to Library";});
            }
        }
/* Code below is work */
/*
        void camera_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
        {
            startVal++;
            string filename = startVal.ToString();

            mediaLibrary.SavePictureToCameraRoll(filename, e.ImageStream);

            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                textBoxStatus.Text = "Image saved to Library";
            });

        }
*/

推荐答案

                    WriteableBitmap writeableBitmap = PictureDecoder.DecodeJpeg(e.ImageStream);
                    writeableBitmap.Invalidate();
                    var renderText = new TextBlock



这篇关于使用时间戳捕获-为什么ImageStream消失了?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 12:36