[mapserver-commits] r10504 - in sandbox/mapserver6: . mapscript/php
svn at osgeo.org
svn at osgeo.org
Mon Sep 13 15:05:06 EDT 2010
Author: aboudreault
Date: 2010-09-13 19:05:06 +0000 (Mon, 13 Sep 2010)
New Revision: 10504
Modified:
sandbox/mapserver6/mapagg.cpp
sandbox/mapserver6/mapscript/php/class.c
sandbox/mapserver6/mapscript/php/image.c
sandbox/mapserver6/mapscript/php/mapscript_i.c
sandbox/mapserver6/maputil.c
Log:
Fixed PHP/MapScript to use proper functions of mapserver 6 rendering
Modified: sandbox/mapserver6/mapagg.cpp
===================================================================
--- sandbox/mapserver6/mapagg.cpp 2010-09-11 16:05:20 UTC (rev 10503)
+++ sandbox/mapserver6/mapagg.cpp 2010-09-13 19:05:06 UTC (rev 10504)
@@ -631,7 +631,7 @@
rendering_buffer b(overlay->data.rgba.pixels, overlay->width, overlay->height, overlay->data.rgba.row_step);
pixel_format pf(b);
AGG2Renderer *r = AGG_RENDERER(dest);
- r->m_renderer_base.blend_from(pf,0, 0, 0,unsigned(opacity * 255));
+ r->m_renderer_base.blend_from(pf,0, dstX, dstY,unsigned(opacity * 255));
return MS_FAILURE;
}
Modified: sandbox/mapserver6/mapscript/php/class.c
===================================================================
--- sandbox/mapserver6/mapscript/php/class.c 2010-09-11 16:05:20 UTC (rev 10503)
+++ sandbox/mapserver6/mapscript/php/class.c 2010-09-13 19:05:06 UTC (rev 10504)
@@ -652,10 +652,10 @@
php_map = (php_map_object *) zend_object_store_get_object(php_layer->parent.val TSRMLS_CC);
- if (!(MS_DRIVER_GD(php_image->image->format)|| MS_DRIVER_AGG(php_image->image->format)))
+ if (!MS_RENDERER_PLUGIN(php_image->image->format))
{
mapscript_report_mapserver_error(E_WARNING TSRMLS_CC);
- mapscript_report_php_error(E_WARNING, "DrawLegendicon function is only available for GD and AGG drivers" TSRMLS_CC);
+ mapscript_report_php_error(E_WARNING, "DrawLegendicon function is only available for renderer plugin drivers" TSRMLS_CC);
RETURN_LONG(MS_FAILURE);
}
Modified: sandbox/mapserver6/mapscript/php/image.c
===================================================================
--- sandbox/mapserver6/mapscript/php/image.c 2010-09-11 16:05:20 UTC (rev 10503)
+++ sandbox/mapserver6/mapscript/php/image.c 2010-09-13 19:05:06 UTC (rev 10504)
@@ -180,7 +180,9 @@
zval *zimage;
zval *zobj = getThis();
php_image_object *php_image, *php_imageSrc;
- int oldTransparentColor, newTransparentColor=-1, r, g, b;
+ /*int oldTransparentColor, newTransparentColor=-1, r, g, b;*/
+ rendererVTableObj *renderer = NULL;
+ rasterBufferObj rb;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol|lll",
@@ -199,11 +201,11 @@
php_image = (php_image_object *) zend_object_store_get_object(zobj TSRMLS_CC);
php_imageSrc = (php_image_object *) zend_object_store_get_object(zimage TSRMLS_CC);
-
- if( (!MS_DRIVER_GD(php_imageSrc->image->format) && !MS_DRIVER_AGG(php_imageSrc->image->format)) ||
- (!MS_DRIVER_GD(php_image->image->format) && !MS_DRIVER_AGG(php_image->image->format)))
+
+ if (!MS_RENDERER_PLUGIN(php_imageSrc->image->format) ||
+ !MS_RENDERER_PLUGIN(php_image->image->format))
{
- mapscript_throw_exception("PasteImage function should only be used with GD or AGG images." TSRMLS_CC);
+ mapscript_throw_exception("PasteImage function should only be used with GD, AGG or CAIRO images." TSRMLS_CC);
return;
}
@@ -214,11 +216,18 @@
msAlphaAGG2GD(php_image->image);
#endif
+
+ renderer = MS_IMAGE_RENDERER(php_image->image);
+ memset(&rb,0,sizeof(rasterBufferObj));
+
+ renderer->getRasterBufferHandle(php_imageSrc->image, &rb);
+ renderer->mergeRasterBuffer(php_image->image, &rb, 1.0, 0, 0, dstx, dsty, rb.width, rb.height);
+
/* Look for r,g,b in color table and make it transparent.
* will return -1 if there is no exact match which will result in
* no transparent color in the call to gdImageColorTransparent().
*/
- if (transparent != -1)
+/* if (transparent != -1)
{
r = (transparent / 0x010000) & 0xff;
g = (transparent / 0x0100) & 0xff;
@@ -237,7 +246,7 @@
0, 0, php_imageSrc->image->img.gd->sx, php_imageSrc->image->img.gd->sy,
angle);
- gdImageColorTransparent(php_imageSrc->image->img.gd, oldTransparentColor);
+ gdImageColorTransparent(php_imageSrc->image->img.gd, oldTransparentColor);*/
RETURN_LONG(MS_SUCCESS);
@@ -260,12 +269,7 @@
php_map_object *php_map;
int status = MS_SUCCESS;
/* stdout specific vars */
- char *imagePath = NULL;
- char *pBuf = NULL;
int size=0;
- int b;
- FILE *tmp = NULL;
- char buf[4096];
void *iptr=NULL;
PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
@@ -301,7 +305,7 @@
}
- if( MS_DRIVER_GD(php_image->image->format) || MS_DRIVER_AGG(php_image->image->format))
+ if (MS_RENDERER_PLUGIN(php_image->image->format))
{
iptr = (void *)msSaveImageBuffer(php_image->image, &size, php_image->image->format);
}
@@ -310,44 +314,7 @@
iptr = php_image->image->img.imagemap;
size = strlen(php_image->image->img.imagemap);
}
- else if (MS_DRIVER_SVG(php_image->image->format))
- {
- status = MS_FAILURE;
-
- if (imagePath)
- {
- pBuf = msTmpFile(NULL, imagePath, "svg");
-
- tmp = fopen(pBuf, "w");
- }
- if (tmp == NULL)
- {
- mapscript_throw_mapserver_exception("Unable to open temporary file for SVG output." TSRMLS_CC);
- return;
- }
-
- if (msSaveImagetoFpSVG(php_image->image, tmp) == MS_SUCCESS)
- {
- fclose(tmp);
- tmp = fopen(pBuf, "r");
-
- while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0)
- {
- php_write(buf, b TSRMLS_CC);
- }
- fclose(tmp);
- status = MS_SUCCESS;
- }
- else
- {
- mapscript_throw_mapserver_exception("Unable to open temporary file for SVG output." TSRMLS_CC);
- return;
- }
-
- RETURN_LONG(status);
- }
-
if (size == 0) {
mapscript_throw_mapserver_exception("Failed writing image to stdout" TSRMLS_CC);
return;
Modified: sandbox/mapserver6/mapscript/php/mapscript_i.c
===================================================================
--- sandbox/mapserver6/mapscript/php/mapscript_i.c 2010-09-11 16:05:20 UTC (rev 10503)
+++ sandbox/mapserver6/mapscript/php/mapscript_i.c 2010-09-13 19:05:06 UTC (rev 10504)
@@ -1288,7 +1288,7 @@
msFreeShape(shape); /* frees all lines and points before re-filling */
msSHPReadShape(self->hSHP, i, shape);
- msTransformShapeToPixel(shape, map->extent, map->cellsize);
+ msTransformShapeToPixel(shape, map->extent, map->cellsize, MS_SIMPLIFY_DEFAULT);
return 0;
}
Modified: sandbox/mapserver6/maputil.c
===================================================================
--- sandbox/mapserver6/maputil.c 2010-09-11 16:05:20 UTC (rev 10503)
+++ sandbox/mapserver6/maputil.c 2010-09-13 19:05:06 UTC (rev 10504)
@@ -755,6 +755,7 @@
msBufferInit(&buffer);
renderer->getRasterBufferHandle(image,&data);
msSaveRasterBufferToBuffer(&data,&buffer,format);
+ *size_ptr = buffer.size;
return buffer.data;
//don't free the bufferObj as we don't own the bytes anymore
} else {
More information about the mapserver-commits
mailing list