ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

ToImage

Create a new Image from a byte array

Source

public static Image ToImage(this byte[] bytes)
{
	if(bytes == null)
		throw new ArgumentNullException("bytes");

	return Image.FromStream(new MemoryStream(bytes));
}

Example

byte[] imageBytes = GetImageBytesFromDB();
Image myImage = imageBytes.ToImage();

Author: Lucas

Submitted on: 7 mrt 2008

Language: C#

Type: System.Array

Views: 5212