GdalRasterLayer patch problem.

Topics: SharpMap Project, SharpMap v0.9 / v1.x, WinForms Controls
Jun 10, 2008 at 6:24 PM
I've downloaded Dan's GdalRasterLayer patch and it works fine with the sample data (thanks, Dan).
However, my own TIFFs appear with grey scales instead of in glorious technicolor.
Any ideas?

Regards,
Lewis.
Jun 11, 2008 at 2:48 PM
Edited Jun 11, 2008 at 3:18 PM
Without knowning what format your tiffs are in, I can't say for sure, but they are probably just in a format not currently supported by the GDalRasterLayer.  I know pallete and monochrome are not supported, but they wouldn't be hard to add.  Do you have a color image displaying as greyscale, or does it just show up as one solid color (black, gray, white)?
Jun 11, 2008 at 3:25 PM
Edited Jun 11, 2008 at 3:26 PM
I'm afraid I don't know what format my TIFFs are in but they appear as a greyscale image.
If it's useful, PaintShop Pro image information shows the pixel depth/colours=8/256 and the Number of layers=1.
Actually, I quite like the option of having my Map appear without colours, especially when drawing other layers on top, but not all the time.
Jun 11, 2008 at 4:03 PM
I am not familiar with PaintShop, but the Number of layers = 1 sounds like its just a greyscale image.  A color image will probably have Number of layers = 3 (red, green, blue).  You could try looking at the PaintShop info on the sample tiffs to confirm this.
Coordinator
Jun 12, 2008 at 6:51 AM
@LewInMadrid:

dan3258 is right, if my math holds up. Since all 8 bits per pixel are taken up by the color scale (2^8 = 256), you only have one layer. It doesn't have to be gray, if you'd prefer assigning some other color values to the scale... Not sure how you'd do this though. Actually, Dan, does the GDALRasterLayer support mapping layer values onto a color map? I'm starting to vet the raster style stuff, and it can support this kind of styling...
Jun 12, 2008 at 8:55 AM
Thanks for the feedback.
The image is definitely a colour one as I can see the colours correctly in both PaintShop and MapInfo.
My guess is that it uses a TIFF colour pallete which Dan says is not supported.

Coordinator
Jun 12, 2008 at 9:32 AM
Yep, if you see color, it's because there is a color map or color palette involved. I missed Dan's point that it doesn't currently work, but it should be not hard... if Dan is implementing it. ;)
Jun 13, 2008 at 1:42 PM
Works fine on Windows 2000 but gives a Gdal PInvoke error on Windows XP.
Initially I had the PInvoke error on Windows 2000 but I resolved the problem by copying all the gdal dlls from the dependencies directory to debug.
However, I've moved the software to Windows XP and it falls over on opening a TIFF with the gdal PInvoke error.
I get the same error not just with my project but with a freshly downloaded copy of DemoWinForm.
I've tested on two PCs with Windows XP and get the same error and two PCs with Windows 2000 without errors.
Can anyone suggest where to look?
Oct 29, 2008 at 8:00 PM
I am encountering the PINVOKE error as well on Vista Business Edition.

Suggestions would be highly appreciated.
Oct 30, 2008 at 2:12 AM
hi.
Where can I download this GdalRasterLayer patch ? thanks.
Oct 30, 2008 at 3:02 PM
http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=SharpMap&DownloadId=24213
Oct 31, 2008 at 1:39 AM
I found a solution for my PINVOKE error.  I downloaded the latest version of FWTools (http://home.gdal.org/fwtools/FWTools228.exe) and place the dlls that are in the /bin/ folder and the /csharp/ folder in the same folder as the /debug/ folder or equivalent folder where you have the .exe file.
Jun 24, 2010 at 8:46 AM

I am seeing this issue with Rasters and sharpmap with the latest trunk. Does GDALRasterLayer have support for palletes? My rasters are geotiff's and FW has checked that the problem is not with GDAL.

Coordinator
Jun 24, 2010 at 9:55 AM

Hello plasmab,

this thread is quite old, the latest source in the trunk should be able to handle palette geotiffs, so my suggestion is that you get the latest source, compile sharpmap yourself and see if your issue is resolved. If that is not the case, please raise an issue and provide the image in question.

Hth FObermaier

Jun 24, 2010 at 2:00 PM

latest code  that i could download (69094) did not support 8 bbp palette geotiffs. I managed to hack the code to support this myself. Wasnt very hard. I didnt see any paletted support in the code.

 

Coordinator
Jun 24, 2010 at 2:18 PM

In that case, it'd be nice if you could provide a patchfile, so others can take advantage of your improvement(s) as well.

Thanks FObermaier

Jun 24, 2010 at 2:34 PM

I added http://pastebin.com/hP6BmVdR to GetNonRotatedPreview in GDALRasterLayer.cs

It needs cleaned up to detect 8bits per pixel nicely. I moved the bitmap locking each codepath. Its hacky but it works. I wouldnt use it as is.

Coordinator
Jun 24, 2010 at 3:04 PM

I just browsed the code in GdalRasterLayer and have a question:

If you set the "UseRotation" property to "true", does your 8bpp GeoTiff still not work?

FObermaier

 

Jun 24, 2010 at 3:20 PM

I reverted and set userotation to true. Back to black and white. You have to set a non identity transform for the GetPreview() codepath to be followed. When i did this i didnt even get a greyscale. I got a blank screen.

 

The code in GetPreview looks very inefficient. The simplest and most effective way to implement paletted bitmaps is to let GDI+ handle them by converting everything to a paletted bitmap.

 

 

 

Jun 24, 2010 at 3:56 PM
http://www.vavi.co.uk/~sleary/SU83NE.TIF http://www.vavi.co.uk/~sleary/SU83NE.TFW for you if you want to test it for yourself.
Coordinator
Jun 24, 2010 at 4:27 PM

thank you, I will test it tomorrow.

cheers FObermaier

Coordinator
Jun 25, 2010 at 9:30 AM

I just fixed GdalRasterLayer to show your paletted image. Is that image copyrighted in any way, or may I add it as a sample to WinFormsSample project

Cheers FObermaier

Jun 25, 2010 at 1:03 PM
Many Thanks, Unfortunately the image is copyrighted but it is available for free download from the OS. Its a tile from OS Streetview