Converts the specified image to a byte array using the specified format.

Namespace: System.Extensions.Drawing
Assembly: System.Extensions (in System.Extensions.dll) Version: 0.0.0.5 (0.0.0.5)

Syntax

C#
public static byte[] ToByteArray(
	this Image image,
	ImageFormat format
)
Visual Basic
<ExtensionAttribute> 
Public Shared Function ToByteArray ( 
	image As Image,
	format As ImageFormat
) As Byte()
Visual C++
public:
[ExtensionAttribute]
static array<unsigned char>^ ToByteArray(
	Image^ image, 
	ImageFormat^ format
)
F#
static member ToByteArray : 
        image : Image * 
        format : ImageFormat -> byte[] 

Parameters

image
Type: System.Drawing..::..Image
The Image to convert.
format
Type: System.Drawing.Imaging..::..ImageFormat
The ImageFormat to use when serializing.

Return Value

Type: array<Byte>[]()[][]
The byte array representation of the image.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Image. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also