# Driver reload required after image size got changed

**URL:** <https://forum.commonvisionblox.com/t/driver-reload-required-after-image-size-got-changed/74>\
**Category:** C-style API\
**Tags:** acquisition\
**Created:** [May 12, 2017, 12:18pm UTC](https://forum.commonvisionblox.com/t/driver-reload-required-after-image-size-got-changed/74 "2017-05-12T12:18:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LRidley](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@LRidley](https://forum.commonvisionblox.com/u/LRidley)\
**Post date:** [May 12, 2017, 12:18pm UTC](https://forum.commonvisionblox.com/t/driver-reload-required-after-image-size-got-changed/74/1 "2017-05-12T12:18:45Z")

</div>

Hi,

when i change the camera’s image format and size programmatically in my software, it seems like the driver doesn’t get updated to the new image size (or bit depth) by itself. Does this mean I always have to release and reload the driver again? Because this takes a while…

I was hoping that there is a better way, like a driver update function I can call?

---

<div class="post-metadata">

**Author:** ![Sebastian](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/sebastian/32/1267_2.png) [@Sebastian](https://forum.commonvisionblox.com/u/Sebastian)\
**Post date:** [May 12, 2017, 1:35pm UTC](https://forum.commonvisionblox.com/t/driver-reload-required-after-image-size-got-changed/74/2 "2017-05-12T13:35:33Z")

</div>

Yes, you can use the IImageRect Interface with its IRImageSize function.

A description can be found in the GenICam User Guide:  
[https://help.commonvisionblox.com/NextGen/14.0/md\_theory\_of\_operation\_hardware\_\_gen\_i\_cam\_\_c\_v\_b\_\_user\_guide.html#gcug\_chmtopic53](https://help.commonvisionblox.com/NextGen/14.0/md_theory_of_operation_hardware __gen_i_cam__ c_v_b__user_guide.html#gcug_chmtopic53)

But this is also related to other drivers.

C# function call:

```cs
int bResult = Cvb.Driver.IImageRect.IRImageSize
                (m_cvImage.Image,
                Cvb.Driver.IImageRect.TImageRectCMD.IMAGERECT_CMD_RESET,
                ref width,
                ref height,
                out imgNew);

```

---

<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 18, 2017, 2:22pm UTC](https://forum.commonvisionblox.com/t/driver-reload-required-after-image-size-got-changed/74/3 "2017-05-18T14:22:04Z")

</div>

One thing to be aware of with the above code sample is that it’s absolutely necessary to call `ReleaseObject` (_CVCImg.dll_) on the _input_ image to `IRImageSize` afterwards!

In @Sebastian’s code this is implicitly done because he is using an image from an image control - and the image control will take care of calling `ReleaseObject` on its handle sooner or later, but if you are working with blunt `IMG` handles this will not be the case. In such a scenario the code should be more like:

```cpp
// assuming: drvImage is a valid handle to a *.vin driver
cvbdim_t width = 0;
cvbdim_t height = 0;
IMG imgReset = nullptr;
auto res = IRImageSize(drvImage, IMAGERECT_CMD_RESET, width, height, imgReset);
if (SUCCEEDED(res))
{
  // it worked; in order for drvImage to live up to its name it should
  // now switch roles with the result image...
  ReleaseObject(drvImage);
  drvImage = imgReset;
  imgReset = nullptr; // just to prevent people from using this later on
}

```

This snippet also highlights one of the most illusive 😉 aspects of the `IRImageSize` function: The image `drvImage` enters it with the full set of driver interfaces, but once the job is done these driver interface will have passed over to the output image (`imgReset` in this case), turning the input image into a plain and simple bitmap.
