AxCVDISPLAYLib.AxCVdisplay.Image

How can I set the AxCVDISPLAYLib.AxCVdisplay.Image value with an image of .bmp or .jpg format. I receive the image from the web and have to process it.

Hi @Farid,

I assume you are using C# with the Display ActiveX control. In this post I propose a solution with Stemmer.Cvb.dll and Stemmer.Cvb.Extensions.dll shipped with :cvb: 13.02.000.

Let’s assume we have a download function to download :cvb: Images like this:

using System.Net;
using Stemmer.Cvb;
using Stemmer.Cvb.Extensions;

//...

public static Image DownloadImage(Uri imageUrl) 
{
  using (var bitmap = DownloadBitmap(imageUrl)) 
  {
    return bitmap.ToImage();
  } 
} 

private static System.Drawing.Bitmap DownloadBitmap(Uri imageUrl) 
{
  using (var client = new WebClient()) 
  {
    using (var stream = client.OpenRead(imageUrl))
    {
      return new System.Drawing.Bitmap(stream);
    } 
  } 
} 

Then you can assign the Image's .Handle to your display ActiveX like this:

myDisplay.Image = downloadedImage.Handle;

Don’t forget to .Dispose() the downloaded image when you don’t access it anymore. The display ActiveX control shares the native image…

Of course it is easier to use the display from Stemmer.Cvb.Forms.dll. Then you have .Net life time over all objects.

4 Likes

Thank you for your reply, parsd.

I have to stick to cvb version 13.01.006 for the time being. Is there a way to do this using this version.

You can install the Cvb.Net for this version from here: