Problems w/ MapScript C#
Ian Erickson
ierickson at ANALYGIS.COM
Mon Apr 4 09:32:19 PDT 2005
Nope...
This no-workie. It is not a GDI+ lock (at least in my case). For some
reason, after 3-4 sequential calls to the MapRefresh function, suddenly
the imageObj reference is suddenly null! I've downloaded the alternate
set of binaries from Morten Nielsen - we'll evalutate that set of
binaries and report back...
- Ian
Sean Gillies wrote:
> 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
>
--
Ian Erickson
AnalyGIS, LLC
More information about the MapServer-users
mailing list