This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

RetangleRubberband

Dear Alex,

How to Resizing,Rotate,Zooming & moving the Rectangle inside the bitmap viewer,
PLZ provide me the code sample,



Thanx
Hello,

Could you describe the task more detailed? How the resize/zoom/move transfoms should be performed? According to which user input or application data? What do you mean by "rotate" rectangle?

In general - the answer is "RectangleRubberband.Rectangle" property. By changing it you can move/resize currently selected area arbitrary, depending on your specific task. E.g code
System.Drawing.Rectangle rect = rectRubberband.Rectangle;
rect.Inflate(50, 50);
rectRubberband.Rectangle = rect;
will increase the size of the selected area.
I have come into trouble dectecting if the inflate command will inflate the rubberband outside of the the image. How do I run a check for that make the rubberband stay inside the image alwasy maintaining its ratio?
Hello,

Value of the Rectangle property of the rubberband is measured in pixels of bitmap. After every change it is automatically fitted into bitmap area. To save aspect ratio of the selection you should calculate new size and check its intersection with image bounds manually and perform all corresponding rectangle size corrections and preserve aspect ratio by yourself. And after that assign the corrected value to the Rectangle property of the rubberband.