Stream GetPngStream(WriteableBitmap bmp)
        {
            // Use Joe Stegman's PNG Encoder
            // http://bit.ly/77mDsv
            EditableImage imageData = new EditableImage(bmp.PixelWidth, bmp.PixelHeight);

            for (int y = 0; y < bmp.PixelHeight; ++y)
            {
                for (int x = 0; x < bmp.PixelWidth; ++x)
                {

                    int pixel = bmp.Pixels[bmp.PixelWidth * y + x];

                    imageData.SetPixel(x, y,
                                (byte)((pixel >> 16) & 0xFF),
                                (byte)((pixel >> 8) & 0xFF),
                                (byte)(pixel & 0xFF),
                                (byte)((pixel >> 24) & 0xFF)
                                );

                }
            }

            return imageData.GetStream();
        }
        Stream GetPngStream(WriteableBitmap bmp)
        {
            // Use Joe Stegman's PNG Encoder
            // http://bit.ly/77mDsv
            EditableImage imageData = new EditableImage(bmp.PixelWidth, bmp.PixelHeight);

            for (int y = 0; y < bmp.PixelHeight; ++y)
            {
                for (int x = 0; x < bmp.PixelWidth; ++x)
                {
                    int pixel = bmp.Pixels[bmp.PixelWidth * y + x];

                    imageData.SetPixel(x, y,
                                       (byte)((pixel >> 16) & 0xFF),
                                       (byte)((pixel >> 8) & 0xFF),
                                       (byte)(pixel & 0xFF),
                                       (byte)((pixel >> 24) & 0xFF)
                                       );
                }
            }

            return(imageData.GetStream());
        }