|
Group: Forum Members
Posts: 12,
Visits: 1
|
The ideea is this: - create a default document/view with predefined size, let say 300/200; - load an architectural floor plan for background, this is an image with let say 3600/1500 pixels; - update the size of the document with document.Bounds = new RectangleF(0, 0, imageWidth, imageHeight); - create a shape with the width and height of the background image to hold the background image (first layer will be the background, i need it to be able to hide and show the background image); - update the zoom with view.fit() and document.RefreshAllViews(); - create a calibration rectangle (i use this to measure some known distances on image and make width and height of the rectangle to actually correspond to real values); - calibrate the rectangle after some know values in image; - calculate the scaleFactor between calibration rectangle width or height and real width or height value; - calculate the new width and height like this: float newWidth = document.Width / scaleFactor; - resize the background image shape to backgroundRect.SetBounds(new NRectangleF(0, 0, newWidth, newHeight)); - resize the document with document.Bounds = new NRectangleF(0, 0, newWidth, newHeight); - view.Fit() & document.RefreshAllViews();
Now the document is (in my case with the background image i use) at roughly 400% zoom factor after fit. Any new shape i add now will have increased borders.
|