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

Notification

Icon
Error

Options
Go to last post Go to first unread
quacka  
#1 Posted : Thursday, August 03, 2006 12:06:02 AM(UTC)
quacka

Rank: Member

Groups: Member
Joined: 1/17/2005(UTC)
Posts: 32

I have two bitmapviewer, one with the Rectanglerubberband control on it and another is to display the area highlighted by the Rectanglerubberband control. My problem is I don't know the right way to display the selected area. I am using the following code but I assume it will be slow as I need to reload the original image from file each time, then crop the image according to the Rectanglerubberband.
Code:

            bmvEdit.Bitmap.Load(ImageName)
            bmvOriginal.Bitmap.Load(ImageName)
            RectangleRubberband1.Connect(bmvOriginal)


    Private Sub RectangleRubberband1_RectangleChanged(ByVal sender As Object, ByVal e As Aurigma.GraphicsMill.WinControls.RectangleEventArgs) Handles RectangleRubberband1.RectangleChanged
        RectangleRubberband1.ResizeMode = WinControls.ResizeMode.Proportional
        If Not RectangleRubberband1.Rectangle = Nothing Then
            bmvEdit.Bitmap.Load(ImageName)
            Dim Transform As BitmapTransform
            Transform = New Crop(RectangleRubberband1.Rectangle)
            Transform.ApplyTransform(bmvEdit.Bitmap)
        End If
   End Sub
There has to be a more resource friendly way to do this.

Edited by user Wednesday, December 19, 2007 3:18:43 PM(UTC)  | Reason: Not specified

Alex Kon  
#2 Posted : Thursday, August 03, 2006 1:22:03 PM(UTC)
Alex Kon

Rank: Advanced Member

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

Was thanked: 5 time(s) in 5 post(s)
Hello, Yes, there is more resource-friendly way. You have no need to reload the original image from file every time (loading from file is a time-consuming operation). It will be faster to use already loaded bitmap from the first BitmapViewer control. Here is small code snippet which illustrates the way:
Code:
    bmvOriginal.Bitmap.Load("Y:\MultiLayerViewer\lexus.jpg")
    bmvEdit.Bitmap = CType(bmvOriginal.Bitmap.Clone(), Aurigma.GraphicsMill.Bitmap)
    
    Private Sub RectangleRubberband1_RectangleChanged(ByVal sender As Object, ByVal e As Aurigma.GraphicsMill.WinControls.RectangleEventArgs) Handles RectangleRubberband1.RectangleChanged
        RectangleRubberband1.ResizeMode = WinControls.ResizeMode.Proportional
        If Not RectangleRubberband1.Rectangle.IsEmpty Then
            Dim cropTransform As Aurigma.GraphicsMill.Transforms.Crop
            cropTransform = New Aurigma.GraphicsMill.Transforms.Crop(RectangleRubberband1.Rectangle)
            cropTransform.ApplyTransform(bmvOriginal.Bitmap, bmvEdit.Bitmap)
        End If
    End Sub

Edited by user Wednesday, December 19, 2007 3:18:54 PM(UTC)  | Reason: Not specified

quacka  
#3 Posted : Thursday, August 03, 2006 4:20:35 PM(UTC)
quacka

Rank: Member

Groups: Member
Joined: 1/17/2005(UTC)
Posts: 32

Thanks for that :)
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.