| 
            
              BitmapExtensionsConvertTo(Image, ImageFormat, Boolean) Method
             | 
          
        
        
             Converts a Bitmap image to the specified ImageFormat.
             
        
        Namespace: GSF.DrawingAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.257-beta+00aa2366fbb9ec75f636ebc7cfa610e3826a727c
Syntaxpublic static Bitmap ConvertTo(
	this Image originalImage,
	ImageFormat newFormat,
	bool disposeOriginal
)
<ExtensionAttribute>
Public Shared Function ConvertTo ( 
	originalImage As Image,
	newFormat As ImageFormat,
	disposeOriginal As Boolean
) As Bitmap
public:
[ExtensionAttribute]
static Bitmap^ ConvertTo(
	Image^ originalImage, 
	ImageFormat^ newFormat, 
	bool disposeOriginal
)
[<ExtensionAttribute>]
static member ConvertTo : 
        originalImage : Image * 
        newFormat : ImageFormat * 
        disposeOriginal : bool -> Bitmap GSF.Drawing.BitmapExtensions.ConvertTo = function(originalImage, newFormat, disposeOriginal);
 View SourceParameters
- originalImage  Image
 - The Bitmap image to be converted.
 - newFormat  ImageFormat
 - The new ImageFormat of the image.
 - disposeOriginal  Boolean
 - true if the original image is to be disposed after converting it; otherwise false.
 
Return Value
BitmapA 
Bitmap instance.
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).
Example
             This example shows how to convert the format of an image and dispose the original image that was converted:
             
using System;
using System.Drawing;
using System.Drawing.Imaging;
using GSF.Drawing;
class Program
{
    static void Main(string[] args)
    {
        
        using (Bitmap converted = ((Bitmap)Bitmap.FromFile("Original.jpg")).ConvertTo(ImageFormat.Gif))
        {
            
            converted.Save("OriginalGif.gif");
        }
        Console.ReadLine();
    }
}
See Also