Problems with transparent ecw & jp2 - rasters with transparency mask do not display

Jul 15, 2013 at 1:29 PM
Hi,

First post so forgive me if this poped out before (could not find a solution though, hence I am here ;)

Anyway,
I am trying to render an ecw/jp2 raster. Everything works fine whenever the rasters do not have the transparent background. When they do, I get a transparent image.
For the time being I use non transparent rasters and just remove the background:
SharpMap.Layers.GdalRasterLayer rl = new SharpMap.Layers.GdalRasterLayer("testr", @"F:\test\sm_test.jp2");
            rl.TransparentColor = System.Drawing.Color.FromArgb(255, 255, 206);
The whole example is:
public static void testhandle()
        {
            SharpMap.Map m = new SharpMap.Map(new System.Drawing.Size(800, 600));
            
            m.BackColor = System.Drawing.Color.Transparent;

            m.SRID = 2180;

            #region this renders ok
            SharpMap.Layers.GdalRasterLayer rl = new SharpMap.Layers.GdalRasterLayer("testr", @"F:\test\sm_test.jp2");
            rl.TransparentColor = System.Drawing.Color.FromArgb(255, 255, 206);
            #endregion

            #region while this renders a transparent output
            //SharpMap.Layers.GdalRasterLayer rl = new SharpMap.Layers.GdalRasterLayer("testr", @"F:\test\sm_test_transparent.jp2");
            #endregion

            m.Layers.Insert(0, rl);

            m.ZoomToExtents();

            System.Drawing.Image testrender = m.GetMap();

            testrender.Save(@"F:\test\sm_test_testrender.png", System.Drawing.Imaging.ImageFormat.Png);
        }
I prepare my rasters in GlobalMapper.
Non-transparent images are exported with an option 'Make background (void) pixels transparent' set to false, while the transparent rasters set this to true.

The transparent rasters display fine in GlobalMapper, Manifold and QGIS, so I assume they should be ok.

Here are the example rasters I used for testing example_data

I used SharpMap rc3 + extensions (any cpu). The project is a simple website with target framework set to 4.0, hosted on my local iis and debugged in vs2012

Not sure what other information may be necessary, so please let me know if this is not enough.

Cheers
dom
Coordinator
Jul 16, 2013 at 9:00 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.