Question : BitBlt visble region

I have created a drawing application of sorts, usually when the user (me) does sa standard drawing their will be about 8000 seperate GraphicsPath objects on the screen and a background image bitmap.

To display the drawing I have used the BufferedGraphics class for the speed using bitblt.

The code to draw the image

    Private m_BGContext As BufferedGraphicsContext
    Private m_BufferedGraphics As BufferedGraphics
    Private m_ImageVisible As Boolean = True

    Private Sub Draw()

        m_BufferedGraphics.Dispose()
        m_BufferedGraphics = m_BGContext.Allocate(m_PicBoxGraphics, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height))

        If m_ImageVisible Then
            m_BufferedGraphics.Graphics.DrawImage(m_img, 0, 0, PictureBox1.Width, PictureBox1.Height)
        End If

        m_BufferedGraphics.Graphics.SmoothingMode = SmoothingMode.AntiAlias
        m_BufferedGraphics.Graphics.CompositingQuality = CompositingQuality.HighQuality

        m_MyDrawing.Draw(m_BufferedGraphics.Graphics)

End Sub

The problem I have is when i zoom the whole drawing my memory usage is going up and slowing performance, if i zoom out it does go back to normal so no memory leaks,  so the question is. Does anyone know how I can bitblt only the viewable/visible region of the drawing. I had talked to a Java developer and he though they have something called a viewport which would do what I wanted if i was in Java, but I couldnt find much out about it and even if there was an equivalent in .Net so not sure if this was a wild goose chase, just thought i would mention it.

Anyway if this makes sense to anyone, thanks in advance for any help.

Oh and I cant use WPF which I think would be better but it has to be GDI+ and I cant drop the quality of the drawing.

Kind regards

Andy

Answer : BitBlt visble region

Without seeing any code this will be pretty tough to answer.  How are you "zooming"?

The generic answer is that YOU compute the visible region in the form of a Rectangle based on YOUR zooming algorithm and then use GraphicsPath.GetBounds() for each GraphicsPath and see if the resulting rectanlge is visible using Rectangle.Intersect().  If so, then you draw that GraphicsPath in your "render" method...
Random Solutions  
 
programming4us programming4us