I'm creating a level editor in WPF for a 2D tile-based game. I'm trying to figure out the best way to load the tileset image file and render each tile in the appropriate location to reconstruct the map.
Currently, I'm loading the image as a BitmapSource, and I'm deriving from the Canvas class for the control that displays the map. I'm overriding the OnRender method so I can get a DrawingContext. However, DrawingContext.DrawImage doesn't appear to have an appropriate overload that draws only a subrect of an image; it looks like I have to draw the entire image.
What should I use if I want to draw subrects of an image onto a Canvas? Or should I be using something other than a Canvas?