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

Notification

Icon
Error

Options
Go to last post Go to first unread
ChingYen  
#1 Posted : Wednesday, June 25, 2008 11:40:56 AM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Hi,

In the previous post http://forums.aurigma.co...w-Frame-for-VObject.aspx

we were asking about adding frame onto ImageVObject.

Actually we plan to go with the 3rd method - Create custom imagevobject that will draw the Rectangle...

But, after several try, we couldn't get it done...

Just wondering can we have a sample for it? Thanks.

Tamila  
#2 Posted : Thursday, June 26, 2008 9:10:17 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Ching Yen,

Unfortunately ImageVObject does not support borders. But you can inherit your oun class, which supports borders.

This is code sample of ImageWithBorder, which allow to draw picture with a border:

Code:

Imports Aurigma.GraphicsMill.WinControls

Public Class ImageWithBorder
    Inherits ImageVObject

    Dim _bgFrame As RectangleVObject

    Public Sub New(ByVal bitmap As Aurigma.GraphicsMill.Bitmap, ByVal scaleToActualSize As Boolean, ByVal x As Single, ByVal y As Single)
        MyBase.New(bitmap, scaleToActualSize, x, y)

        _bgFrame = New RectangleVObject(0, 0, 1, 1)
        _bgFrame.Pen = New System.Drawing.Pen(Color.BurlyWood, 10)
        _bgFrame.Pen.Alignment = Drawing2D.PenAlignment.Inset
        _bgFrame.Brush = Nothing
    End Sub
Public Overrides Sub Draw(ByVal renderingRect As System.Drawing.Rectangle, ByVal g As System.Drawing.Graphics, ByVal coordinateMapper As ICoordinateMapper)
        Dim rectBounds As System.Drawing.RectangleF = _bgFrame.GetVObjectBounds()
        Dim objBounds As System.Drawing.RectangleF = Me.GetVObjectBounds()

        If Not rectBounds.Equals(objBounds) Then
            Dim interim As System.Drawing.Pen = _bgFrame.Pen
            _bgFrame = New RectangleVObject(objBounds)
            _bgFrame.Transform = Me.Transform
            _bgFrame.Pen = interim
            _bgFrame.Brush = Nothing
        End If

        MyBase.Draw(renderingRect, g, coordinateMapper)

        _bgFrame.Transform = Me.Transform
        _bgFrame.Draw(renderingRect, g, coordinateMapper)
    End Sub

    Public Property BackgroundPen() As System.Drawing.Pen
        Get
            Return _bgFrame.Pen
        End Get
        Set(ByVal Value As System.Drawing.Pen)
            _bgFrame.Pen = Value
        End Set
    End Property
End Class

Now you can change borger of image.

This sample demonstrates how to use ImageWithBorder class:

Code:

        Dim bt As New Aurigma.GraphicsMill.Bitmap("image.jpg")
        Dim newImage As New ImageWithFrame(bt, False, 0, 0)
        Me._multiLayerViewer.CurrentLayer.VObjects.Add(newImage)

Edited by user Thursday, June 26, 2008 9:11:04 PM(UTC)  | Reason: Not specified

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!

ChingYen  
#3 Posted : Saturday, June 28, 2008 4:32:14 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Hi,

Thanks for the great code !!

But, here comes the problem and perhaps you could give some hints on how to solve it...

Please check on the attachment

ChingYen attached the following image(s):
FrameIssue.jpg
Tamila  
#4 Posted : Monday, June 30, 2008 6:42:17 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi,

To solve this problem you should override two methods GetVObjectBounds() and GetTransformedVObjectBounds() in ImageWithBorder class.

For example:

Code:

    Public Sub UpdateFrame()
        Dim rectBounds As System.Drawing.RectangleF = _bgFrame.GetVObjectBounds()
        Dim objBounds As System.Drawing.RectangleF = MyBase.GetVObjectBounds()

        If Not rectBounds.Equals(objBounds) Then
            Dim interim As System.Drawing.Pen = _bgFrame.Pen
            _bgFrame = New RectangleVObject(objBounds)
            _bgFrame.Transform = Me.Transform
            _bgFrame.Pen = interim
            _bgFrame.Brush = Nothing
        End If
    End Sub

    Public Overrides Sub Draw(ByVal renderingRect As System.Drawing.Rectangle, ByVal g As System.Drawing.Graphics, ByVal coordinateMapper As ICoordinateMapper)
        MyBase.Draw(renderingRect, g, coordinateMapper)

        UpdateFrame()
        _bgFrame.Transform = Me.Transform
        _bgFrame.Draw(renderingRect, g, coordinateMapper)
    End Sub

    Public Overrides Function GetVObjectBounds() As System.Drawing.RectangleF
        UpdateFrame()
        Return System.Drawing.RectangleF.Union(MyBase.GetVObjectBounds(), _bgFrame.GetVObjectBounds)
    End Function

    Public Overrides Function GetTransformedVObjectBounds() As System.Drawing.RectangleF
        UpdateFrame()
        Return System.Drawing.RectangleF.Union(MyBase.GetTransformedVObjectBounds(), _bgFrame.GetVObjectBounds)
    End Function

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!

Users browsing this topic
Guest
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.