From: <ai...@us...> - 2008-10-05 01:04:47
|
Revision: 8854 http://plplot.svn.sourceforge.net/plplot/?rev=8854&view=rev Author: airwin Date: 2008-10-05 01:00:26 +0000 (Sun, 05 Oct 2008) Log Message: ----------- Replace PIXELS_X (which is 32768) by PIXELS_X-1 to avoid overflowing PLplot core coordinates. This bug resulted in coordinate overflows for example 6 where the grid goes exactly to the edge of the physical device in the X direction. Change tested for gd, cairo, and svg device drivers, but applied to cgm and wingcc device drivers as well. Modified Paths: -------------- trunk/drivers/cairo.c trunk/drivers/cgm.c trunk/drivers/gd.c trunk/drivers/svg.c trunk/drivers/wingcc.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2008-10-04 22:24:59 UTC (rev 8853) +++ trunk/drivers/cairo.c 2008-10-05 01:00:26 UTC (rev 8854) @@ -674,7 +674,7 @@ /* Calculate ratio of (smaller) external coordinates used for cairo devices to (larger) internal PLplot coordinates. */ if (pls->xlength > pls->ylength) - downscale = (PLFLT)pls->xlength/(PLFLT)PIXELS_X; + downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); else downscale = (PLFLT)pls->ylength/(PLFLT)PIXELS_Y; plP_setphy((PLINT) 0, (PLINT) (pls->xlength / downscale), (PLINT) 0, (PLINT) (pls->ylength / downscale)); Modified: trunk/drivers/cgm.c =================================================================== --- trunk/drivers/cgm.c 2008-10-04 22:24:59 UTC (rev 8853) +++ trunk/drivers/cgm.c 2008-10-05 01:00:26 UTC (rev 8854) @@ -259,7 +259,7 @@ if (dev->cgmx>dev->cgmy) /* Work out the scaling factor for the */ { /* "virtual" (oversized) page */ - dev->scale=PIXELS_X/dev->cgmx; + dev->scale=(PIXELS_X-1)/dev->cgmx; } else { Modified: trunk/drivers/gd.c =================================================================== --- trunk/drivers/gd.c 2008-10-04 22:24:59 UTC (rev 8853) +++ trunk/drivers/gd.c 2008-10-05 01:00:26 UTC (rev 8854) @@ -505,7 +505,7 @@ if (dev->pngx>dev->pngy) /* Work out the scaling factor for the */ { /* "virtual" (oversized) page */ - dev->scale=(PLFLT)PIXELS_X/(PLFLT)dev->pngx; + dev->scale=(PLFLT)(PIXELS_X-1)/(PLFLT)dev->pngx; } else { @@ -661,7 +661,7 @@ if (dev->pngx>dev->pngy) /* Work out the scaling factor for the */ { /* "virtual" (oversized) page */ - dev->scale=(PLFLT)PIXELS_X/(PLFLT)dev->pngx; + dev->scale=(PLFLT)(PIXELS_X-1)/(PLFLT)dev->pngx; } else { Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2008-10-04 22:24:59 UTC (rev 8853) +++ trunk/drivers/svg.c 2008-10-05 01:00:26 UTC (rev 8854) @@ -172,7 +172,7 @@ /* Calculate ratio of (larger) internal PLplot coordinates to external coordinates used for svg file. */ if (canvasXSize > canvasYSize) - scale = (PLFLT)PIXELS_X/(PLFLT)canvasXSize; + scale = (PLFLT)(PIXELS_X-1)/(PLFLT)canvasXSize; else scale = (PLFLT)PIXELS_Y/(PLFLT)canvasYSize; /* to return to old behaviour use Modified: trunk/drivers/wingcc.c =================================================================== --- trunk/drivers/wingcc.c 2008-10-04 22:24:59 UTC (rev 8853) +++ trunk/drivers/wingcc.c 2008-10-05 01:00:26 UTC (rev 8854) @@ -616,7 +616,7 @@ if (dev->width>dev->height) /* Work out the scaling factor for the */ { /* "virtual" (oversized) page */ - dev->scale=(PLFLT)PIXELS_X/dev->width; + dev->scale=(PLFLT)(PIXELS_X-1)/dev->width; } else { @@ -1010,7 +1010,7 @@ dev->height=dev->rect.bottom; if (dev->width>dev->height) /* Work out the scaling factor for the */ { /* "virtual" (oversized) page */ - dev->scale=(PLFLT)PIXELS_X/dev->width; + dev->scale=(PLFLT)(PIXELS_X-1)/dev->width; } else { @@ -1300,7 +1300,7 @@ if (dev->width>dev->height) /* Work out the scaling factor for the */ { /* "virtual" (oversized) page */ - dev->scale=(PLFLT)PIXELS_X/dev->width; + dev->scale=(PLFLT)(PIXELS_X-1)/dev->width; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |