Example #1
0
        private bool ExportWallPNG(string folderPath, byte[] bitmapData, int width, int height, PixelFormat format)
        {
            bool isImgSaved = false;

            // create a bitmapsource object using byte[]
            BitmapSource bitmapSrc = KinectExtensions.ToBitmapSrc(bitmapData, width, height, PixelFormats.Bgr32);

            // create a png bitmap encoder which knows how to save a .png file
            BitmapEncoder encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(bitmapSrc));

            string filePath = System.IO.Path.Combine(folderPath, wallID + ".png");

            // write the new file to disk
            try
            {
                // FileStream is IDisposable
                using (FileStream fs = new FileStream(filePath, FileMode.Create))
                {
                    encoder.Save(fs);
                    isImgSaved = true;
                }
            }
            catch (IOException ex)
            {
                Debug.WriteLine("ERROR----Wall Image Export Exception: " + ex.ToString());
            }

            return(isImgSaved);
        }
Example #2
0
        //InfraredFrame Stream to Image
        public BitmapSource ToBitmapSrc(InfraredFrame frame)
        {
            int width  = frame.FrameDescription.Width;
            int height = frame.FrameDescription.Height;

            ushort[] frameData = new ushort[width * height];
            frame.CopyFrameDataToArray(frameData);

            return(KinectExtensions.ToBitmapSrc(frameData, width, height));
        }
Example #3
0
        //DepthFrame Stream to Image
        public BitmapSource ToBitmapSrc(DepthFrame frame, bool reliable)
        {
            int width  = frame.FrameDescription.Width;
            int height = frame.FrameDescription.Height;

            ushort[] depthData = new ushort[width * height];
            frame.CopyFrameDataToArray(depthData);

            return(KinectExtensions.ToBitmapSrc(depthData, width, height, reliable));
        }
Example #4
0
        //ColorFrame Stream to Image
        public BitmapSource ToBitmapSrc(ColorFrame frame)
        {
            int width  = frame.FrameDescription.Width;
            int height = frame.FrameDescription.Height;

            System.Windows.Media.PixelFormat pixelFormat = PixelFormats.Bgr32;

            byte[] pixels = new byte[width * height * ((pixelFormat.BitsPerPixel + 7) / 8)];

            if (frame.RawColorImageFormat == ColorImageFormat.Bgra)
            {
                frame.CopyRawFrameDataToArray(pixels);
            }
            else
            {
                frame.CopyConvertedFrameDataToArray(pixels, ColorImageFormat.Bgra);
            }
            return(KinectExtensions.ToBitmapSrc(pixels, width, height, pixelFormat));
        }