System.Drawing.Image.FromFile Method

Creates an System.Drawing.Image from the specified file using embedded color management information in that file.

Syntax

public static Image FromFile (string filename, bool useEmbeddedColorManagement)

Parameters

filename
A string that contains the name of the file from which to create the System.Drawing.Image.
useEmbeddedColorManagement
Set to true to use color management information embedded in the image file; otherwise, false.

Returns

The System.Drawing.Image this method creates.

Remarks

Managed GDI+ has built-in encoders and decoders that support the following file types:

  • BMP

  • GIF

  • JPEG

  • PNG

  • TIFF

If the file does not have a valid image format or if ndptecgdiplus does not support the pixel format of the file, this method throws anĀ OutOfMemoryException exception.

The file remains locked until the System.Drawing.Image is disposed.

The useEmbeddedColorManagement parameter specifies whether the new System.Drawing.Image applies color correction according to color management information that is embedded in the image file. Embedded information can include International Color Consortium (ICC) profiles, gamma values, and chromaticity information.

Note:

The System.Drawing.Image class does not support alpha transparency in bitmaps. To enable alpha transparency, use PNG images with 32 bits per pixel.

Requirements

Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0