GDI+ Drawing an image on top of another

Sep 21, 2010 at 7:26 AM
I am drawing a couple of rectangles on the WinForm version of the GMap.NET control as such:
Public Overrides Sub OnRender(ByVal g As Graphics)
g.FillRectangle(FillBrush, New System.Drawing.Rectangle(LocalPosition.X, LocalPosition.Y, scaledWidth, scaledHeight))
End Sub
I then draw an image marker as such:

Public Overrides Sub OnRender(ByVal g As Graphics)
g.DrawImageUnscaled(Image, LocalPosition.X - Image.Width / 2, LocalPosition.Y - Image.Height / 2, Image.Width, Image.Height)
End Sub

The problem is that the image is appearing underneath the rectangle (even though the rectangle was drawn first). Is there a way to make the image appear on top of the rectangle?



Sep 21, 2010 at 7:32 AM

you can add image marker in different layer which is added last, so it would be rendered last

Sep 21, 2010 at 7:41 AM

Of course! Hehe, thanks radioman. Worked perfectly ;)