When I make a tile-based map editor in C #, I try to iterate over the X, Y axes and call Graphics.DrawImage () to split one tile in place, from the bitmap on the Bitmap map. It takes several seconds to complete this process, so I only do it once when loading a new map or changing its set. Any changes from there are relatively quick highlights of the edited tile only.
Now I sat back today and thought about my options. Graphics.DrawImage () is the only one of the three (the others are DrawImageUnscaled and DrawImageUnscaledAndCropped (?)), Which allows you to specify the source origin. DrawImageUnscaled () was much more much faster, but always close to the upper left corner of the original bitmap.
Unlike the QuickBasic PSET and POKEing speeds of video memory or VB6 PSet versus WinAPI SetPixel, the simple Get / SetPixel loop was as fast as calling DrawImageUnscaled , but it did a trimming that would otherwise only have performed DrawImage.
It's fast enough, but I was wondering how something like direct image manipulation could speed it up even more? Is there something with LockBits, perhaps a feature that I know almost nothing about?
source share