# Display images with \> 8 Bits

**URL:** <https://forum.commonvisionblox.com/t/display-images-with-8-bits/29>\
**Category:** C-style API\
**Tags:** display, high-bit\
**Created:** [May 8, 2017, 1:12pm UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29 "2017-05-08T13:12:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [May 8, 2017, 2:25pm UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29/2 "2017-05-08T14:25:59Z")

</div>

Hi @taserface!

Depending on what you consider a proper display for image data with more than 8 bits per pixel the answer is definitely yes! 😉

First: The slightly garbled display that you are seeing is only the _default_ way of Common Vision Blox to display images with more than 8 bits per pixels. What happens is this: Usually a device context in Windows is not capable of displaying more than 8 bits per pixel. When confronted with image data with more than 8 bits per pixels, the Common Vision Blox display therefore simply copies the lowest 8 bits of the pixels to be displayed to the device context. If, for example, your data has 10 bits per pixel (pixel values: [0…1023]), you will have 3 pixel values at which a wraparound occurs when incrementing by one: 255, 511 and 767. These give rise to the striking white-to-black transitions in the display. You can easily verify that the actual pixel data has no discontinuity by moving the mouse pointer through one of these transitions and having a look at the display’s status line (if the display is configured to show the grey values).

However, this is just the default way of Common Vision Blox to display high-bit images - there are different options available (and the default approach is simply the one that happened to be there first). If you want a visually more attractive display of high-bit images you have two options:

1. **Change the high bit scale mode from its default (`HBSM_WrapAround`) to something else.**  
The high bit scale mode may be changed by setting the display control’s `HighBitScaleMode` property or by selecting a different mode on the control’s property page (on the tab _Status Line Styles_):  
 ![](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/e24acf84da6931dfc781156d253e01d6accaa0f7.png)  
In addition to the default of `HBSM_WrapAround` there are (currently) two other options:

- **`HBSM_Global`**  
In this mode, the entire image’s grey scale range will be mapped to the range [0…255] for display. This mode will probably yield what you’d expect, but it’ll not show you the finer details that might be present in a high-bit image.  
 ![](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/af0a107c3958d73f11465914ab58515b019d8f94.jpg)
- **`HBSM_ViewPort`**  
This mode maps only the currently visible pixels (the view port) to the range [0…255], making also the finer details in a high-bit image visible. This mode is nice for closely inspecting an image but it may also be confusing because the displayed brightness of a pixel (x, y) is likely to change depending on the zoom state.  
 ![](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/48b1159e24a39ae78bf694a56bd4a9f1be0fa145.png)

1. Alternatively you may use the function `MapTo8Bits` from the _CVCImg.dll_ to convert a high-bit image to an 8 bit image. This is not exactly the same as using `HBSM_Global` because `HBSM_Global` always maps the theoretical grey value range (as determined from the data type identifier) to [0…255], whereas `MapTo8Bits` converts the range of values encountered in the image to [0…255].  
The main difference between `MapTo8Bits` and changing the `HighBitScaleMode` is of course that the latter only acts on the display whereas the first will generate a new image with modified image data (which you can then subsequently assign to a Common Vision Blox display… this post might come in handy in that scenario: [Setting the image property on the display control resets the zoom state](http://forum.commonvisionblox.com/t/setting-the-image-property-on-the-display-control-resets-the-zoom-state/27/4?u=illusive)) - making this the approach of choice when the processed image should not only be used for display, but also for processing in a different tool.  
By the way: The _CVFoundation.dll_ has a function called `DownShift` that can be used to achieve the same results that `HBSM_Global` (simply shift down by enough bits to make sure that the value range does not exceep [0…255] any more) and is typically a lot faster than `MapTo8Bits`.

❗ Please keep in mind that the `HighBitScaleMode` value has no influence on the display’s appearance if the display is using DirectDraw or Direct3D (property `DirectDrawEnabled` set to `true`).

---

_[View the full topic](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29)._
