EcwRasterLayer.cs - 3 issues

Topics: General Topics, SharpMap v0.9 / v1.x
May 9, 2009 at 11:41 PM

Hi,

I have been using EcwRasterLayer.cs (Interop.NCSECWLib.dll) with SharpMap v0.9 for some time and it works well for both asp.net and web forms. I have three issues that all occur in EcwRasterLayer.cs and that may all be related.

Issue 1 - Exception on SetView
For every ecw file I have tested (including the examples supplied with the ecw SDK) I get a "Error HRESULT E_FAIL has been returned from a call to a COM component." (_COMPlusExceptionCode -532459699) exception on the following line in the Render method:

ecw.SetView(ecw.NumberOfBands, ref oImageBands, width, height, left, top, right, bottom);

If I wrap the above line in a try/catch the method continues on and renders the image properly. This is obviously not ideal but it works. Has anyone else experienced this problem?

Issue 2 - Printing - Image size
If I print the ecw using Printing.PrintPageEventArgs.Graphics and the Map.Render method the image is printed the wrong size which gets worse as the print resolution is increased. I can fix this issue by changing the following lines in the Render method when printing:

    int width = (int)Math.Round((right - left) / map.PixelSize);
    int height = (int)Math.Round((top - bottom) / map.PixelSize);

to:

    int width = (int)Math.Round((right - left) / map.PixelSize) * g.DpiX /100);
    int height = (int)Math.Round((top - bottom) / map.PixelSize) * g.DpiY / 100);

Issue 2 - Printing - Colour
If I print the ecw using Printing.PrintPageEventArgs.Graphics and the Map.Render method the image is printed the wrong colour. It appears to be only printed using Green. I have checked the bands and all the ecw bands are being printed. In fact, when I purposely limit the number of bands being rendered to 1 (ie only render the image in greyscale) the ecw image still prints green.

Any assistance would be greatly appreciated. Thank you in advance.