Problems w/ MapScript C#
Sean Gillies
sgillies at FRII.COM
Mon Apr 4 08:38:18 PDT 2005
On Apr 4, 2005, at 9:09 AM, Mike Saunt wrote:
> Sean
>
> I replied to Ian last night but had hit reply and not reply all hence
> it hadn't come on to the list. I had a similar problem on a different
> project with the .NET GDI+ locking the image file and the following
> resolved it.
>
> public System.Drawing.Image MapRefresh(int mapHeight, int mapWidth)
> {
> if (map == null)
> {
> return null;
> }
> map.height = mapHeight;
> map.width = mapWidth;
> MapScriptDotNet.imageObj img = map.draw();
>
> string sMapImage = @"C:\windows\temp\map.png";
> img.save(sMapImage,map);
>
> //we need to load via a memory stream as the GDI+ locks the
> image
> System.IO.FileStream fs = new System.IO.FileStream(sMapImage,
> FileMode.Open, FileAccess.Read, FileShare.Read);
> System.Drawing.Image mapImage =
> System.Drawing.Image.FromStream(fs);
> fs.Close();
> fs = null;
> File.Delete(sMapImage);
> return mapImage;
>
> }
>
> Hope this helps
>
> Cheers
> Mike Saunt
>
>
Aha! I have a feeling we are going to discover a few more MapServer
and .NET quirks yet.
cheers,
Se
More information about the MapServer-users
mailing list