Unplanned
Last Updated: 13 Aug 2019 12:02 by ADMIN
Kerry
Created on: 24 Jun 2019 12:45
Category: ImageEditor
Type: Bug Report
0
RadImageEditor: OutOfMemory when drawing a rectangle over the image
Please run the attached sample project, click the button to start drawing and following the steps illustrated in the gif file.
6 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 13 Aug 2019 12:02
Hello, Nirav, 

I would like to note that this feedback item is with status Approved. Hence, a fix hasn't been introduced yet.

If you are experiencing any issues with RadImageEditor, could you please specify the exact steps how to reproduce the problem? If the error is not related to the case described in this feedback item, I would kindly ask you to submit a new ticket with detailed information about the precise case. It would be also greatly appreciated if you can provide a sample project demonstrating the issue in the specific thread. Thus, we would be able to make an adequate analysis of the precise case and assist you further.

Thank you in advance.

Regards,
Dess | Tech Support Engineer, Sr.
Progress TelerikRadImageEditor for Winforms
nirav
Posted on: 09 Aug 2019 20:34

I am getting OutOfMemory exception for even i am not customizing any thing and it crashing my application

Some time it give the error of 2-3 operation and sometime it give error after many operation did.

 

Thanks,

Nirav

Kerry
Posted on: 25 Jun 2019 15:25

Thank you Dess!!!!!

That works.

I laughed when I saw the last GIF. So many rectangles. Lol.

Thank you!!!

 

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 25 Jun 2019 04:58
Hello, Kerry,  
 
Thank you for the provided files. But it is not clear enough whether in the Designer file you use the custom RadImageEditor's implementation. That is why I have updated the sample project in a way to apply the workaround. The attached gif file illustrates the behavior on my end. 

Could you please give it a try and see how it works?

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress TelerikRadImageEditor for Winforms
Kerry
Posted on: 24 Jun 2019 17:32

Excuse my ignorance...

I added your code to the project and I still get the out of memory error. Attached is the updated RadForm1. It is not calling the override at all. Maybe because I am not calling DrawShape?

Thank you for your help!!!

The main thing is that you can duplicate it. If I need to wait for an update that is okay. I can tell people to just 2 to 3 things max for now.

 

 

Attached Files:
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 24 Jun 2019 12:54
Hello, Kerry,  

Thank you for reporting this issue. I confirm that this is a memory problem in the drawing logic of the shape in RadImageEditor.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to use the following custom RadImageEditor:

Public Class CustomImageEditor
    Inherits RadImageEditor
    Protected Overrides Function CreateImageEditorElement() As RadImageEditorElement
        Return New CustomImageEditorElement()
    End Function
End Class
 
Public Class CustomImageEditorElement
    Inherits RadImageEditorElement
    Public Overrides Sub DrawShape(shape As Drawing2D.GraphicsPath, fill As Color, stroke As Color, borderThickness As Integer)
        If Me.CurrentBitmap Is Nothing Then
            Me.OpenImage()
            Return
        End If
 
        Dim destRect As Rectangle = New Rectangle(0, 0, Me.OriginalBitmap.Width, Me.OriginalBitmap.Height)
        Dim destImage As Bitmap = New Bitmap(Me.OriginalBitmap.Width, Me.OriginalBitmap.Height)
        destImage.SetResolution(Me.OriginalBitmap.HorizontalResolution, Me.OriginalBitmap.VerticalResolution)
 
        Using graphics As Graphics = graphics.FromImage(destImage)
            graphics.CompositingMode = CompositingMode.SourceCopy
            graphics.CompositingQuality = CompositingQuality.HighQuality
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
            graphics.SmoothingMode = SmoothingMode.HighQuality
            graphics.PixelOffsetMode = PixelOffsetMode.HighQuality
            graphics.DrawImage(Me.OriginalBitmap, destRect, 0, 0, Me.OriginalBitmap.Width, Me.OriginalBitmap.Height, GraphicsUnit.Pixel)
 
            Using brush As SolidBrush = New SolidBrush(fill)
 
                Using pen As Pen = New Pen(stroke, borderThickness)
                    graphics.CompositingMode = CompositingMode.SourceOver
                    graphics.FillPath(brush, shape)
                    graphics.DrawPath(pen, shape)
                End Using
            End Using
        End Using
 
        Me.CurrentBitmap.Dispose()
        Me.CurrentBitmap = Nothing
        Me.CurrentBitmap = CType(destImage.Clone(), Bitmap)
        destImage.Dispose()
        Me.Invalidate()
    End Sub
End Class

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Dess | Tech Support Engineer, Sr.
Progress TelerikRadImageEditor for Winforms