[GRASS-SVN] r34720 - in grass/trunk/lib: cairodriver driver
htmldriver pngdriver psdriver raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 4 11:47:24 EST 2008
Author: glynn
Date: 2008-12-04 11:47:24 -0500 (Thu, 04 Dec 2008)
New Revision: 34720
Added:
grass/trunk/lib/cairodriver/Draw.c
grass/trunk/lib/driver/path.c
grass/trunk/lib/htmldriver/Draw.c
grass/trunk/lib/pngdriver/Draw.c
grass/trunk/lib/pngdriver/Point.c
grass/trunk/lib/psdriver/Draw.c
Removed:
grass/trunk/lib/cairodriver/Draw_line.c
grass/trunk/lib/cairodriver/Draw_point.c
grass/trunk/lib/cairodriver/Poly.c
grass/trunk/lib/driver/Bitmap.c
grass/trunk/lib/driver/Cont.c
grass/trunk/lib/psdriver/Draw_line.c
grass/trunk/lib/psdriver/Draw_point.c
grass/trunk/lib/psdriver/Polygon.c
grass/trunk/lib/psdriver/Polyline.c
Modified:
grass/trunk/lib/cairodriver/Color.c
grass/trunk/lib/cairodriver/Draw_bitmap.c
grass/trunk/lib/cairodriver/Driver.c
grass/trunk/lib/cairodriver/Raster.c
grass/trunk/lib/cairodriver/Text.c
grass/trunk/lib/cairodriver/cairodriver.h
grass/trunk/lib/driver/Color.c
grass/trunk/lib/driver/Draw.c
grass/trunk/lib/driver/Get_t_box.c
grass/trunk/lib/driver/Polydots.c
grass/trunk/lib/driver/Polygon.c
grass/trunk/lib/driver/Polyline.c
grass/trunk/lib/driver/Raster.c
grass/trunk/lib/driver/Text.c
grass/trunk/lib/driver/driver.h
grass/trunk/lib/driver/driverlib.h
grass/trunk/lib/driver/text3.c
grass/trunk/lib/htmldriver/Box.c
grass/trunk/lib/htmldriver/Driver.c
grass/trunk/lib/htmldriver/Polygon.c
grass/trunk/lib/htmldriver/htmlmap.h
grass/trunk/lib/pngdriver/Color.c
grass/trunk/lib/pngdriver/Color_table.c
grass/trunk/lib/pngdriver/Draw_bitmap.c
grass/trunk/lib/pngdriver/Draw_line.c
grass/trunk/lib/pngdriver/Driver.c
grass/trunk/lib/pngdriver/Graph_set.c
grass/trunk/lib/pngdriver/Polygon.c
grass/trunk/lib/pngdriver/Raster.c
grass/trunk/lib/pngdriver/pngdriver.h
grass/trunk/lib/pngdriver/read_bmp.c
grass/trunk/lib/pngdriver/read_png.c
grass/trunk/lib/pngdriver/read_ppm.c
grass/trunk/lib/pngdriver/write_bmp.c
grass/trunk/lib/pngdriver/write_png.c
grass/trunk/lib/pngdriver/write_ppm.c
grass/trunk/lib/psdriver/Color.c
grass/trunk/lib/psdriver/Draw_bitmap.c
grass/trunk/lib/psdriver/Driver.c
grass/trunk/lib/psdriver/Raster.c
grass/trunk/lib/psdriver/psdriver.h
grass/trunk/lib/psdriver/psdriver.ps
grass/trunk/lib/raster/raster.c
Log:
Replace polygon/polyline with path-based primitives
Replace polydots with single point primitive
Miscellaneous clean-up
Modified: grass/trunk/lib/cairodriver/Color.c
===================================================================
--- grass/trunk/lib/cairodriver/Color.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Color.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -22,9 +22,9 @@
\param color value
*/
-void Cairo_color_rgb(int r, int g, int b)
+void Cairo_Color(int r, int g, int b)
{
- G_debug(3, "Cairo_color: %d,%d,%d", r, g, b);
+ G_debug(3, "Cairo_Color: %d,%d,%d", r, g, b);
cairo_set_source_rgba(cairo,
CAIROCOLOR(r), CAIROCOLOR(g), CAIROCOLOR(b), 1.0);
Added: grass/trunk/lib/cairodriver/Draw.c
===================================================================
--- grass/trunk/lib/cairodriver/Draw.c (rev 0)
+++ grass/trunk/lib/cairodriver/Draw.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -0,0 +1,61 @@
+/*!
+ \file cairodriver/Draw.c
+
+ \brief GRASS cairo display driver
+
+ (C) 2007-2008 by Lars Ahlzen, Glynn Clements and the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Lars Ahlzen <lars ahlzen.com> (original contibutor)
+ \author Glynn Clements
+*/
+
+#include "cairodriver.h"
+
+void Cairo_Begin(void)
+{
+ cairo_new_path(cairo);
+}
+
+void Cairo_Move(double x, double y)
+{
+ cairo_move_to(cairo, x, y);
+}
+
+void Cairo_Cont(double x, double y)
+{
+ cairo_line_to(cairo, x, y);
+}
+
+void Cairo_Close(void)
+{
+ cairo_close_path(cairo);
+}
+
+void Cairo_Stroke(void)
+{
+ cairo_stroke(cairo);
+ ca.modified = 1;
+}
+
+void Cairo_Fill(void)
+{
+ cairo_fill(cairo);
+ ca.modified = 1;
+}
+
+void Cairo_Point(double x, double y)
+{
+ static double point_size = 1.0;
+ double half_point_size = point_size / 2;
+
+ cairo_new_path(cairo);
+ cairo_rectangle(cairo,
+ x - half_point_size, y - half_point_size,
+ point_size, point_size);
+ cairo_fill(cairo);
+ ca.modified = 1;
+}
+
Modified: grass/trunk/lib/cairodriver/Draw_bitmap.c
===================================================================
--- grass/trunk/lib/cairodriver/Draw_bitmap.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Draw_bitmap.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -47,19 +47,19 @@
\param threshold threshold value
\param buf data buffer
*/
-void Cairo_draw_bitmap(int ncols, int nrows, int threshold,
+void Cairo_Bitmap(int ncols, int nrows, int threshold,
const unsigned char *buf)
{
cairo_surface_t *surf;
- G_debug(1, "Cairo_draw_bitmap: %d %d %d", ncols, nrows, threshold);
+ G_debug(1, "Cairo_Bitmap: %d %d %d", ncols, nrows, threshold);
surf = cairo_image_surface_create_for_data((unsigned char *)buf,
CAIRO_FORMAT_A8, ncols, nrows,
ncols);
if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS)
- G_fatal_error(_("Cairo_draw_bitmap: Failed to create source"));
+ G_fatal_error(_("Cairo_Bitmap: Failed to create source"));
surf = fix_surface(surf);
@@ -67,6 +67,4 @@
cairo_surface_destroy(surf);
ca.modified = 1;
-
- return;
}
Deleted: grass/trunk/lib/cairodriver/Draw_line.c
===================================================================
--- grass/trunk/lib/cairodriver/Draw_line.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Draw_line.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,38 +0,0 @@
-/*!
- \file cairodriver/Draw_line.c
-
- \brief GRASS cairo display driver - colors management
-
- (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
-
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
-
- \author Lars Ahlzen <lars ahlzen.com> (original contibutor)
- \author Glynn Clements
-*/
-
-#include "cairodriver.h"
-
-/*!
- \brief Draw line
-
- \param x1,y1,x2,y2 line nodes
-*/
-void Cairo_draw_line(double x1, double y1, double x2, double y2)
-{
- G_debug(3, "Cairo_draw_line: %f %f %f %f", x1, y1, x2, y2);
-
- if (x1 == x2 && y1 == y2) {
- /* don't draw degenerate lines */
- G_debug(3, "Skipping zero-length line");
- return;
- }
-
- cairo_move_to(cairo, x1, y1);
- cairo_line_to(cairo, x2, y2);
- cairo_stroke(cairo);
- ca.modified = 1;
-
- return;
-}
Deleted: grass/trunk/lib/cairodriver/Draw_point.c
===================================================================
--- grass/trunk/lib/cairodriver/Draw_point.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Draw_point.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,36 +0,0 @@
-/*!
- \file cairodriver/Draw_point.c
-
- \brief GRASS cairo display driver - draw point
-
- (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
-
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
-
- \author Lars Ahlzen <lars ahlzen.com> (original contibutor)
- \author Glynn Clements
-*/
-
-#include "cairodriver.h"
-
-#define POINTSIZE 1.0
-#define HALFPOINTSIZE (0.5*POINTSIZE)
-
-/*!
- \brief Draw point
-
- \param x,y point coordinates
-*/
-void Cairo_draw_point(double x, double y)
-{
- G_debug(3, "Cairo_draw_point: %f %f", x, y);
-
- cairo_rectangle(cairo,
- x - HALFPOINTSIZE, y - HALFPOINTSIZE,
- POINTSIZE, POINTSIZE);
- cairo_fill(cairo);
- ca.modified = 1;
-
- return;
-}
Modified: grass/trunk/lib/cairodriver/Driver.c
===================================================================
--- grass/trunk/lib/cairodriver/Driver.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Driver.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -32,19 +32,21 @@
drv.Graph_set = Cairo_Graph_set;
drv.Graph_close = Cairo_Graph_close;
drv.Line_width = Cairo_Line_width;
- drv.Polydots = Cairo_Polydots;
- drv.Polyline = Cairo_Polyline;
- drv.Polygon = Cairo_Polygon;
drv.Set_window = Cairo_Set_window;
- drv.Begin_scaled_raster = Cairo_begin_scaled_raster;
- drv.Scaled_raster = Cairo_scaled_raster;
- drv.End_scaled_raster = Cairo_end_scaled_raster;
- drv.color_rgb = Cairo_color_rgb;
- drv.draw_line = Cairo_draw_line;
- drv.draw_point = Cairo_draw_point;
- drv.draw_bitmap = Cairo_draw_bitmap;
- drv.draw_text = Cairo_draw_text;
- drv.text_box = Cairo_text_box;
+ drv.Begin_raster = Cairo_begin_raster;
+ drv.Raster = Cairo_raster;
+ drv.End_raster = Cairo_end_raster;
+ drv.Begin = Cairo_Begin;
+ drv.Move = Cairo_Move;
+ drv.Cont = Cairo_Cont;
+ drv.Close = Cairo_Close;
+ drv.Stroke = Cairo_Stroke;
+ drv.Fill = Cairo_Fill;
+ drv.Point = Cairo_Point;
+ drv.Color = Cairo_Color;
+ drv.Bitmap = Cairo_Bitmap;
+ drv.Text = Cairo_Text;
+ drv.Text_box = Cairo_text_box;
drv.Set_font = Cairo_set_font;
drv.Font_list = Cairo_font_list;
drv.Font_info = Cairo_font_info;
Deleted: grass/trunk/lib/cairodriver/Poly.c
===================================================================
--- grass/trunk/lib/cairodriver/Poly.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Poly.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,74 +0,0 @@
-/*!
- \file cairodriver/Poly.c
-
- \brief GRASS cairo display driver - draw polygon/polyline
-
- (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
-
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
-
- \author Lars Ahlzen <lars ahlzen.com> (original contibutor)
- \author Glynn Clements
-*/
-
-#include "cairodriver.h"
-
-static void do_polygon(const double *xarray, const double *yarray, int count)
-{
- int i;
-
- cairo_move_to(cairo, xarray[0], yarray[0]);
- for (i = 1; i < count; i++)
- cairo_line_to(cairo, xarray[i], yarray[i]);
-}
-
-/*!
- \brief Draw polygon (filled)
-
- \param xarray,yarray array of x/y coordinates
- \param count number of points
-*/
-void Cairo_Polygon(const double *xarray, const double *yarray, int count)
-{
- G_debug(3, "Cairo_Polygon (%d points)", count);
- do_polygon(xarray, yarray, count);
- cairo_fill(cairo);
- ca.modified = 1;
-
- return;
-}
-
-/*!
- \brief Draw polyline
-
- \param xarray,yarray array of x/y coordinates
- \param count number of points
-*/
-void Cairo_Polyline(const double *xarray, const double *yarray, int count)
-{
- G_debug(3, "Cairo_Polyline (%d points)", count);
- do_polygon(xarray, yarray, count);
- cairo_stroke(cairo);
- ca.modified = 1;
-
- return;
-}
-
-/*!
- \brief Draw polyline points
-
- \param xarray,yarray array of x/y coordinates
- \param count number of points
-*/
-void Cairo_Polydots(const double *xarray, const double *yarray, int count)
-{
- int i;
-
- G_debug(3, "Cairo_Polydots (%d points)", count);
- for (i = 1; i < count; i++)
- Cairo_draw_point(xarray[0], yarray[0]);
- ca.modified = 1;
-
- return;
-}
Modified: grass/trunk/lib/cairodriver/Raster.c
===================================================================
--- grass/trunk/lib/cairodriver/Raster.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Raster.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -32,9 +32,9 @@
\param s
\param d
*/
-void Cairo_begin_scaled_raster(int mask, int s[2][2], double d[2][2])
+void Cairo_begin_raster(int mask, int s[2][2], double d[2][2])
{
- G_debug(1, "Cairo_begin_scaled_raster: %d, %d %d %d %d, %f %f %f %f",
+ G_debug(1, "Cairo_begin_raster: %d, %d %d %d %d, %f %f %f %f",
mask,
s[0][0], s[0][1], s[1][0], s[1][1],
d[0][0], d[0][1], d[1][0], d[1][1]);
@@ -65,12 +65,10 @@
/* create source surface */
src_surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, src_w, src_h);
if (cairo_surface_status(src_surf) != CAIRO_STATUS_SUCCESS)
- G_fatal_error(_("Cairo_begin_scaled_raster: Failed to create surface"));
+ G_fatal_error(_("Cairo_begin_raster: Failed to create surface"));
src_data = cairo_image_surface_get_data(src_surf);
src_stride = cairo_image_surface_get_stride(src_surf);
-
- return;
}
/*!
@@ -82,15 +80,15 @@
\return next row
*/
-int Cairo_scaled_raster(int n, int row,
- const unsigned char *red, const unsigned char *grn,
- const unsigned char *blu, const unsigned char *nul)
+int Cairo_raster(int n, int row,
+ const unsigned char *red, const unsigned char *grn,
+ const unsigned char *blu, const unsigned char *nul)
{
unsigned int *dst =
(unsigned int *)(src_data + (row - src_t) * src_stride);
int i;
- G_debug(3, "Cairo_scaled_raster: %d %d", n, row);
+ G_debug(3, "Cairo_raster: %d %d", n, row);
for (i = 0; i < n; i++) {
unsigned int r = red[i];
@@ -108,9 +106,9 @@
/*!
\brief Finish drawing raster
*/
-void Cairo_end_scaled_raster(void)
+void Cairo_end_raster(void)
{
- G_debug(1, "Cairo_end_scaled_raster");
+ G_debug(1, "Cairo_end_raster");
/* paint source surface onto dstination (scaled) */
cairo_save(cairo);
@@ -124,6 +122,4 @@
/* cleanup */
cairo_surface_destroy(src_surf);
ca.modified = 1;
-
- return;
}
Modified: grass/trunk/lib/cairodriver/Text.c
===================================================================
--- grass/trunk/lib/cairodriver/Text.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/Text.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -101,7 +101,7 @@
\param str string to be drawn
*/
-void Cairo_draw_text(const char *str)
+void Cairo_Text(const char *str)
{
char *utf8 = convert(str);
@@ -116,8 +116,6 @@
G_free(utf8);
ca.modified = 1;
-
- return;
}
/*
@@ -144,8 +142,6 @@
*r = cur_x + ext.x_bearing + ext.width;
*t = cur_y + ext.y_bearing;
*b = cur_y + ext.y_bearing + ext.height;
-
- return;
}
static void set_font_toy(const char *name)
@@ -247,8 +243,6 @@
#else
set_font_toy(name);
#endif
-
- return;
}
static void font_list_toy(char ***list, int *count, int verbose)
@@ -281,8 +275,6 @@
{
font_list(list, count, 0);
font_list_toy(list, count, 0);
-
- return;
}
/*!
@@ -295,7 +287,5 @@
{
font_list(list, count, 1);
font_list_toy(list, count, 1);
-
- return;
}
Modified: grass/trunk/lib/cairodriver/cairodriver.h
===================================================================
--- grass/trunk/lib/cairodriver/cairodriver.h 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/cairodriver/cairodriver.h 2008-12-04 16:47:24 UTC (rev 34720)
@@ -67,21 +67,23 @@
extern void Cairo_Graph_close(void);
extern void Cairo_Box(double, double, double, double);
extern void Cairo_Set_window(double, double, double, double);
-extern void Cairo_draw_line(double, double, double, double);
-extern void Cairo_draw_bitmap(int, int, int, const unsigned char *);
-extern void Cairo_draw_point(double, double);
-extern void Cairo_color_rgb(int, int, int);
+extern void Cairo_Bitmap(int, int, int, const unsigned char *);
+extern void Cairo_Color(int, int, int);
extern void Cairo_Erase(void);
-extern void Cairo_begin_scaled_raster(int, int[2][2], double[2][2]);
-extern int Cairo_scaled_raster(int, int,
- const unsigned char *, const unsigned char *,
- const unsigned char *, const unsigned char *);
-extern void Cairo_end_scaled_raster(void);
+extern void Cairo_begin_raster(int, int[2][2], double[2][2]);
+extern int Cairo_raster(int, int,
+ const unsigned char *, const unsigned char *,
+ const unsigned char *, const unsigned char *);
+extern void Cairo_end_raster(void);
+extern void Cairo_Begin(void);
+extern void Cairo_Move(double, double);
+extern void Cairo_Cont(double, double);
+extern void Cairo_Close(void);
+extern void Cairo_Stroke(void);
+extern void Cairo_Fill(void);
+extern void Cairo_Point(double, double);
extern void Cairo_Line_width(double);
-extern void Cairo_Polygon(const double *, const double *, int);
-extern void Cairo_Polyline(const double *, const double *, int);
-extern void Cairo_Polydots(const double *, const double *, int);
-extern void Cairo_draw_text(const char *);
+extern void Cairo_Text(const char *);
extern void Cairo_text_box(const char *, double *, double *, double *, double *);
extern void Cairo_set_font(const char *);
extern void Cairo_font_list(char ***, int *);
Deleted: grass/trunk/lib/driver/Bitmap.c
===================================================================
--- grass/trunk/lib/driver/Bitmap.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Bitmap.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,7 +0,0 @@
-#include "driver.h"
-#include "driverlib.h"
-
-void COM_Bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
-{
- DRV_draw_bitmap(ncols, nrows, threshold, buf);
-}
Modified: grass/trunk/lib/driver/Color.c
===================================================================
--- grass/trunk/lib/driver/Color.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Color.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -4,8 +4,8 @@
void COM_Color_RGB(unsigned char r, unsigned char g, unsigned char b)
{
- if (driver->color_rgb)
- (*driver->color_rgb)(r, g, b);
+ if (driver->Color)
+ (*driver->Color)(r, g, b);
}
void COM_Standard_color(int number)
Deleted: grass/trunk/lib/driver/Cont.c
===================================================================
--- grass/trunk/lib/driver/Cont.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Cont.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,8 +0,0 @@
-#include "driver.h"
-#include "driverlib.h"
-
-void COM_Line_abs(double x1, double y1, double x2, double y2)
-{
- DRV_draw_line(x1, y1, x2, y2);
-}
-
Modified: grass/trunk/lib/driver/Draw.c
===================================================================
--- grass/trunk/lib/driver/Draw.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Draw.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,22 +1,60 @@
#include "driver.h"
#include "driverlib.h"
+void COM_Bitmap(int ncols, int nrows, int threshold,
+ const unsigned char *buf)
+{
+ if (driver->Bitmap)
+ (*driver->Bitmap) (ncols, nrows, threshold, buf);
+}
-void DRV_draw_bitmap(int ncols, int nrows, int threshold,
- const unsigned char *buf)
+void COM_Line_abs(double x0, double y0, double x1, double y1)
{
- if (driver->draw_bitmap)
- (*driver->draw_bitmap) (ncols, nrows, threshold, buf);
+ COM_Begin();
+ COM_Move(x0, y0);
+ COM_Cont(x1, y1);
+ COM_Stroke();
}
-void DRV_draw_line(double x0, double y0, double x1, double y1)
+void COM_Begin(void)
{
- if (driver->draw_line)
- (*driver->draw_line) (x0, y0, x1, y1);
+ if (driver->Begin)
+ (*driver->Begin)();
}
-void DRV_draw_point(double x, double y)
+void COM_Move(double x, double y)
{
- if (driver->draw_point)
- (*driver->draw_point) (x, y);
+ if (driver->Move)
+ (*driver->Move)(x, y);
}
+
+void COM_Cont(double x, double y)
+{
+ if (driver->Cont)
+ (*driver->Cont)(x, y);
+}
+
+void COM_Close(void)
+{
+ if (driver->Close)
+ (*driver->Close)();
+}
+
+void COM_Stroke(void)
+{
+ if (driver->Stroke)
+ (*driver->Stroke)();
+}
+
+void COM_Fill(void)
+{
+ if (driver->Fill)
+ (*driver->Fill)();
+}
+
+void COM_Point(double x, double y)
+{
+ if (driver->Point)
+ (*driver->Point)(x, y);
+}
+
Modified: grass/trunk/lib/driver/Get_t_box.c
===================================================================
--- grass/trunk/lib/driver/Get_t_box.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Get_t_box.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -3,8 +3,8 @@
void COM_Get_text_box(const char *text, double *t, double *b, double *l, double *r)
{
- if (driver->text_box) {
- (*driver->text_box)(text, t, b, l, r);
+ if (driver->Text_box) {
+ (*driver->Text_box)(text, t, b, l, r);
return;
}
Modified: grass/trunk/lib/driver/Polydots.c
===================================================================
--- grass/trunk/lib/driver/Polydots.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Polydots.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -5,12 +5,7 @@
{
int i;
- if (driver->Polydots) {
- (*driver->Polydots) (xarray, yarray, number);
- return;
- }
-
for (i = 0; i < number; i++)
- COM_Line_abs(xarray[i], yarray[i], xarray[i], yarray[i]);
+ COM_Point(xarray[i], yarray[i]);
}
Modified: grass/trunk/lib/driver/Polygon.c
===================================================================
--- grass/trunk/lib/driver/Polygon.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Polygon.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -5,7 +5,13 @@
void COM_Polygon_abs(const double *xarray, const double *yarray, int number)
{
- if (driver->Polygon)
- (*driver->Polygon) (xarray, yarray, number);
+ int i;
+
+ COM_Begin();
+ COM_Move(xarray[0], yarray[0]);
+ for (i = 1; i < number; i++)
+ COM_Cont(xarray[i], yarray[i]);
+ COM_Close();
+ COM_Fill();
}
Modified: grass/trunk/lib/driver/Polyline.c
===================================================================
--- grass/trunk/lib/driver/Polyline.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Polyline.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -5,12 +5,10 @@
{
int i;
- if (driver->Polyline) {
- (*driver->Polyline) (xarray, yarray, number);
- return;
- }
-
+ COM_Begin();
+ COM_Move(xarray[0], yarray[0]);
for (i = 1; i < number; i++)
- COM_Line_abs(xarray[i-1], yarray[i-1], xarray[i], yarray[i]);
+ COM_Cont(xarray[i], yarray[i]);
+ COM_Stroke();
}
Modified: grass/trunk/lib/driver/Raster.c
===================================================================
--- grass/trunk/lib/driver/Raster.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Raster.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -10,24 +10,24 @@
******************************************************************************
*/
-void COM_begin_scaled_raster(int mask, int src[2][2], double dst[2][2])
+void COM_begin_raster(int mask, int src[2][2], double dst[2][2])
{
- if (driver->Begin_scaled_raster)
- (*driver->Begin_scaled_raster) (mask, src, dst);
+ if (driver->Begin_raster)
+ (*driver->Begin_raster) (mask, src, dst);
}
-int COM_scaled_raster(int n, int row,
- const unsigned char *red, const unsigned char *grn,
- const unsigned char *blu, const unsigned char *nul)
+int COM_raster(int n, int row,
+ const unsigned char *red, const unsigned char *grn,
+ const unsigned char *blu, const unsigned char *nul)
{
- if (driver->Scaled_raster)
- return (*driver->Scaled_raster) (n, row, red, grn, blu, nul);
+ if (driver->Raster)
+ return (*driver->Raster) (n, row, red, grn, blu, nul);
return -1;
}
-void COM_end_scaled_raster(void)
+void COM_end_raster(void)
{
- if (driver->End_scaled_raster)
- (*driver->End_scaled_raster) ();
+ if (driver->End_raster)
+ (*driver->End_raster) ();
}
Modified: grass/trunk/lib/driver/Text.c
===================================================================
--- grass/trunk/lib/driver/Text.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/Text.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -3,8 +3,8 @@
void COM_Text(const char *text)
{
- if (driver->draw_text) {
- (*driver->draw_text) (text);
+ if (driver->Text) {
+ (*driver->Text)(text);
return;
}
Modified: grass/trunk/lib/driver/driver.h
===================================================================
--- grass/trunk/lib/driver/driver.h 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/driver.h 2008-12-04 16:47:24 UTC (rev 34720)
@@ -25,23 +25,26 @@
int (*Graph_set)(void);
void (*Graph_close)(void);
void (*Line_width)(double);
- void (*Polydots)(const double *, const double *, int);
- void (*Polyline)(const double *, const double *, int);
- void (*Polygon)(const double *, const double *, int);
void (*Set_window)(double, double, double, double);
- void (*Begin_scaled_raster)(int, int[2][2], double[2][2]);
- int (*Scaled_raster)(int, int,
- const unsigned char *,
- const unsigned char *,
- const unsigned char *, const unsigned char *);
- void (*End_scaled_raster)(void);
+ void (*Begin_raster)(int, int[2][2], double[2][2]);
+ int (*Raster)(int, int,
+ const unsigned char *,
+ const unsigned char *,
+ const unsigned char *,
+ const unsigned char *);
+ void (*End_raster)(void);
+ void (*Begin)(void);
+ void (*Move)(double, double);
+ void (*Cont)(double, double);
+ void (*Close)(void);
+ void (*Stroke)(void);
+ void (*Fill)(void);
+ void (*Point)(double, double);
- void (*color_rgb)(int, int, int);
- void (*draw_line)(double, double, double, double);
- void (*draw_point)(double, double);
- void (*draw_bitmap)(int, int, int, const unsigned char *);
- void (*draw_text)(const char *);
- void (*text_box)(const char *, double *, double *, double *, double *);
+ void (*Color)(int, int, int);
+ void (*Bitmap)(int, int, int, const unsigned char *);
+ void (*Text)(const char *);
+ void (*Text_box)(const char *, double *, double *, double *, double *);
void (*Set_font)(const char *);
void (*Font_list)(char ***, int *);
void (*Font_info)(char ***, int *);
@@ -54,9 +57,6 @@
/* Commands */
-/* Bitmap.c */
-extern void COM_Bitmap(int, int, int, const unsigned char *);
-
/* Box.c */
extern void COM_Box_abs(double, double, double, double);
@@ -64,9 +64,6 @@
extern void COM_Color_RGB(unsigned char, unsigned char, unsigned char);
extern void COM_Standard_color(int);
-/* Cont.c */
-extern void COM_Line_abs(double, double, double, double);
-
/* Erase.c */
extern void COM_Erase(void);
@@ -99,11 +96,11 @@
extern void COM_Polyline_abs(const double *, const double *, int);
/* Raster.c */
-extern void COM_begin_scaled_raster(int, int[2][2], double[2][2]);
-extern int COM_scaled_raster(int, int, const unsigned char *,
- const unsigned char *, const unsigned char *,
- const unsigned char *);
-extern void COM_end_scaled_raster(void);
+extern void COM_begin_raster(int, int[2][2], double[2][2]);
+extern int COM_raster(int, int, const unsigned char *,
+ const unsigned char *, const unsigned char *,
+ const unsigned char *);
+extern void COM_end_raster(void);
/* Set_window.c */
extern void COM_Set_window(double, double, double, double);
@@ -119,8 +116,14 @@
/* Driver Operations */
/* Draw.c */
-extern void DRV_draw_bitmap(int, int, int, const unsigned char *);
-extern void DRV_draw_line(double, double, double, double);
-extern void DRV_draw_point(double, double);
+extern void COM_Bitmap(int, int, int, const unsigned char *);
+extern void COM_Line_abs(double, double, double, double);
+extern void COM_Begin(void);
+extern void COM_Move(double, double);
+extern void COM_Cont(double, double);
+extern void COM_Close(void);
+extern void COM_Stroke(void);
+extern void COM_Fill(void);
+extern void COM_Point(double, double);
#endif /* _DRIVER_H */
Modified: grass/trunk/lib/driver/driverlib.h
===================================================================
--- grass/trunk/lib/driver/driverlib.h 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/driverlib.h 2008-12-04 16:47:24 UTC (rev 34720)
@@ -38,3 +38,23 @@
extern struct GFONT_CAP *parse_freetypecap(void);
extern void free_freetypecap(struct GFONT_CAP *);
extern void free_font_list(char **, int);
+
+/* path.c */
+struct path {
+ double *px, *py;
+ int count;
+ int alloc;
+
+ int cur_offset;
+ int *offsets;
+ int o_count;
+ int o_alloc;
+};
+
+void path_begin(struct path *);
+void path_move(struct path *, double, double);
+void path_cont(struct path *, double, double);
+void path_close(struct path *);
+void path_fill(struct path *, void (*)(const double *, const double *, int));
+void path_stroke(struct path *, void (*)(double, double, double, double));
+void path_reset(struct path *);
Added: grass/trunk/lib/driver/path.c
===================================================================
--- grass/trunk/lib/driver/path.c (rev 0)
+++ grass/trunk/lib/driver/path.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -0,0 +1,92 @@
+
+#include <grass/gis.h>
+#include "driverlib.h"
+
+static void begin_subpath(struct path *p)
+{
+ if (p->o_count >= p->o_alloc) {
+ p->o_alloc += 100;
+ p->offsets = G_realloc(p->offsets, p->o_alloc * sizeof(int));
+ }
+
+ p->offsets[p->o_count++] = p->count;
+ p->cur_offset = p->count;
+}
+
+static void add_point(struct path *p, double x, double y)
+{
+ if (p->count >= p->alloc) {
+ p->alloc = p->alloc ? p->alloc * 2 : 100;
+ p->px = G_realloc(p->px, p->alloc * sizeof(double));
+ p->py = G_realloc(p->py, p->alloc * sizeof(double));
+ }
+
+ p->px[p->count] = x;
+ p->py[p->count] = y;
+ p->count++;
+}
+
+void path_begin(struct path *p)
+{
+ p->count = 0;
+ p->o_count = 0;
+ begin_subpath(p);
+}
+
+void path_move(struct path *p, double x, double y)
+{
+ if (p->count > p->cur_offset)
+ begin_subpath(p);
+ add_point(p, x, y);
+}
+
+void path_cont(struct path *p, double x, double y)
+{
+ add_point(p, x, y);
+}
+
+void path_close(struct path *p)
+{
+ if (p->count <= p->cur_offset + 2)
+ return;
+
+ add_point(p, p->px[p->cur_offset], p->py[p->cur_offset]);
+ begin_subpath(p);
+}
+
+void path_fill(struct path *p, void (*polygon)(const double *, const double *, int))
+{
+ int i;
+
+ if (p->count > p->cur_offset)
+ begin_subpath(p);
+
+ for (i = 0; i < p->o_count - 1; i++) {
+ int start = p->offsets[i];
+ int end = p->offsets[i+1];
+ (*polygon)(&p->px[start], &p->py[start], end - start);
+ }
+
+ path_reset(p);
+}
+
+void path_stroke(struct path *p, void (*line)(double, double, double, double))
+{
+ int i, j;
+
+ if (p->count > p->cur_offset)
+ begin_subpath(p);
+
+ for (i = 0; i < p->o_count - 1; i++)
+ for (j = p->offsets[i] + 1; j < p->offsets[i+1]; j++)
+ (*line)(p->px[j-1], p->py[j-1], p->px[j], p->py[j]);
+
+ path_reset(p);
+}
+
+void path_reset(struct path *p)
+{
+ p->count = 0;
+ p->o_count = 0;
+}
+
Modified: grass/trunk/lib/driver/text3.c
===================================================================
--- grass/trunk/lib/driver/text3.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/driver/text3.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -268,7 +268,7 @@
buf[j * w + i] = sbuf[offset + j * bw + i];
COM_Pos_abs(x1, y1);
- DRV_draw_bitmap(w, h, 128, buf);
+ COM_Bitmap(w, h, 128, buf);
}
#endif
Modified: grass/trunk/lib/htmldriver/Box.c
===================================================================
--- grass/trunk/lib/htmldriver/Box.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/htmldriver/Box.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -2,13 +2,11 @@
void HTML_Box(double x1, double y1, double x2, double y2)
{
- double x[4], y[4];
-
- x[0] = x1; y[0] = y1;
- x[1] = x1; y[1] = y2;
- x[2] = x2; y[2] = y2;
- x[3] = x2; y[3] = y1;
-
- HTML_Polygon(x, y, 4);
+ HTML_Begin();
+ HTML_Move(x1, y1);
+ HTML_Cont(x1, y2);
+ HTML_Cont(x2, y2);
+ HTML_Cont(x2, y1);
+ HTML_Fill();
}
Added: grass/trunk/lib/htmldriver/Draw.c
===================================================================
--- grass/trunk/lib/htmldriver/Draw.c (rev 0)
+++ grass/trunk/lib/htmldriver/Draw.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -0,0 +1,37 @@
+
+#include <grass/gis.h>
+#include "driverlib.h"
+#include "htmlmap.h"
+
+static struct path path;
+
+void HTML_Begin(void)
+{
+ path_begin(&path);
+}
+
+void HTML_Move(double x, double y)
+{
+ path_move(&path, x, y);
+}
+
+void HTML_Cont(double x, double y)
+{
+ path_cont(&path, x, y);
+}
+
+void HTML_Close(void)
+{
+ path_close(&path);
+}
+
+void HTML_Fill(void)
+{
+ path_fill(&path, html_polygon);
+}
+
+void HTML_Stroke(void)
+{
+ path_reset(&path);
+}
+
Modified: grass/trunk/lib/htmldriver/Driver.c
===================================================================
--- grass/trunk/lib/htmldriver/Driver.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/htmldriver/Driver.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -30,19 +30,21 @@
drv.Graph_set = HTML_Graph_set;
drv.Graph_close = HTML_Graph_close;
drv.Line_width = NULL;
- drv.Polydots = NULL;
- drv.Polyline = NULL;
- drv.Polygon = HTML_Polygon;
drv.Set_window = NULL;
- drv.Begin_scaled_raster = NULL;
- drv.Scaled_raster = NULL;
- drv.End_scaled_raster = NULL;
- drv.color_rgb = NULL;
- drv.draw_line = NULL;
- drv.draw_point = NULL;
- drv.draw_bitmap = NULL;
- drv.draw_text = HTML_Text;
- drv.text_box = NULL;
+ drv.Begin_raster = NULL;
+ drv.Raster = NULL;
+ drv.End_raster = NULL;
+ drv.Begin = HTML_Begin;
+ drv.Move = HTML_Move;
+ drv.Cont = HTML_Cont;
+ drv.Close = HTML_Close;
+ drv.Stroke = HTML_Stroke;
+ drv.Fill = HTML_Fill;
+ drv.Point = NULL;
+ drv.Color = NULL;
+ drv.Bitmap = NULL;
+ drv.Text = HTML_Text;
+ drv.Text_box = NULL;
drv.Set_font = NULL;
drv.Font_list = NULL;
drv.Font_info = NULL;
Modified: grass/trunk/lib/htmldriver/Polygon.c
===================================================================
--- grass/trunk/lib/htmldriver/Polygon.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/htmldriver/Polygon.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -51,7 +51,7 @@
}
-void HTML_Polygon(const double *px, const double *py, int n)
+void html_polygon(const double *px, const double *py, int n)
{
struct MapPoly *new;
int i;
Modified: grass/trunk/lib/htmldriver/htmlmap.h
===================================================================
--- grass/trunk/lib/htmldriver/htmlmap.h 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/htmldriver/htmlmap.h 2008-12-04 16:47:24 UTC (rev 34720)
@@ -38,6 +38,14 @@
extern struct html_state html;
+/* Draw.c */
+extern void HTML_Begin(void);
+extern void HTML_Move(double, double);
+extern void HTML_Cont(double, double);
+extern void HTML_Close(void);
+extern void HTML_Fill(void);
+extern void HTML_Stroke(void);
+
/* Driver.c */
extern const struct driver *HTML_Driver(void);
@@ -51,7 +59,7 @@
extern void HTML_Box(double, double, double, double);
/* Polygon.c */
-extern void HTML_Polygon(const double *, const double *, int);
+extern void html_polygon(const double *, const double *, int);
/* Text.c */
extern void HTML_Text(const char *);
Modified: grass/trunk/lib/pngdriver/Color.c
===================================================================
--- grass/trunk/lib/pngdriver/Color.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Color.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -11,5 +11,5 @@
void PNG_color_rgb(int r, int g, int b)
{
- png.current_color = get_color(r, g, b, 0);
+ png.current_color = png_get_color(r, g, b, 0);
}
Modified: grass/trunk/lib/pngdriver/Color_table.c
===================================================================
--- grass/trunk/lib/pngdriver/Color_table.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Color_table.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -70,7 +70,7 @@
}
}
-void init_color_table(void)
+void png_init_color_table(void)
{
if (png.true_color)
init_colors_rgb();
@@ -109,7 +109,7 @@
}
-void get_pixel(unsigned int pixel, int *r, int *g, int *b, int *a)
+void png_get_pixel(unsigned int pixel, int *r, int *g, int *b, int *a)
{
if (png.true_color)
get_pixel_rgb(pixel, r, g, b, a);
@@ -117,7 +117,7 @@
get_pixel_indexed(pixel, r, g, b, a);
}
-unsigned int get_color(int r, int g, int b, int a)
+unsigned int png_get_color(int r, int g, int b, int a)
{
return png.true_color
? get_color_rgb(r, g, b, a)
Added: grass/trunk/lib/pngdriver/Draw.c
===================================================================
--- grass/trunk/lib/pngdriver/Draw.c (rev 0)
+++ grass/trunk/lib/pngdriver/Draw.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -0,0 +1,49 @@
+/*!
+ \file pngdriver/Draw.c
+
+ \brief GRASS PNG display driver
+
+ (C) 2008 by Glynn Clements and the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Glynn Clements
+*/
+
+#include <grass/gis.h>
+#include "driverlib.h"
+#include "pngdriver.h"
+
+static struct path path;
+
+void PNG_Begin(void)
+{
+ path_begin(&path);
+}
+
+void PNG_Move(double x, double y)
+{
+ path_move(&path, x, y);
+}
+
+void PNG_Cont(double x, double y)
+{
+ path_cont(&path, x, y);
+}
+
+void PNG_Close(void)
+{
+ path_close(&path);
+}
+
+void PNG_Stroke(void)
+{
+ path_stroke(&path, png_draw_line);
+}
+
+void PNG_Fill(void)
+{
+ path_fill(&path, png_polygon);
+}
+
Modified: grass/trunk/lib/pngdriver/Draw_bitmap.c
===================================================================
--- grass/trunk/lib/pngdriver/Draw_bitmap.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Draw_bitmap.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -45,7 +45,7 @@
int r1, g1, b1, a1;
int i, j;
- get_pixel(png.current_color, &r1, &g1, &b1, &a1);
+ png_get_pixel(png.current_color, &r1, &g1, &b1, &a1);
for (j = j0; j < j1; j++) {
int y = cur_y + j;
@@ -57,14 +57,14 @@
unsigned int a0, r0, g0, b0;
unsigned int a, r, g, b;
- get_pixel(*p, &r0, &g0, &b0, &a0);
+ png_get_pixel(*p, &r0, &g0, &b0, &a0);
a = (a0 * (255 - k) + a1 * k) / 255;
r = (r0 * (255 - k) + r1 * k) / 255;
g = (g0 * (255 - k) + g1 * k) / 255;
b = (b0 * (255 - k) + b1 * k) / 255;
- *p = get_color(r, g, b, a);
+ *p = png_get_color(r, g, b, a);
}
}
}
Modified: grass/trunk/lib/pngdriver/Draw_line.c
===================================================================
--- grass/trunk/lib/pngdriver/Draw_line.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Draw_line.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -62,7 +62,7 @@
}
}
-void PNG_draw_line(double x1, double y1, double x2, double y2)
+void png_draw_line(double x1, double y1, double x2, double y2)
{
double ax[4], ay[4];
double k = png.linewidth / 2;
@@ -87,6 +87,6 @@
ax[3] = x2; ay[3] = y2 - k;
}
- PNG_Polygon(ax, ay, 4);
+ png_polygon(ax, ay, 4);
}
Modified: grass/trunk/lib/pngdriver/Driver.c
===================================================================
--- grass/trunk/lib/pngdriver/Driver.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Driver.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -32,19 +32,21 @@
drv.Graph_set = PNG_Graph_set;
drv.Graph_close = PNG_Graph_close;
drv.Line_width = PNG_Line_width;
- drv.Polydots = NULL;
- drv.Polyline = NULL;
- drv.Polygon = PNG_Polygon;
drv.Set_window = PNG_Set_window;
- drv.Begin_scaled_raster = PNG_begin_scaled_raster;
- drv.Scaled_raster = PNG_scaled_raster;
- drv.End_scaled_raster = NULL;
- drv.color_rgb = PNG_color_rgb;
- drv.draw_line = PNG_draw_line;
- drv.draw_point = PNG_draw_point;
- drv.draw_bitmap = PNG_draw_bitmap;
- drv.draw_text = NULL;
- drv.text_box = NULL;
+ drv.Begin_raster = PNG_begin_raster;
+ drv.Raster = PNG_raster;
+ drv.End_raster = NULL;
+ drv.Begin = PNG_Begin;
+ drv.Move = PNG_Move;
+ drv.Cont = PNG_Cont;
+ drv.Close = PNG_Close;
+ drv.Stroke = PNG_Stroke;
+ drv.Fill = PNG_Fill;
+ drv.Point = PNG_Point;
+ drv.Color = PNG_color_rgb;
+ drv.Bitmap = PNG_draw_bitmap;
+ drv.Text = NULL;
+ drv.Text_box = NULL;
drv.Set_font = NULL;
drv.Font_list = NULL;
drv.Font_info = NULL;
Modified: grass/trunk/lib/pngdriver/Graph_set.c
===================================================================
--- grass/trunk/lib/pngdriver/Graph_set.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Graph_set.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -99,19 +99,19 @@
p = getenv("GRASS_TRANSPARENT");
png.has_alpha = p && strcmp(p, "TRUE") == 0;
- init_color_table();
+ png_init_color_table();
p = getenv("GRASS_BACKGROUNDCOLOR");
if (p && *p && sscanf(p, "%02x%02x%02x", &red, &grn, &blu) == 3)
- png.background = get_color(red, grn, blu, png.has_alpha ? 255 : 0);
+ png.background = png_get_color(red, grn, blu, png.has_alpha ? 255 : 0);
else {
/* 0xffffff = white, 0x000000 = black */
if (strcmp(DEFAULT_FG_COLOR, "white") == 0)
/* foreground: white, background: black */
- png.background = get_color(0, 0, 0, png.has_alpha ? 255 : 0);
+ png.background = png_get_color(0, 0, 0, png.has_alpha ? 255 : 0);
else
/* foreground: black, background: white */
- png.background = get_color(255, 255, 255, png.has_alpha ? 255 : 0);
+ png.background = png_get_color(255, 255, 255, png.has_alpha ? 255 : 0);
}
G_verbose_message(_("PNG: collecting to file <%s>"), png.file_name);
Added: grass/trunk/lib/pngdriver/Point.c
===================================================================
--- grass/trunk/lib/pngdriver/Point.c (rev 0)
+++ grass/trunk/lib/pngdriver/Point.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -0,0 +1,12 @@
+#include <grass/gis.h>
+#include "pngdriver.h"
+
+void PNG_Point(double x, double y)
+{
+ static double point_size = 1.0;
+ double half_point_size = point_size / 2;
+
+ PNG_Box(x - half_point_size, y - half_point_size,
+ point_size, point_size);
+}
+
Modified: grass/trunk/lib/pngdriver/Polygon.c
===================================================================
--- grass/trunk/lib/pngdriver/Polygon.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Polygon.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -123,7 +123,7 @@
line(p, n, y);
}
-void PNG_Polygon(const double *xarray, const double *yarray, int count)
+void png_polygon(const double *xarray, const double *yarray, int count)
{
static struct point *points;
static int max_points;
Modified: grass/trunk/lib/pngdriver/Raster.c
===================================================================
--- grass/trunk/lib/pngdriver/Raster.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/Raster.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -57,7 +57,7 @@
trans = G_realloc(trans, nalloc * sizeof(int));
}
-void PNG_begin_scaled_raster(int mask, int s[2][2], double fd[2][2])
+void PNG_begin_raster(int mask, int s[2][2], double fd[2][2])
{
int d[2][2];
int i;
@@ -79,9 +79,9 @@
trans[i] = scale_rev_x(d[0][0] + i);
}
-int PNG_scaled_raster(int n, int row,
- const unsigned char *red, const unsigned char *grn,
- const unsigned char *blu, const unsigned char *nul)
+int PNG_raster(int n, int row,
+ const unsigned char *red, const unsigned char *grn,
+ const unsigned char *blu, const unsigned char *nul)
{
int d_y0 = scale_fwd_y(row + 0);
int d_y1 = scale_fwd_y(row + 1);
@@ -103,7 +103,7 @@
if (masked && nul && nul[j])
continue;
- c = get_color(red[j], grn[j], blu[j], 0);
+ c = png_get_color(red[j], grn[j], blu[j], 0);
for (y = y0; y < y1; y++) {
int yy = d_y0 + y;
Modified: grass/trunk/lib/pngdriver/pngdriver.h
===================================================================
--- grass/trunk/lib/pngdriver/pngdriver.h 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/pngdriver.h 2008-12-04 16:47:24 UTC (rev 34720)
@@ -42,9 +42,11 @@
extern void write_bmp(void);
extern void write_png(void);
-extern void init_color_table(void);
-extern unsigned int get_color(int, int, int, int);
-extern void get_pixel(unsigned int, int *, int *, int *, int *);
+extern void png_init_color_table(void);
+extern unsigned int png_get_color(int, int, int, int);
+extern void png_get_pixel(unsigned int, int *, int *, int *, int *);
+extern void png_draw_line(double, double, double, double);
+extern void png_polygon(const double *, const double *, int);
extern const struct driver *PNG_Driver(void);
@@ -54,15 +56,19 @@
extern void PNG_Graph_close(void);
extern int PNG_Graph_set(void);
extern void PNG_Line_width(double);
-extern void PNG_Polygon(const double *, const double *, int);
-extern void PNG_begin_scaled_raster(int, int[2][2], double[2][2]);
-extern int PNG_scaled_raster(int, int, const unsigned char *,
- const unsigned char *, const unsigned char *,
- const unsigned char *);
+extern void PNG_begin_raster(int, int[2][2], double[2][2]);
+extern int PNG_raster(int, int, const unsigned char *,
+ const unsigned char *, const unsigned char *,
+ const unsigned char *);
+extern void PNG_Begin(void);
+extern void PNG_Move(double, double);
+extern void PNG_Cont(double, double);
+extern void PNG_Close(void);
+extern void PNG_Stroke(void);
+extern void PNG_Fill(void);
+extern void PNG_Point(double, double);
extern void PNG_Set_window(double, double, double, double);
extern void PNG_color_rgb(int, int, int);
extern void PNG_draw_bitmap(int, int, int, const unsigned char *);
-extern void PNG_draw_line(double, double, double, double);
-extern void PNG_draw_point(double, double);
#endif /* __PNGDRIVER_H__ */
Modified: grass/trunk/lib/pngdriver/read_bmp.c
===================================================================
--- grass/trunk/lib/pngdriver/read_bmp.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/read_bmp.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -90,7 +90,7 @@
int g = fgetc(input);
int r = fgetc(input);
int a = fgetc(input);
- unsigned int c = get_color(r, g, b, a);
+ unsigned int c = png_get_color(r, g, b, a);
*p = c;
}
Modified: grass/trunk/lib/pngdriver/read_png.c
===================================================================
--- grass/trunk/lib/pngdriver/read_png.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/read_png.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -100,7 +100,7 @@
int g = *q++;
int b = *q++;
int a = *q++;
- unsigned int c = get_color(r, g, b, a);
+ unsigned int c = png_get_color(r, g, b, a);
*p = c;
}
Modified: grass/trunk/lib/pngdriver/read_ppm.c
===================================================================
--- grass/trunk/lib/pngdriver/read_ppm.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/read_ppm.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -11,7 +11,7 @@
FILE *input;
int x, y;
int i_width, i_height, maxval;
- unsigned int rgb_mask = get_color(255, 255, 255, 0);
+ unsigned int rgb_mask = png_get_color(255, 255, 255, 0);
unsigned int *p;
if (!png.true_color)
@@ -44,7 +44,7 @@
b = b * 255 / maxval;
c &= ~rgb_mask;
- c |= get_color(r, g, b, 0);
+ c |= png_get_color(r, g, b, 0);
*p = c;
}
@@ -59,7 +59,7 @@
FILE *input;
int x, y;
int i_width, i_height, maxval;
- unsigned int rgb_mask = get_color(255, 255, 255, 0);
+ unsigned int rgb_mask = png_get_color(255, 255, 255, 0);
unsigned int *p;
if (!png.true_color)
@@ -92,7 +92,7 @@
k = k * 255 / maxval;
c &= rgb_mask;
- c |= get_color(0, 0, 0, 255 - k);
+ c |= png_get_color(0, 0, 0, 255 - k);
*p = c;
}
Modified: grass/trunk/lib/pngdriver/write_bmp.c
===================================================================
--- grass/trunk/lib/pngdriver/write_bmp.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/write_bmp.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -67,7 +67,7 @@
unsigned int c = *p;
int r, g, b, a;
- get_pixel(c, &r, &g, &b, &a);
+ png_get_pixel(c, &r, &g, &b, &a);
fputc((unsigned char)b, output);
fputc((unsigned char)g, output);
Modified: grass/trunk/lib/pngdriver/write_png.c
===================================================================
--- grass/trunk/lib/pngdriver/write_png.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/write_png.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -79,7 +79,7 @@
unsigned int c = *p;
int r, g, b, a;
- get_pixel(c, &r, &g, &b, &a);
+ png_get_pixel(c, &r, &g, &b, &a);
*q++ = (png_byte) r;
*q++ = (png_byte) g;
*q++ = (png_byte) b;
Modified: grass/trunk/lib/pngdriver/write_ppm.c
===================================================================
--- grass/trunk/lib/pngdriver/write_ppm.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/pngdriver/write_ppm.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -23,7 +23,7 @@
unsigned int c = *p;
int r, g, b, a;
- get_pixel(c, &r, &g, &b, &a);
+ png_get_pixel(c, &r, &g, &b, &a);
fputc((unsigned char)r, output);
fputc((unsigned char)g, output);
@@ -56,7 +56,7 @@
unsigned int c = *p;
int r, g, b, a;
- get_pixel(c, &r, &g, &b, &a);
+ png_get_pixel(c, &r, &g, &b, &a);
fputc((unsigned char)(255 - a), output);
}
Modified: grass/trunk/lib/psdriver/Color.c
===================================================================
--- grass/trunk/lib/psdriver/Color.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Color.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -2,7 +2,7 @@
#include <grass/gis.h>
#include "psdriver.h"
-void PS_color_rgb(int r, int g, int b)
+void PS_Color(int r, int g, int b)
{
if (ps.true_color)
output("%d %d %d COLOR\n", r, g, b);
Added: grass/trunk/lib/psdriver/Draw.c
===================================================================
--- grass/trunk/lib/psdriver/Draw.c (rev 0)
+++ grass/trunk/lib/psdriver/Draw.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -0,0 +1,50 @@
+/*!
+ \file psdriver/Draw.c
+
+ \brief GRASS PS display driver
+
+ (C) 2007-2008 by Glynn Clements and the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Glynn Clements
+*/
+
+#include "psdriver.h"
+
+void PS_Begin(void)
+{
+ output("NEW\n");
+}
+
+void PS_Move(double x, double y)
+{
+ output("%f %f MOVE\n", x, y);
+}
+
+void PS_Cont(double x, double y)
+{
+ output("%f %f CONT\n", x, y);
+}
+
+void PS_Close(void)
+{
+ output("CLOSE\n");
+}
+
+void PS_Stroke(void)
+{
+ output("STROKE\n");
+}
+
+void PS_Fill(void)
+{
+ output("FILL\n");
+}
+
+void PS_Point(double x, double y)
+{
+ output("%f %f POINT\n", x, y);
+}
+
Modified: grass/trunk/lib/psdriver/Draw_bitmap.c
===================================================================
--- grass/trunk/lib/psdriver/Draw_bitmap.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Draw_bitmap.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,8 +1,8 @@
#include "psdriver.h"
-void PS_draw_bitmap(int ncols, int nrows, int threshold,
- const unsigned char *buf)
+void PS_Bitmap(int ncols, int nrows, int threshold,
+ const unsigned char *buf)
{
int i, j;
Deleted: grass/trunk/lib/psdriver/Draw_line.c
===================================================================
--- grass/trunk/lib/psdriver/Draw_line.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Draw_line.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,7 +0,0 @@
-
-#include "psdriver.h"
-
-void PS_draw_line(double x1, double y1, double x2, double y2)
-{
- output("%f %f %f %f LINE\n", x1, y1, x2, y2);
-}
Deleted: grass/trunk/lib/psdriver/Draw_point.c
===================================================================
--- grass/trunk/lib/psdriver/Draw_point.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Draw_point.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,6 +0,0 @@
-#include "psdriver.h"
-
-void PS_draw_point(double x, double y)
-{
- output("%f %f POINT\n", x, y);
-}
Modified: grass/trunk/lib/psdriver/Driver.c
===================================================================
--- grass/trunk/lib/psdriver/Driver.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Driver.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -32,19 +32,21 @@
drv.Graph_set = PS_Graph_set;
drv.Graph_close = PS_Graph_close;
drv.Line_width = PS_Line_width;
- drv.Polydots = NULL;
- drv.Polyline = PS_Polyline;
- drv.Polygon = PS_Polygon;
drv.Set_window = PS_Set_window;
- drv.Begin_scaled_raster = PS_begin_scaled_raster;
- drv.Scaled_raster = PS_scaled_raster;
- drv.End_scaled_raster = PS_end_scaled_raster;
- drv.color_rgb = PS_color_rgb;
- drv.draw_line = PS_draw_line;
- drv.draw_point = PS_draw_point;
- drv.draw_bitmap = PS_draw_bitmap;
- drv.draw_text = NULL;
- drv.text_box = NULL;
+ drv.Begin_raster = PS_begin_raster;
+ drv.Raster = PS_raster;
+ drv.End_raster = PS_end_raster;
+ drv.Begin = PS_Begin;
+ drv.Move = PS_Move;
+ drv.Cont = PS_Cont;
+ drv.Close = PS_Close;
+ drv.Stroke = PS_Stroke;
+ drv.Fill = PS_Fill;
+ drv.Point = PS_Point;
+ drv.Color = PS_Color;
+ drv.Bitmap = PS_Bitmap;
+ drv.Text = NULL;
+ drv.Text_box = NULL;
drv.Set_font = NULL;
drv.Font_list = NULL;
drv.Font_info = NULL;
Deleted: grass/trunk/lib/psdriver/Polygon.c
===================================================================
--- grass/trunk/lib/psdriver/Polygon.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Polygon.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,17 +0,0 @@
-
-#include "psdriver.h"
-
-void PS_Polygon(const double *xarray, const double *yarray, int number)
-{
- int i;
-
- if (number < 2)
- return;
-
- output("%f %f POLYGONSTART\n", xarray[0], yarray[0]);
-
- for (i = 1; i < number; i++)
- output("%f %f POLYGONVERTEX\n", xarray[i], yarray[i]);
-
- output("POLYGONEND\n");
-}
Deleted: grass/trunk/lib/psdriver/Polyline.c
===================================================================
--- grass/trunk/lib/psdriver/Polyline.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Polyline.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -1,17 +0,0 @@
-
-#include "psdriver.h"
-
-void PS_Polyline(const double *xarray, const double *yarray, int number)
-{
- int i;
-
- if (number < 2)
- return;
-
- output("%f %f POLYLINESTART\n", xarray[0], yarray[0]);
-
- for (i = 1; i < number; i++)
- output("%f %f POLYLINEVERTEX\n", xarray[i], yarray[i]);
-
- output("POLYLINEEND\n");
-}
Modified: grass/trunk/lib/psdriver/Raster.c
===================================================================
--- grass/trunk/lib/psdriver/Raster.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/Raster.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -5,7 +5,7 @@
static int masked;
-void PS_begin_scaled_raster(int mask, int src[2][2], double dst[2][2])
+void PS_begin_raster(int mask, int src[2][2], double dst[2][2])
{
const char *type = ps.true_color ? (mask ? "RASTERRGBMASK" : "RASTERRGB")
: (mask ? "RASTERGRAYMASK" : "RASTERGRAY");
@@ -28,9 +28,9 @@
type);
}
-int PS_scaled_raster(int n, int row,
- const unsigned char *red, const unsigned char *grn,
- const unsigned char *blu, const unsigned char *nul)
+int PS_raster(int n, int row,
+ const unsigned char *red, const unsigned char *grn,
+ const unsigned char *blu, const unsigned char *nul)
{
int i;
@@ -59,7 +59,7 @@
return row + 1;
}
-void PS_end_scaled_raster(void)
+void PS_end_raster(void)
{
output("grestore\n");
}
Modified: grass/trunk/lib/psdriver/psdriver.h
===================================================================
--- grass/trunk/lib/psdriver/psdriver.h 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/psdriver/psdriver.h 2008-12-04 16:47:24 UTC (rev 34720)
@@ -33,16 +33,19 @@
extern int PS_Graph_set(void);
extern void PS_Line_width(double);
extern void PS_Set_window(double, double, double, double);
-extern void PS_color_rgb(int, int, int);
-extern void PS_draw_bitmap(int, int, int, const unsigned char *);
-extern void PS_draw_line(double, double, double, double);
-extern void PS_draw_point(double, double);
-extern void PS_begin_scaled_raster(int, int[2][2], double[2][2]);
-extern int PS_scaled_raster(int, int, const unsigned char *,
- const unsigned char *, const unsigned char *,
- const unsigned char *);
-extern void PS_end_scaled_raster(void);
-extern void PS_Polygon(const double *, const double *, int);
-extern void PS_Polyline(const double *, const double *, int);
+extern void PS_Color(int, int, int);
+extern void PS_Bitmap(int, int, int, const unsigned char *);
+extern void PS_begin_raster(int, int[2][2], double[2][2]);
+extern int PS_raster(int, int, const unsigned char *,
+ const unsigned char *, const unsigned char *,
+ const unsigned char *);
+extern void PS_end_raster(void);
+extern void PS_Begin(void);
+extern void PS_Move(double, double);
+extern void PS_Cont(double, double);
+extern void PS_Close(void);
+extern void PS_Stroke(void);
+extern void PS_Fill(void);
+extern void PS_Point(double, double);
#endif /* __PSDRIVER_H__ */
Modified: grass/trunk/lib/psdriver/psdriver.ps
===================================================================
(Binary files differ)
Modified: grass/trunk/lib/raster/raster.c
===================================================================
--- grass/trunk/lib/raster/raster.c 2008-12-04 13:49:54 UTC (rev 34719)
+++ grass/trunk/lib/raster/raster.c 2008-12-04 16:47:24 UTC (rev 34720)
@@ -377,19 +377,19 @@
void R_begin_scaled_raster(int mask, int src[2][2], double dst[2][2])
{
- COM_begin_scaled_raster(mask, src, dst);
+ COM_begin_raster(mask, src, dst);
}
int R_scaled_raster(int n, int row,
const unsigned char *red, const unsigned char *grn,
const unsigned char *blu, const unsigned char *nul)
{
- return COM_scaled_raster(n, row, red, grn, blu, nul);
+ return COM_raster(n, row, red, grn, blu, nul);
}
void R_end_scaled_raster(void)
{
- COM_end_scaled_raster();
+ COM_end_raster();
}
void R_bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
More information about the grass-commit
mailing list