Example #1
0
        private void loadDepthMapButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title  = "Open depth map";
            ofd.Filter = "PNG Files|*.png" +
                         "|PFM Files|*.pfm" +
                         "|Bitmap Files|*.bmp" +
                         "|Gif Files|*.gif" +
                         "|JPEG Files|*.jpg" +
                         "|TIFF Files|*.tif" +
                         "|All Image types|*.png;*.pfm;*.bmp;*.gif;*.jpg;*.tif";

            ofd.FilterIndex = 7;
            ofd.FileName    = "";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (depthMap != null)
            {
                depthMap.Dispose();
            }
            if (ofd.FileName.EndsWith(".pfm"))
            {
                depthMap = PortableFloatMap.LoadImage(ofd.FileName);
            }
            else
            {
                Bitmap depthMapLdr = (Bitmap)Image.FromFile(ofd.FileName);
                depthMap = depthMapLdr.ToFloatMap();
                depthMapLdr.Dispose();
            }
        }
Example #2
0
 private void OpenLayerImage(string fileName)
 {
     if (fileName.EndsWith(".pfm"))
     {
         layerImage = PortableFloatMap.LoadImage(fileName);
     }
     else
     {
         Bitmap layerBitmap = (Bitmap)Bitmap.FromFile(fileName);
         layerImage = layerBitmap.ToFloatMap();
     }
     rayTracer.Scene.Layer.Image = layerImage;
 }
Example #3
0
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title  = "Open Image File";
            ofd.Filter = "PNG Files|*.png" +
                         "|PFM Files|*.pfm" +
                         "|Bitmap Files|*.bmp" +
                         "|Gif Files|*.gif" +
                         "|JPEG Files|*.jpg" +
                         "|TIFF Files|*.tif" +
                         "|All Image types|*.png;*.pfm;*.bmp;*.gif;*.jpg;*.tif";

            ofd.FilterIndex = 7;
            ofd.FileName    = "";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (ofd.FileName.EndsWith(".pfm"))
            {
                if (inputHdrImage != null)
                {
                    inputHdrImage.Dispose();
                }
                inputHdrImage = PortableFloatMap.LoadImage(ofd.FileName);
                ReplaceLdrImage(ref inputLdrImage, inputHdrImage.ToBitmap(ToneMappingEnabled));
            }
            else
            {
                ReplaceLdrImage(ref inputLdrImage, (Bitmap)Image.FromFile(ofd.FileName));
                if (inputHdrImage != null)
                {
                    inputHdrImage.Dispose();
                }
                inputHdrImage = inputLdrImage.ToFloatMap();
            }
            imageTypeComboBox.SelectedIndex = 0; // TODO: select original better
            updatePictureBoxImage();

            if (outputHdrImage != null)
            {
                outputHdrImage.Dispose();
            }
            outputHdrImage = null;
            ReplaceLdrImage(ref outputLdrImage, null);

            imageSizeLabel.Text = String.Format("{0}x{1}", inputHdrImage.Width, inputHdrImage.Height);
        }
Example #4
0
 private static FloatMapImage LoadFile(string filename)
 {
     if (filename.ToLower().EndsWith(".pfm"))
     {
         return(PortableFloatMap.LoadImage(filename));
     }
     else if (filename.ToLower().EndsWith(".png"))
     {
         return(((Bitmap)Bitmap.FromFile(filename)).ToFloatMap());
     }
     else if (filename.ToLower().EndsWith(".jpg"))
     {
         return(((Bitmap)Bitmap.FromFile(filename)).ToFloatMap());
     }
     throw new ArgumentException("Unknown file format: {0}", filename);
 }
Example #5
0
        private static void ReadAndWriteTestImage(string filename)
        {
            Console.WriteLine("Writing a test image.");
            FloatMapImage image = CreateTestImage();

            DisplayInfo(image);
            PrintImageContents(image);
            PortableFloatMap.SaveImage(image, filename);
            Console.WriteLine();

            Console.WriteLine("Reading a test image.");
            FloatMapImage loadedImage = PortableFloatMap.LoadImage(filename);

            DisplayInfo(loadedImage);
            PrintImageContents(loadedImage);
        }
Example #6
0
        private static void ReadAndWriteExistingImage(string filename)
        {
            Console.WriteLine("Reading an existing image.");
            FloatMapImage image = PortableFloatMap.LoadImage(filename);

            DisplayInfo(image);
            Console.WriteLine();

            Console.WriteLine("Writing a copy of an existing image.");
            string copyFilename = filename + ".out";

            PortableFloatMap.SaveImage(image, copyFilename);
            Console.WriteLine("Reading a copy of an existing image.");
            FloatMapImage loadedImage = PortableFloatMap.LoadImage(copyFilename);

            DisplayInfo(loadedImage);
        }