[mapserver-commits] r7765 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Jun 30 14:01:39 EDT 2008
Author: tbonfort
Date: 2008-06-30 14:01:38 -0400 (Mon, 30 Jun 2008)
New Revision: 7765
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapresample.c
Log:
mapresample.c: fix for bug 2540 when using raster resampling and AGG
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2008-06-29 14:44:06 UTC (rev 7764)
+++ trunk/mapserver/HISTORY.TXT 2008-06-30 18:01:38 UTC (rev 7765)
@@ -11,6 +11,7 @@
Current Version (SVN trunk):
----------------------------
+- mapresample.c: fix for bug 2540 when using raster resampling and AGG.
- mapsde.c: Check at compile time that we have SE_connection_test_server,
which appears to only be available for ArcSDE 9+ (#2665).
Modified: trunk/mapserver/mapresample.c
===================================================================
--- trunk/mapserver/mapresample.c 2008-06-29 14:44:06 UTC (rev 7764)
+++ trunk/mapserver/mapresample.c 2008-06-30 18:01:38 UTC (rev 7765)
@@ -172,41 +172,6 @@
}
}
}
-#ifdef USE_AGG
- else if( MS_RENDERER_AGG(psSrcImage->format) )
- {
- if( !gdImageTrueColor(psSrcImage->img.gd) )
- {
- nValue = panCMap[srcImg->pixels[nSrcY][nSrcX]];
-
- if( nValue == -1 )
- continue;
-
- nSetPoints++;
- dstImg->pixels[nDstY][nDstX] = nValue;
- }
- else
- {
- int nValue = srcImg->tpixels[nSrcY][nSrcX];
- int gd_alpha = gdTrueColorGetAlpha(nValue);
-
- if( gd_alpha == 0 )
- {
- nSetPoints++;
- dstImg->tpixels[nDstY][nDstX] = nValue;
- }
- else if( gd_alpha == 127 )
- /* overlay is transparent, do nothing */;
- else
- {
- nSetPoints++;
- dstImg->tpixels[nDstY][nDstX] =
- gdAlphaBlend( dstImg->tpixels[nDstY][nDstX],
- nValue );
- }
- }
- }
-#endif
else if( MS_RENDERER_RAWDATA(psSrcImage->format) )
{
int band;
@@ -326,31 +291,6 @@
}
}
}
-#ifdef USE_AGG
- else if( MS_RENDERER_AGG(psSrcImage->format) )
- {
- if( !gdImageTrueColor(psSrcImage->img.gd) )
- {
- padfPixelSum[0] +=
- (dfWeight * psSrcImage->img.gd->pixels[iSrcY][iSrcX]);
- *pdfWeightSum += dfWeight;
- }
- else
- {
- int nValue = psSrcImage->img.gd->tpixels[iSrcY][iSrcX];
- int gd_alpha = gdTrueColorGetAlpha(nValue);
-
- if( gd_alpha != 127 )
- {
- padfPixelSum[0] += dfWeight * gdTrueColorGetRed(nValue);
- padfPixelSum[1] += dfWeight * gdTrueColorGetGreen(nValue);
- padfPixelSum[2] += dfWeight * gdTrueColorGetBlue(nValue);
-
- *pdfWeightSum += dfWeight;
- }
- }
- }
-#endif
else
{
int band;
@@ -549,45 +489,6 @@
}
}
}
-#ifdef USE_AGG
- else if( MS_RENDERER_AGG(psSrcImage->format) )
- {
- if( !gdImageTrueColor(psSrcImage->img.gd) )
- {
- int nResult = panCMap[(int) padfPixelSum[0]];
- if( nResult != -1 )
- {
- nSetPoints++;
- dstImg->pixels[nDstY][nDstX] = nResult;
- }
- }
- else
- {
- nSetPoints++;
- if( dfWeightSum > 0.99 )
- dstImg->tpixels[nDstY][nDstX] =
- gdTrueColor( (int) padfPixelSum[0],
- (int) padfPixelSum[1],
- (int) padfPixelSum[2] );
- else
- {
- int gd_color;
- int gd_alpha = 127 - 127.9 * dfWeightSum;
-
- gd_alpha = MAX(0,MIN(127,gd_alpha));
- gd_color = gdTrueColorAlpha(
- (int) padfPixelSum[0],
- (int) padfPixelSum[1],
- (int) padfPixelSum[2],
- gd_alpha );
-
- dstImg->tpixels[nDstY][nDstX] =
- msAlphaBlend( dstImg->tpixels[nDstY][nDstX],
- gd_color );
- }
- }
- }
-#endif
else if( MS_RENDERER_RAWDATA(psSrcImage->format) )
{
int band;
@@ -814,46 +715,6 @@
}
}
}
-#ifdef USE_AGG
- else if( MS_RENDERER_AGG(psSrcImage->format) )
- {
- if( !gdImageTrueColor(psSrcImage->img.gd) )
- {
- int nResult = panCMap[(int) padfPixelSum[0]];
- if( nResult != -1 )
- {
- nSetPoints++;
- dstImg->pixels[nDstY][nDstX] = nResult;
- }
- }
- else
- {
- nSetPoints++;
- if( dfAlpha01 > 0.99 )
- dstImg->tpixels[nDstY][nDstX] =
- gdTrueColor( (int) padfPixelSum[0],
- (int) padfPixelSum[1],
- (int) padfPixelSum[2] );
- else
- {
- int gd_color;
- int gd_alpha = (int) (127 - 127.9 * dfAlpha01);
-
- gd_alpha = MAX(0,MIN(127,gd_alpha));
- gd_color = gdTrueColorAlpha(
- (int) padfPixelSum[0],
- (int) padfPixelSum[1],
- (int) padfPixelSum[2],
- gd_alpha );
-
- dstImg->tpixels[nDstY][nDstX] =
- msAlphaBlend( dstImg->tpixels[nDstY][nDstX],
- gd_color );
-
- }
- }
- }
-#endif
else if( MS_RENDERER_RAWDATA(psSrcImage->format) )
{
int band;
@@ -1646,6 +1507,21 @@
/* for the temporary image to include transparentency support. */
/* -------------------------------------------------------------------- */
sDummyMap.outputformat = msCloneOutputFormat( image->format );
+ #ifdef USE_AGG
+ if( MS_RENDERER_AGG(sDummyMap.outputformat))
+ {
+/*
+Fix for bug 2540 :
+
+The resampling methods used later assume that the pixel format of the
+dummy image is in gd format (alpha between 127 and 0). If we keep an AGG
+outpuformat, the image is initialised with its alpha=0, which is interpreted
+as fully opaque instead of fully transparent. The fix is to completely forget
+about AGG here, and create a GD imageObj
+*/
+ sDummyMap.outputformat->renderer=MS_RENDER_WITH_GD;
+ }
+#endif
sDummyMap.width = nLoadImgXSize;
sDummyMap.height = nLoadImgYSize;
@@ -1664,16 +1540,6 @@
sDummyMap.imagecolor.green = 17;
sDummyMap.imagecolor.blue = 191;
}
-#ifdef USE_AGG
- else if( MS_RENDERER_AGG(sDummyMap.outputformat)
- && !gdImageTrueColor( image->img.gd ) )
- {
- sDummyMap.outputformat->transparent = MS_TRUE;
- sDummyMap.imagecolor.red = 117;
- sDummyMap.imagecolor.green = 17;
- sDummyMap.imagecolor.blue = 191;
- }
-#endif
/* -------------------------------------------------------------------- */
/* If we are working in RGB mode ensure we produce an RGBA */
/* image so the transparency can be preserved. */
@@ -1691,21 +1557,6 @@
sDummyMap.imagecolor.green = map->imagecolor.green;
sDummyMap.imagecolor.blue = map->imagecolor.blue;
}
-#ifdef USE_AGG
- else if( MS_RENDERER_AGG(sDummyMap.outputformat)
- && gdImageTrueColor( image->img.gd ) )
- {
- assert( sDummyMap.outputformat->imagemode == MS_IMAGEMODE_RGB
- || sDummyMap.outputformat->imagemode == MS_IMAGEMODE_RGBA );
-
- sDummyMap.outputformat->transparent = MS_TRUE;
- sDummyMap.outputformat->imagemode = MS_IMAGEMODE_RGBA;
-
- sDummyMap.imagecolor.red = map->imagecolor.red;
- sDummyMap.imagecolor.green = map->imagecolor.green;
- sDummyMap.imagecolor.blue = map->imagecolor.blue;
- }
-#endif
/* -------------------------------------------------------------------- */
/* Setup a dummy map object we can use to read from the source */
/* raster, with the newly established extents, and resolution. */
@@ -1761,27 +1612,6 @@
for( iColor = nColorCount; iColor < 256; iColor++ )
anCMap[iColor] = -1;
}
-#ifdef USE_AGG
- else if( MS_RENDERER_AGG(srcImage->format)
- && !gdImageTrueColor( srcImage->img.gd ) )
- {
- int iColor, nColorCount;
-
- anCMap[0] = -1; /* color zero is always transparent */
-
- nColorCount = gdImageColorsTotal( srcImage->img.gd );
- for( iColor = 1; iColor < nColorCount; iColor++ )
- {
- anCMap[iColor] =
- msAddColorAGG( map, image->img.gd, 0,
- gdImageRed( srcImage->img.gd, iColor ),
- gdImageGreen( srcImage->img.gd, iColor ),
- gdImageBlue( srcImage->img.gd, iColor ) );
- }
- for( iColor = nColorCount; iColor < 256; iColor++ )
- anCMap[iColor] = -1;
- }
-#endif
/* -------------------------------------------------------------------- */
/* Setup transformations between our source image, and the */
/* target map image. */
More information about the mapserver-commits
mailing list