0

I have the following image (have put a screen-grab of the image as its size is more than 2 MB - the original can be downloaded from https://drive.google.com/file/d/1rC2QQBzMhZ8AG5Lp5PyrpkOxwlyP9QaE/view?usp=sharing

enter image description here

When i create a Bitmap object from the image,its color scheme changes and becomes kind of faded.See the screenshot below

enter image description here

The following is the code used

  OpenFileDialog of = new OpenFileDialog();
  of.ShowDialog();
  pictureBox2.Image = new Bitmap(of.FileName);

I'm not sure if this is because of the color scheme of the camera used.Please advice.

techno
  • 6,100
  • 16
  • 86
  • 192
  • 1
    The two version show the same image, one with one without honoring the color profile. Iefanview looks the same as GDI, Photoshop the same as the browser. The Profile is called 'ProPhoto RGB' and when I tell pshop to not apply it it looks just like the gdi version. (Much more natural imo, btw). - To apply it in GDI see [the hints here](https://stackoverflow.com/questions/38295/apply-an-icc-color-profile-to-an-image-in-c-sharp-dotnet) – TaW Dec 02 '21 at 15:22
  • @TaW Thanks.The MSDN article in the answer you pointed to is broken.Is there any easy way to get the color scheme right when processing this image.How does PictureViewer display this image correctly ? Is this a rare or new color profile ? – techno Dec 02 '21 at 15:49
  • @TaW Found an interesting link https://learn.microsoft.com/en-us/dotnet/api/system.drawing.image.fromfile?redirectedfrom=MSDN&view=dotnet-plat-ext-6.0#System_Drawing_Image_FromFile_System_String_System_Boolean_ – techno Dec 02 '21 at 15:57
  • 1
    @TaW `useEmbeddedColorManagement=true` seems to solve the problem. – techno Dec 02 '21 at 15:58
  • Yup, that's the one. We still can't freely pick, but using what someone decided was right should be fine 99% of the time! – TaW Dec 02 '21 at 16:20
  • @TaW I'm currently using this piece of code https://stackoverflow.com/a/60112084/848968 to quickly generate thumbnail.This uses `System.Windows.Media.Imaging` , do you have any idea to make this code honor the color scheme . – techno Dec 02 '21 at 17:20
  • Well [there](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.bitmapcreateoptions?view=windowsdesktop-6.0) are options that look promising, no? - But the default seems to be to honor the colorprofle.. hm..? – TaW Dec 02 '21 at 18:53
  • @TaW Yes,but the default is not honoring it.When i try to set the color profile of the encoder manually,i get this error `The designated BitmapEncoder does not support ColorContexts.` It is the JPEG Encoder. – techno Dec 03 '21 at 04:17

0 Answers0