Question

I created an application that allows user to magnify a certain part of a background picture. The main problem is, that the magnification field is lagging as you can see on the picture. And also this is a single threaded application. Does anyone have any suggestion what can I do to solve my problem?

enter image description here

my code:

    public void Magnifier(Point e)
    {
        magnifiedPicture.Size = new Size(MagnifierSize, MagnifierSize);    
        magnifiedPicture.Visible = true;
        magnifiedPicture.Location = new Point(e.X-MagnifierSize/2, e.Y-MagnifierSize/2);  
        magnifiedPicture.BackgroundImage = CutThePicture(CanvasImage, new Rectangle(_ptOnCanvas.X - 18, _ptOnCanvas.Y - 18, 16, 16)); 
        magnifiedPicture.Refresh(); // <-- just for probe, but without any effect
    }
Was it helpful?

Solution

I use InvokePaint on mouse move event and the problem was solved.

InvokePaint( this, new PaintEventArgs( this.CreateGraphics(), this.DisplayRectangle ) );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top