title: How to Save Image as 8 bit in C#?
body: <p>I load image using this code:</p>
  
  <pre><code>OpenFileDialog ofd = new OpenFileDialog();
  ofd.Title = "Select a Picture";
  ofd.InitialDirectory = @"PATH";
  if (ofd.ShowDialog() == DialogResult.OK)
  {
        HostImageLocationTxt.Text = ofd.FileName;
        hostImage.Image = new Bitmap(ofd.FileName);
  }
  </code></pre>
  
  <p>then , I load the image in another "PictureBox" and save the image without any modification using this code:</p>
  
  <pre><code>if (transformedImage.Image != null)
              {
                  Bitmap bmp = new Bitmap(transformedImage.Image);
                  SaveFileDialog sfd = new SaveFileDialog();
                  sfd.Title = "Select Save Location";
                  sfd.InitialDirectory = @"PATH";
                  sfd.AddExtension = true;
                  if (sfd.ShowDialog() == DialogResult.OK)
                  {
                      switch (Path.GetExtension(sfd.FileName).ToUpper())
                      {
                          case ".BMP":
                              bmp.Save(sfd.FileName, ImageFormat.Bmp);
                              break;
                          case ".gif":
                              bmp.Save(sfd.FileName, ImageFormat.Gif);
                              break;
                          case ".JPG":
                              bmp.Save(sfd.FileName, ImageFormat.Jpeg);
                              break;
                          case ".JPEG":
                              bmp.Save(sfd.FileName,ImageFormat.Jpeg);
                              break;
                          case ".PNG":
                              bmp.Save(sfd.FileName, ImageFormat.Png);
                              break;
                          case ".png":
                              bmp.Save(sfd.FileName, ImageFormat.Png);
                              break;
                          default:
                              break;
                      }
                  }
              } 
  </code></pre>
  
  <p>The saved image result in different bit depth (Left: First Load Image , Right: Saved Image):
  <a href="https://i.stack.imgur.com/5FPWJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5FPWJ.png" alt="Left: First Load Image , Right: Saved Image"></a></p>
  
  <p>How to save it using same format it was loaded in the first?. Thank you.</p>