# How to convert Bitmap to Image

**URL:** <https://forum.commonvisionblox.com/t/how-to-convert-bitmap-to-image/608>\
**Category:** .Net API\
**Created:** [December 7, 2018, 10:46am UTC](https://forum.commonvisionblox.com/t/how-to-convert-bitmap-to-image/608 "2018-12-07T10:46:39Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [December 7, 2018, 1:51pm UTC](https://forum.commonvisionblox.com/t/how-to-convert-bitmap-to-image/608/5 "2018-12-07T13:51:32Z")

</div>

> [@roychou](#):
>
> what’s the problem with the code?

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 ☹

To fix this, please do the following:

1. Make sure the latest build of the [CVB.Net](http://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](https://forum.commonvisionblox.com/t/introducing-experimental-cvb-net-cvb-and-cvbpy-api/205). (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](https://forum.commonvisionblox.com/uploads/commonvisionblox/original/1X/61d11b43100498ed2e1dbfe74d341a2e642ee909.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](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/2e892b2f340375f615be9fdda7a08624579ea1ae.png)
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 `AssemblyVersion`s, 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.

---

_[View the full topic](https://forum.commonvisionblox.com/t/how-to-convert-bitmap-to-image/608)._
