Since the thread I replied to just got locked (it was only on the second page and no answer was given to the op, so I don't see the problem), here it is again as a brand spankin new topic!
I would really like to know this. I've been developing a multi-page tiff editor which currently has a working pencil, text tool, color picker, form/image coordinate spaces, etc. It is usable in it's current state, but not perfect. All edits are done by creating a graphics object out of the loaded image and drawing to that.
The text tool works by calling drawstring() on the graphics object every time the user types a character, but when the user backspaces and types again it just overlaps with more text. I figured I would need to implement a layer system like Photoshop has, and it sounds easy enough. It seems like you could just create a new transparent bitmap for each layer with the same size as the original image, and then render them all together in order to a picturebox. I have tried this and it's very slow.
My pencil tool does not create a consistent stroke, it stutters with gaps inbetween. It just draws a square using fillrectangle() whenever the mouse moves, but there's obviously a sync issue with the mouse and the picturebox painting, or something else that causes the stroke to have gaps.
I came here thinking I might find some examples of the inner workings of Paint.NET to give me a clue about some better techniques I could use in my own program. I would greatly appreciate it if a Paint.NET dev could come here and talk about it.