This project has moved and is read-only. For the latest updates, please go here.

Bitmap Presentation

Topics: SharpMap Project, SharpMap v2.0
May 30, 2008 at 8:14 PM
Does anyone have a simple Bitmap Presenter? All I need to do is render a map using GDI to a bitmap. I am trying to avoid writing one from scratch. It seems like this would be the base for an ASP.NET Presentation as well as the Windows Presentation. Am I missing something blatantly obvious?<o:p></o:p>
May 30, 2008 at 11:53 PM
The GDI presenter does this already. It takes geometries, converts them into graphics paths, and renders the paths to a bitmap.

In general, a bitmap is not the best solution. For WPF, it doesn't take advantage of the retained-mode visual hierarchy, and for ASP.Net, GDI is actually considered harmful (although that doesn't stop almost everyone from using it).
May 31, 2008 at 12:38 AM

True, but if you are pre-generating tiles or map images then it works great. Do you have any other suggestions? I also couldnt find the GDI presenter, where is it?


Jun 2, 2008 at 4:22 PM
Edited Jun 2, 2008 at 4:23 PM
Actually, even if you are pre-generating bitmaps, you still have to use them in ASP.Net, and this means using an HBitmap handle. Even for images off disk. I know, it is ridiculous - everyone does this! Thanks to Window's client-only legacy....

At any rate, the GDI "display" is split into two parts: the renderer and the presenter. The GDI renderer lives at /SharpMap/SharpMap.Rendering/GDI and the WinForms presenter (the only one done at the moment) lives at /SharpMap/SharpMap.Presentation/WinForms. The WinForms presenter takes the renderer output and puts it on a Bitmap instance, and then displays it. It should be close to what you are looking for, but it sounds like you'll need to modify it to get just the bitmap out, since in the Presenter case, it offers it to the MapViewControl to display on screen.