You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 23, 2020. It is now read-only.
Hi,
I have been using the DrawSprite method from the DIsplayConduit lately and I realized that it was generating a memory leak. Below is a code that can be used in a plugin to recreate the issue. There may be something wrong in the way I use the method but I couldn't find it.
publicclassTestSprite:Command{publicTestSprite(){// Rhino only creates one instance of each command class defined in a// plug-in, so it is safe to store a refence in a static property.Instance=this;}///<summary>The only instance of this command.</summary>publicstaticTestSpriteInstance{get;privateset;}///<returns>The command name as it appears on the Rhino command line.</returns>publicoverridestringEnglishName{get{return"DrawRectangle";}}protectedoverrideResultRunCommand(RhinoDocdoc,RunModemode){returnTest.SpriteDrawing(doc);}}publicclassTest{staticfloatm_sprite_size=200;publicstaticRhino.Commands.ResultSpriteDrawing(RhinoDocdoc){varsize_option=newRhino.Input.Custom.OptionDouble(m_sprite_size);vargo=newRhino.Input.Custom.GetOption();go.SetCommandPrompt("Sprite drawing mode");go.AddOptionDouble("Size",refsize_option);Rhino.Display.DisplayPipeline.PostDrawObjects+=DisplayRectangle;doc.Views.Redraw();while(go.Get()==Rhino.Input.GetResult.Option){m_sprite_size=(float)size_option.CurrentValue;doc.Views.Redraw();}Rhino.Display.DisplayPipeline.PostDrawObjects-=DisplayRectangle;returnRhino.Commands.Result.Success;}staticRhino.Display.DisplayBitmapmm;staticvoidDisplayRectangle(objectsender,Rhino.Display.DrawEventArgse){Bitmapbit=newBitmap((int)m_sprite_size,(int)m_sprite_size);using(Graphicsgraphics=Graphics.FromImage(bit)){// Main frameusing(Penpen=newPen(Color.Black)){graphics.FillRectangle(Brushes.White,0,0,m_sprite_size,m_sprite_size);graphics.DrawRectangle(pen,0,0,m_sprite_size,m_sprite_size);}}// DisplayRectangleFbounds=e.Viewport.Bounds;mm=newRhino.Display.DisplayBitmap(bit);e.Display.DrawSprite(mm,newPoint2d(bounds.Width/2+m_sprite_size/2,bounds.Height/2+m_sprite_size/2),m_sprite_size);bit.Dispose();mm.Dispose();}}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I have been using the DrawSprite method from the DIsplayConduit lately and I realized that it was generating a memory leak. Below is a code that can be used in a plugin to recreate the issue. There may be something wrong in the way I use the method but I couldn't find it.
The text was updated successfully, but these errors were encountered: