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

How can I get the rectangle information from Vobjects in Multilayerviewer

Sorry for the multipost... but can any one help me with this?

I am trying to get the union rectangle from Vobjects in multilayer viewer. I wrote these code but it just does not solve the problem...

        Dim pRect As New RectangleF
        For Each pObj As Aurigma.GraphicsMill.WinControls.ImageVObject In Me.Canvas.CurrentLayer.VObjects

            If pRect.Width = 0 Then
                pRect = pObj.GetControlPointsBounds
            Else
                pRect = System.Drawing.RectangleF.Union(pRect, pObj.GetControlPointsBounds)
            End If
        Next


Me.Canvas is Multilayerviewer and would like to get the rectangle so I can crop the image without extra transparent area.

GetVObjectsBound did not work either...

Is there something that I am missing?

Please help
Hello Ichiro,

Here is small code snippet which you can use as start point for your implementation. Please note that all vector objects are measured in points.
        Dim a, b As Aurigma.GraphicsMill.WinControls.VObject

        a = New Aurigma.GraphicsMill.WinControls.EllipseVObject(20, 30, 100, 200)
        b = New Aurigma.GraphicsMill.WinControls.EllipseVObject(120, 80, 60, 50)
        _multiLayerViewer.CurrentLayer.VObjects.Add(a)
        _multiLayerViewer.CurrentLayer.VObjects.Add(b)

        Dim aBounds, bBounds, boundingRect As System.Drawing.RectangleF
        aBounds = a.GetTransformedVObjectBounds()
        bBounds = b.GetTransformedVObjectBounds()
        boundingRect = System.Drawing.RectangleF.Union(aBounds, bBounds)

        Dim image As Aurigma.GraphicsMill.Bitmap = _multiLayerViewer.RenderWorkspace(96)

        boundingRect.X = Aurigma.GraphicsMill.UnitConverter.ConvertUnitsToPixels(image.HorizontalResolution, _
            boundingRect.X, Aurigma.GraphicsMill.Unit.Point)
        boundingRect.Y = Aurigma.GraphicsMill.UnitConverter.ConvertUnitsToPixels(image.VerticalResolution, _
            boundingRect.Y, Aurigma.GraphicsMill.Unit.Point)
        boundingRect.Width = Aurigma.GraphicsMill.UnitConverter.ConvertUnitsToPixels(image.HorizontalResolution, _
            boundingRect.Width, Aurigma.GraphicsMill.Unit.Point)
        boundingRect.Height = Aurigma.GraphicsMill.UnitConverter.ConvertUnitsToPixels(image.VerticalResolution, _
            boundingRect.Height, Aurigma.GraphicsMill.Unit.Point)

        image.Transforms.Crop(boundingRect)
        image.Save("c:/image.jpg")
Please, feel free to contact us if you have any questions.
Thank you very much, Alex.
I really do appreciate your reply.

Here is further question...

Is there any way to avoid 1 pixel transparent edge for cropping?
or detect no-transparent area as rectangle??

Here is whats happening...

The vobjects in the multilayer measured in point, converting it to the pixel measurement, there would be a difference between the exact position (in pixel) in the image and the position in point, which finally causes the wrong cropping of the image.

When you move, resize, rotate vobjects, the difference varies.
Is assume this is based on the resolution difference between 72 dpi and 96 dpi.
The smaller size you resize in the screen to, the difference is much bigger...

Please give me some idea to avoid this wrong cropping...

I am programming PNG/GIF graphic tool for web developer and they are critical on 1 pixel difference...

I finally got around. It was unnecessary function to provide "real-time" image shrinking.

Thanks a lot any way.