Graphics

 View Only
  • 1.  Cast xpImage in System.Drawing.Image

    Posted 05-17-2013 18:49
    Is it possible to cast a xpImage (for Preview in the Control App) to a .NET System.Drawing.Image?


  • 2.  RE: Cast xpImage in System.Drawing.Image

    Posted 05-17-2013 20:34
    You can convert it from an xpImage to a Bitmap object using the xpTools library. Just add the xpTools .NET library to your project references in Visual Studio.

    Here is a C# snippet:



    xpImage Image;

    Bitmap bmp;

    // assuming xpScene is already holding a valid Scene

    xpScene.GetRenderedFrame(0, 1920, 1080, out Image)

    bmp = xpTools.xpImageToBitmap(Image);



    Once you have a Bitmap you can assign it to the Image property of a PictureBox control to display on a form. (Or anything else you want to do with the Bitmap object)

    #XPression


  • 3.  RE: Cast xpImage in System.Drawing.Image

    Posted 05-18-2013 10:08
    Thanks... but the version 5.1 has only the function ImageToPicture or ImageToFile. The ImageToPicture function returns a stdole.IPicture. So you have to convert this in a System.Drawing.Image

    Dim xpTool As New xpToolsLib.xpTools

    imgPreview.Image = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureToImage(xpTool.ImageToPicture(_Engine.ResultPage.PreviewImage))



    The _Engine.ResultPage.PreviewImage returns a xpImage from project internal object.

    #XPression


  • 4.  RE: Cast xpImage in System.Drawing.Image

    Posted 05-18-2013 22:47
    I think you must be using the COM interface. If you use the .NET dll then you should have ImageToBitmap. How did you add the xpTools reference to your project?

    #XPression


  • 5.  RE: Cast xpImage in System.Drawing.Image

    Posted 05-24-2013 07:56
    the comman like "Dim xpTool As New xpToolsLib.xpTools

    imgPreview.Image = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureToImage(xpTool.ImageToPicture(_Engine.ResultPage.PreviewImage))

    The _Engine.ResultPage.PreviewImage returns a xpImage from project internal object."

    where are document guide for it.point me where to download.

    Thanks !

    #XPression