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

How to display the Selected RectangleRubberBand area from one bitmapviewer on another bitmapviewer e

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.


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