Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Ichiro  
#1 Posted : Tuesday, February 27, 2007 4:46:09 PM(UTC)
Ichiro

Rank: Member

Groups: Member
Joined: 2/26/2007(UTC)
Posts: 8

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...
Code:
        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

Edited by user Tuesday, December 18, 2007 4:50:29 PM(UTC)  | Reason: Not specified

Ichiro Komoda
Alex Kon  
#2 Posted : Tuesday, February 27, 2007 9:49:15 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
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.
Code:
        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.

Edited by user Tuesday, December 18, 2007 4:51:38 PM(UTC)  | Reason: Not specified

Ichiro  
#3 Posted : Wednesday, February 28, 2007 1:05:17 AM(UTC)
Ichiro

Rank: Member

Groups: Member
Joined: 2/26/2007(UTC)
Posts: 8

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...
Ichiro Komoda
Ichiro  
#4 Posted : Thursday, March 01, 2007 1:31:43 AM(UTC)
Ichiro

Rank: Member

Groups: Member
Joined: 2/26/2007(UTC)
Posts: 8

I finally got around. It was unnecessary function to provide "real-time" image shrinking. Thanks a lot any way.
Ichiro Komoda
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.