コード例 #1
0
        /// <summary>
        /// Combines two equirectangular images into a single stereo image, either left/right or top/bottom.
        /// </summary>
        public static Bitmap ComposeEyes(Bitmap left, Bitmap right, EyeImageGeometry geometry = EyeImageGeometry.OverUnder)
        {
            if (left == null || right == null || left.Size != right.Size || left.PixelFormat != right.PixelFormat)
            {
                return(null);
            }

            Size  imgSize       = geometry == EyeImageGeometry.LeftRight ? new Size(left.Width * 2, left.Height) : new Size(left.Width, left.Height * 2);
            Point rightLocation = geometry == EyeImageGeometry.LeftRight ? new Point(left.Width, 0) : new Point(0, left.Height);

            Bitmap result = new Bitmap(imgSize.Width, imgSize.Height, left.PixelFormat);

            using (Graphics g = Graphics.FromImage(result))
            {
                g.DrawImageUnscaled(left, Point.Empty);
                g.DrawImageUnscaled(right, rightLocation);
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Allow to create SBS Images
        /// This function was added by Andreas Pollak to the orignal library.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="geometry"></param>
        /// <param name="fillPoles"></param>
        /// <param name="maxWidth"></param>
        /// <returns></returns>
        public static Bitmap CreateStereo(string filename, EyeImageGeometry geometry = EyeImageGeometry.OverUnder, bool fillPoles = true, int maxWidth = 0)
        {
            var       xmpDirectories = VrJpegMetadataReader.ReadMetadata(filename);
            GPanorama pano           = new GPanorama(xmpDirectories.ToList());

            Bitmap left  = new Bitmap(filename);
            Bitmap right = ExtractRightEye(pano);

            if (right == null)
            {
                left.Dispose();
                return(null);
            }

            Bitmap composite = ComposeEyes(left, right, geometry);

            left.Dispose();
            right.Dispose();

            return(composite);
        }