View Full Version : Show full image in reduced size control

February 4, 2014, 08:01:18
I've just realized that I'm not showing the entire image in my ICImagingControl windows form. My camera is working at 1280x960 but the control is only 640x480. I want the following:

1. to have the control at 640x480 in the application
2. to have the control display the entire 1280x960 image from the camera, scaled down to fit the control
3. to have images captured and saved to be the full 1280x960 resolution

Is this possible without a lot of image kung fu? I would prefer to avoid having to have a separate picturebox control that shows the scaled image, but if that's my only choice I will do that. In this case, the ICImagingControl will always be hidden as it will only show the top left 640x480 portion of the image, which isn't useful. The control cannot be bigger than 640x480.


Stefan Geissler
February 4, 2014, 08:30:00

Please have a look into the IC documentation (".NET Users Guide" on your computer) at

This is a good point to start.
ICImagingControl1.LiveDisplayDefault =false
ICImagingControl1.LiveDisplayHeight = ICImagingControl1.Height;
ICImagingControl1.LiveDisplayWidth = ICImagingControl1.Width;

and you are done.

February 4, 2014, 16:50:18
Thanks Stefan, that worked. But now I have a new problem in that my overlay lines are sometimes there and sometimes not. Apparently this is due to the scaling. Is there a way to make the lines thicker when calling ob.DrawLin so that they always show up?

Stefan Geissler
February 5, 2014, 09:33:10
Hello Carnaby,

you are right, due to scale, thin lines can be removed. Unfortunately the Overlaybitmap drawing functions do not export Pen settings, so you have to draw you lines twice using a pixel step joint, so you have two pixels wide lines.

May 14, 2014, 14:57:33
Following up on this, I don't think the suggested work-around to double paint lines is acceptable, at least it is not acceptable for my project.

I have tried to add a paint handler in which I could then directly draw my overlay into the ICImagingControl's Graphic, but that didn't work. I could not paint anything over the picture, only next to it in the unused client area.

I have also tried to use an overlay update event handler, but although this handler is called, it doesn't allow me to paint either.

Currently I'm using LifeCaptureContinuous = true and LiveDisplay = false. Upon ImageAvailable I call DisplayBuffer on the current buffer. How does DisplayBuffer() work, and how does it interact with .NET's Paint event infrastructure?


Stefan Geissler
May 14, 2014, 15:29:00
You can draw the image in the size you need into a bitmap, using the Bitmap property of the image buffer. Then you can the System.Drawing.Graphics functions to draw your graphics on this bitmap and show it later in a picture box.

Bitmap _DrawImage;
private void Form1_Load(object sender, EventArgs e)

_DrawImage = new Bitmap(pictureBox1.Width, pictureBox1.Height);

private void icImagingControl1_ImageAvailable(object sender, TIS.Imaging.ICImagingControl.ImageAvailableEventAr gs e)
Graphics gr = Graphics.FromImage(_DrawImage);
gr.DrawImage(icImagingControl1.ImageActiveBuffer.B itmap, 0, 0);

// Do some more drawings here


pictureBox1.Image = _DrawImage;

Please consult the MSDN for finding the necessary parameters of DrawImage(), so you image will be drawn as wanted.

May 14, 2014, 16:34:31
Thanks for the quick response. Will that also work with the IcImagingControl in a WinFormsHost control using WPF?

Stefan Geissler
May 14, 2014, 16:51:54

Will that also work with the IcImagingControl in a WinFormsHost control using WPF?
Never tested this, you may try on your own.

May 14, 2014, 18:55:42
Ok, I'll give it a try tomorrow. However, I have one question regarding your suggestion. The line:

pictureBox1.Image = _DrawImage;
assigns the modified image to a picture box - but this picture box is obviously not the icimagingcontrol where I got the image from. But I need to paint into that control, otherwise it would remain empty wouldn't it? Are you suggestion to keep the icimagingcontrol sort of present in the form, but hidden?

Stefan Geissler
May 15, 2014, 11:13:52
You only show the images in the picture box, because this is the the only way to show thin lines on resized images.

The OverlayBitmap of IC is allways in the same size as the video format. If you have a 2592x1944 resolution, draw a single line and resize the image to 320x240, then the line will vanish. Therefore, if the line should be visible in any case, you must resize the image first, and then draw the line. Therefore an extra Bitmap, where to draw the video resized and then do your lines and other graphics.

May 15, 2014, 13:37:38
Thanks for your support Stefan. To wrap this up, here is what I do now and it seems to work quite nicely:

icImagingControl.LiveCaptureContinuous = false;
icImagingControl.LiveDisplay = false;
icImagingControl.ImageRingBufferSize = 1;
timer = new Timer(Callback, null, 0, DisplayUpdateTimeMs);
In the Callback I then do

save icImagingControl.ImageActiveBuffer.Bitmap if needed
scale & paint icImagingControl.ImageActiveBuffer.Bitmap to temp bitmap
paint overlay information in temp bitmap
paint temp bitmap to icImagingControl's client area
The temp bitmap and it's graphics object are precalculated and updated upon window resize events (using locked access).