id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
6905,Northwood GRC driver returns incorrect alpha value in color table,Daniel Morissette,Daniel Morissette,"I was tracking down an issue with MapServer which was not rendering Northwood GRC files properly, and eventually found that the problem is that the GDAL driver returns a collor table with invalid alpha values.
The code in grcdataset.cpp assumes that alpha 0=opaque and 255=transparent instead of 0=transparent and 255=opaque as it should, so all colors in the returned color table are 100% transparent. In the end the issue is not that MapServer does not render the GRC file, it is that it renders it using transparent ink.
I am surprised that anyone has ever been able to use files read by this driver since this code has not changed in 7 years, so this issue has always been there.
Even, can you please confirm that the following patch makes sense and that I am not missing something obvious about alpha values?
{{{
Index: grcdataset.cpp
===================================================================
--- grcdataset.cpp (revision 38717)
+++ grcdataset.cpp (working copy)
@@ -117,9 +117,9 @@
// load the color table and might as well to the ClassNames
poGDS->poColorTable = new GDALColorTable();
- GDALColorEntry oEntry = { 255, 255, 255, 255 };
+ GDALColorEntry oEntry = { 255, 255, 255, 0 };
// null value = 0 is transparent
- // alpha 255 = transparent
+ // alpha 0 = transparent
poGDS->poColorTable->SetColorEntry( 0, &oEntry );
@@ -130,7 +130,7 @@
oEntry.c1 = poGDS->pGrd->stClassDict->stClassifedItem[i]->r;
oEntry.c2 = poGDS->pGrd->stClassDict->stClassifedItem[i]->g;
oEntry.c3 = poGDS->pGrd->stClassDict->stClassifedItem[i]->b;
- oEntry.c4 = 0; // alpha 0 = solid
+ oEntry.c4 = 255; // alpha 255 = solid
poGDS->poColorTable->SetColorEntry( poGDS->pGrd->
stClassDict->stClassifedItem[i]->
}}}",defect,closed,normal,1.11.6,GDAL_Raster,unspecified,normal,fixed,,Even Rouault