LEADTOOLS GDI/GDI+ (Leadtools.Drawing assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
ConvertFromImage Method
See Also 



image
The System.Drawing.Image from which to create the new Leadtools.RasterImage.
options
The conversion options.
image
The System.Drawing.Image from which to create the new Leadtools.RasterImage.
options
The conversion options.
Creates a new Leadtools.RasterImage from the specified existing GDI+ System.Drawing.Image object.

Syntax

Visual Basic (Declaration) 
Public Shared Function ConvertFromImage( _
   ByVal image As Image, _
   ByVal options As ConvertFromImageOptions _
) As RasterImage
Visual Basic (Usage)Copy Code
Dim image As Image
Dim options As ConvertFromImageOptions
Dim value As RasterImage
 
value = RasterImageConverter.ConvertFromImage(image, options)
C# 
public static RasterImage ConvertFromImage( 
   Image image,
   ConvertFromImageOptions options
)
C++/CLI 
public:
static RasterImage^ ConvertFromImage( 
   Image^ image,
   ConvertFromImageOptions options
) 

Parameters

image
The System.Drawing.Image from which to create the new Leadtools.RasterImage.
options
The conversion options.

Example

This example converts between a Leadtools.RasterImage and a GDI+ image.

Visual BasicCopy Code
Public Sub ConvertFromImageExample()
      Dim codecs As New RasterCodecs()

      Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ConvertFromImage.bmp")

      ' Create a GDI+ image
      Using btmp As Bitmap = New Bitmap(320, 200)
         Using g As Graphics = Graphics.FromImage(btmp)
            g.Clear(Color.Yellow)
            g.FillEllipse(Brushes.Red, New Rectangle(0, 0, btmp.Width, btmp.Height))

            ' Convert this image to RasterImage

            Using image As RasterImage = RasterImageConverter.ConvertFromImage(btmp, ConvertFromImageOptions.None)
               ' Save it
               codecs.Save(image, destFileName, RasterImageFormat.Bmp, 0)
            End Using
         End Using
      End Using

      ' Clean up
      codecs.Dispose()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void ConvertFromImageExample()
   {
      RasterCodecs codecs = new RasterCodecs();

      string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "ConvertFromImage.bmp");

      // Create a GDI+ image
      using(Bitmap btmp = new Bitmap(320, 200))
      {
         using(Graphics g = Graphics.FromImage(btmp))
         {
            g.Clear(Color.Yellow);
            g.FillEllipse(Brushes.Red, new Rectangle(0, 0, btmp.Width, btmp.Height));

            // Convert this image to RasterImage

            using(RasterImage image = RasterImageConverter.ConvertFromImage(btmp, ConvertFromImageOptions.None))
            {
               // Save it
               codecs.Save(image, destFileName, RasterImageFormat.Bmp, 0);
            }
         }
      }

      // Clean up
      codecs.Dispose();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

To convert a LEADTOOLS Leadtools.RasterImage to GDI+ image, use ConvertToImage.

For information about 16bpp grayscale images, refer to The RasterPaintEngine Property and 16bpp Grayscale Images.

For more information refer to RasterImage and GDI/GDI+.

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also