How to convert Bitmap to Image

Nothing. I guess that D:\1.bmp is a monochrome image and I fear you have found a bug in the import code for monochrome bitmaps - sorry for that :frowning_face:

To fix this, please do the following:

  1. Make sure the latest build of the CVB.Net Wrappers is installed on your system (the file Stemmer.Cvb.dll in your %CVB%\Lib\Net folder should have version 1.30.0.x). If the file is older than that, please download the latest version from here: https://forum.commonvisionblox.com/t/introducing-experimental-cvb-net-cvb-and-cvbpy-api/205?u=illusive. (if you DLL version is newer than 1.30.0.x, then you don’t need to worry - you already have the patch installed…).
  2. Download this file here, unzip it and copy it to a folder on your machine: Stemmer.Cvb.Extensions.dll.zip (17.7 KB)
  3. Open a Visual Studio command prompt (any version >= 2010 will do) with admin privileges and go to the folder where you copied the downloaded DLL.
    image
  4. Execute the command
    gacutil -i Stemmer.Cvb.Extensions.dll
    The output should read Assembly successfully added to the cache

Now your code should finally work. Hint: In Visual Studio you won’t see much of a difference between the old DLL and the new DLL because Visual Studio only reports AssemblyVersions, and as the assembly interface did not change at all I have only increased the AssemblyFileVersion to 1.0.1.0.

One last thing: The line Stemmer.Cvb.Extensions.ImageExtensions.ToBitmap(img); will always yield a 32 bit Bitmap - when working with monochrome images this is probably not what you’d expect, so you might want to use one of the overloads that permits the specification of a target pixel format.