[GRASS-SVN] r33172 - in grass/trunk: display/d.info include
lib/cairodriver lib/driver lib/htmldriver lib/pngdriver
lib/psdriver lib/raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 30 14:12:48 EDT 2008
Author: glynn
Date: 2008-08-30 14:12:48 -0400 (Sat, 30 Aug 2008)
New Revision: 33172
Added:
grass/trunk/lib/htmldriver/Box.c
Removed:
grass/trunk/lib/driver/Returns.c
grass/trunk/lib/psdriver/Color_table.c
Modified:
grass/trunk/display/d.info/main.c
grass/trunk/include/raster.h
grass/trunk/lib/cairodriver/Color.c
grass/trunk/lib/cairodriver/Driver.c
grass/trunk/lib/cairodriver/cairodriver.h
grass/trunk/lib/driver/Box.c
grass/trunk/lib/driver/Color.c
grass/trunk/lib/driver/Erase.c
grass/trunk/lib/driver/driver.h
grass/trunk/lib/driver/init.c
grass/trunk/lib/htmldriver/Driver.c
grass/trunk/lib/htmldriver/Graph_Set.c
grass/trunk/lib/htmldriver/htmlmap.h
grass/trunk/lib/pngdriver/Color.c
grass/trunk/lib/pngdriver/Color_table.c
grass/trunk/lib/pngdriver/Driver.c
grass/trunk/lib/pngdriver/pngdriver.h
grass/trunk/lib/psdriver/Color.c
grass/trunk/lib/psdriver/Driver.c
grass/trunk/lib/psdriver/Graph_set.c
grass/trunk/lib/psdriver/psdriver.h
grass/trunk/lib/raster/raster.c
Log:
Remove last vestiges of colour indices
Modified: grass/trunk/display/d.info/main.c
===================================================================
--- grass/trunk/display/d.info/main.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/display/d.info/main.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -55,10 +55,6 @@
gflag->description =
_("Display screen rectangle coordinates and resolution (west, east, north, south, ewres, nsres)");
- cflag = G_define_flag();
- cflag->key = 'c';
- cflag->description = _("Display number of colors");
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -80,9 +76,6 @@
if (dflag->answer)
fprintf(stdout, "dimensions: %f %f\n", r - l, b - t);
- if (cflag->answer)
- fprintf(stdout, "colors: %d\n", R_get_num_colors());
-
if (fflag->answer) {
R_get_window(&t, &b, &l, &r);
fprintf(stdout, "frame: %f %f %f %f\n", l, r, t, b);
Modified: grass/trunk/include/raster.h
===================================================================
--- grass/trunk/include/raster.h 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/include/raster.h 2008-08-30 18:12:48 UTC (rev 33172)
@@ -5,7 +5,6 @@
int R_open_driver(void);
void R_close_driver(void);
-int R_get_num_colors(void);
void R_set_window(double, double, double, double);
void R_get_window(double *, double *, double *, double *);
Modified: grass/trunk/lib/cairodriver/Color.c
===================================================================
--- grass/trunk/lib/cairodriver/Color.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/cairodriver/Color.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -22,36 +22,13 @@
\param color value
*/
-void Cairo_color(int color)
+void Cairo_color_rgb(int r, int g, int b)
{
- static int previous_color = 0x7FFFFFFF;
+ G_debug(3, "Cairo_color: %d,%d,%d", r, g, b);
- G_debug(3, "Cairo_color: %d", color);
+ cairo_set_source_rgba(cairo,
+ CAIROCOLOR(r), CAIROCOLOR(g), CAIROCOLOR(b), 1.0);
- if (color != previous_color) {
- int r = (color >> 16) & 0xFF;
- int g = (color >> 8) & 0xFF;
- int b = (color >> 0) & 0xFF;
-
- cairo_set_source_rgba(cairo, CAIROCOLOR(r), CAIROCOLOR(g),
- CAIROCOLOR(b), 1.0);
- previous_color = color;
-
- G_debug(3, "Set color to: %g %g %g", CAIROCOLOR(r), CAIROCOLOR(g),
- CAIROCOLOR(b));
- }
+ G_debug(3, "Set color to: %g %g %g",
+ CAIROCOLOR(r), CAIROCOLOR(g), CAIROCOLOR(b));
}
-
-/*!
- \brief Get color value
-
- \param r,g,b red,green,blue
-
- \return value
-*/
-int Cairo_lookup_color(int r, int g, int b)
-{
- G_debug(3, "Cairo_lookup_color: %d %d %d", r, g, b);
-
- return (r << 16) + (g << 8) + (b << 0);
-}
Modified: grass/trunk/lib/cairodriver/Driver.c
===================================================================
--- grass/trunk/lib/cairodriver/Driver.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/cairodriver/Driver.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -40,8 +40,7 @@
drv.Scaled_raster = Cairo_scaled_raster;
drv.End_scaled_raster = Cairo_end_scaled_raster;
drv.Respond = Cairo_Respond;
- drv.lookup_color = Cairo_lookup_color;
- drv.color = Cairo_color;
+ drv.color_rgb = Cairo_color_rgb;
drv.draw_line = Cairo_draw_line;
drv.draw_point = Cairo_draw_point;
drv.draw_bitmap = Cairo_draw_bitmap;
Modified: grass/trunk/lib/cairodriver/cairodriver.h
===================================================================
--- grass/trunk/lib/cairodriver/cairodriver.h 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/cairodriver/cairodriver.h 2008-08-30 18:12:48 UTC (rev 33172)
@@ -71,8 +71,7 @@
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(int);
-extern int Cairo_lookup_color(int, int, int);
+extern void Cairo_color_rgb(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,
Modified: grass/trunk/lib/driver/Box.c
===================================================================
--- grass/trunk/lib/driver/Box.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/driver/Box.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -3,23 +3,8 @@
void COM_Box_abs(double x1, double y1, double x2, double y2)
{
- double x[4], y[4];
-
- if (driver->Box) {
- (*driver->Box) (x1, y1, x2, y2);
- return;
- }
-
- x[0] = x1;
- y[0] = y1;
- x[1] = x1;
- y[1] = y2;
- x[2] = x2;
- y[2] = y2;
- x[3] = x2;
- y[3] = y1;
-
- COM_Polygon_abs(x, y, 4);
+ if (driver->Box)
+ (*driver->Box)(x1, y1, x2, y2);
}
void COM_Box_rel(double x, double y)
Modified: grass/trunk/lib/driver/Color.c
===================================================================
--- grass/trunk/lib/driver/Color.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/driver/Color.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -2,23 +2,10 @@
#include "driver.h"
#include "driverlib.h"
-static int lookup_color(int r, int g, int b)
-{
- if (driver->lookup_color)
- return (*driver->lookup_color) (r, g, b);
- return 0;
-}
-
-static void color(int number)
-{
- if (driver->color)
- (*driver->color) (number);
-}
-
-
void COM_Color_RGB(unsigned char r, unsigned char g, unsigned char b)
{
- color(lookup_color(r, g, b));
+ if (driver->color_rgb)
+ (*driver->color_rgb)(r, g, b);
}
void COM_Standard_color(int number)
Modified: grass/trunk/lib/driver/Erase.c
===================================================================
--- grass/trunk/lib/driver/Erase.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/driver/Erase.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -3,14 +3,6 @@
void COM_Erase(void)
{
- double top, bot, left, rite;
-
- if (driver->Erase) {
- (*driver->Erase) ();
- return;
- }
-
- COM_Get_window(&top, &bot, &left, &rite);
-
- COM_Box_abs(left, top, rite, bot);
+ if (driver->Erase)
+ (*driver->Erase)();
}
Deleted: grass/trunk/lib/driver/Returns.c
===================================================================
--- grass/trunk/lib/driver/Returns.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/driver/Returns.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -1,7 +0,0 @@
-#include "driver.h"
-#include "driverlib.h"
-
-int COM_Number_of_colors(void)
-{
- return NCOLORS;
-}
Modified: grass/trunk/lib/driver/driver.h
===================================================================
--- grass/trunk/lib/driver/driver.h 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/driver/driver.h 2008-08-30 18:12:48 UTC (rev 33172)
@@ -4,8 +4,6 @@
#include <grass/freetypecap.h>
-extern int NCOLORS;
-
extern int screen_width;
extern int screen_height;
@@ -22,29 +20,28 @@
struct driver
{
- void (*Box) (double, double, double, double);
- void (*Erase) (void);
- 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 (*Respond) (void);
+ void (*Box)(double, double, double, double);
+ void (*Erase)(void);
+ 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 (*Respond)(void);
- int (*lookup_color) (int, int, int);
- void (*color) (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 (*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 (*Set_font)(const char *);
void (*Font_list)(char ***, int *);
@@ -118,9 +115,6 @@
/* Respond.c */
extern void COM_Respond(void);
-/* Returns.c */
-extern int COM_Number_of_colors(void);
-
/* Set_window.c */
extern void COM_Set_window(double, double, double, double);
extern void COM_Get_window(double *, double *, double *, double *);
Modified: grass/trunk/lib/driver/init.c
===================================================================
--- grass/trunk/lib/driver/init.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/driver/init.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -26,8 +26,6 @@
struct GFONT_CAP *ftcap;
-int NCOLORS;
-
int screen_width;
int screen_height;
Added: grass/trunk/lib/htmldriver/Box.c
===================================================================
--- grass/trunk/lib/htmldriver/Box.c (rev 0)
+++ grass/trunk/lib/htmldriver/Box.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -0,0 +1,14 @@
+#include "htmlmap.h"
+
+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);
+}
+
Modified: grass/trunk/lib/htmldriver/Driver.c
===================================================================
--- grass/trunk/lib/htmldriver/Driver.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/htmldriver/Driver.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -25,7 +25,7 @@
if (initialized)
return &drv;
- drv.Box = NULL;
+ drv.Box = HTML_Box;
drv.Erase = NULL;
drv.Graph_set = HTML_Graph_set;
drv.Graph_close = HTML_Graph_close;
@@ -38,8 +38,7 @@
drv.Scaled_raster = NULL;
drv.End_scaled_raster = NULL;
drv.Respond = NULL;
- drv.lookup_color = NULL;
- drv.color = NULL;
+ drv.color_rgb = NULL;
drv.draw_line = NULL;
drv.draw_point = NULL;
drv.draw_bitmap = NULL;
Modified: grass/trunk/lib/htmldriver/Graph_Set.c
===================================================================
--- grass/trunk/lib/htmldriver/Graph_Set.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/htmldriver/Graph_Set.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -28,8 +28,6 @@
G_gisinit("HTMLMAP driver");
- NCOLORS = 256;
-
/*
* set the minimum bounding box dimensions
*/
Modified: grass/trunk/lib/htmldriver/htmlmap.h
===================================================================
--- grass/trunk/lib/htmldriver/htmlmap.h 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/htmldriver/htmlmap.h 2008-08-30 18:12:48 UTC (rev 33172)
@@ -47,6 +47,9 @@
/* Graph_Set.c */
extern int HTML_Graph_set(void);
+/* Box.c */
+extern void HTML_Box(double, double, double, double);
+
/* Polygon.c */
extern void HTML_Polygon(const double *, const double *, int);
Modified: grass/trunk/lib/pngdriver/Color.c
===================================================================
--- grass/trunk/lib/pngdriver/Color.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/pngdriver/Color.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -9,20 +9,7 @@
#include <grass/gis.h>
#include "pngdriver.h"
-void PNG_color(int number)
+void PNG_color_rgb(int r, int g, int b)
{
- if (number >= NCOLORS || number < 0) {
- G_warning("Color: can't set color %d\n", number);
- return;
- }
-
- if (png.true_color) {
- int r = (number >> 16) & 0xFF;
- int g = (number >> 8) & 0xFF;
- int b = (number >> 0) & 0xFF;
-
- png.current_color = get_color(r, g, b, 0);
- }
- else
- png.current_color = number;
+ png.current_color = get_color(r, g, b, 0);
}
Modified: grass/trunk/lib/pngdriver/Color_table.c
===================================================================
--- grass/trunk/lib/pngdriver/Color_table.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/pngdriver/Color_table.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -19,8 +19,6 @@
static void init_colors_rgb(void)
{
- NCOLORS = 1 << 24;
-
if (G_is_little_endian()) {
b_shift = 0;
g_shift = 8;
@@ -41,8 +39,6 @@
int r, g, b;
int i;
- NCOLORS = 256;
-
n_pixels = 0;
if (png.has_alpha)
@@ -62,7 +58,7 @@
}
}
- while (n_pixels < NCOLORS)
+ while (n_pixels < 256)
set_color(n_pixels++, 0, 0, 0);
for (i = 0; i < 256; i++) {
@@ -123,12 +119,8 @@
unsigned int get_color(int r, int g, int b, int a)
{
- return png.true_color ? get_color_rgb(r, g, b, a)
+ return png.true_color
+ ? get_color_rgb(r, g, b, a)
: get_color_indexed(r, g, b, a);
}
-int PNG_lookup_color(int r, int g, int b)
-{
- return png.true_color ? ((r << 16) | (g << 8) | (b << 0))
- : Red[r] + Grn[g] + Blu[b] + png.has_alpha;
-}
Modified: grass/trunk/lib/pngdriver/Driver.c
===================================================================
--- grass/trunk/lib/pngdriver/Driver.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/pngdriver/Driver.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -40,8 +40,7 @@
drv.Scaled_raster = PNG_scaled_raster;
drv.End_scaled_raster = NULL;
drv.Respond = PNG_Respond;
- drv.lookup_color = PNG_lookup_color;
- drv.color = PNG_color;
+ drv.color_rgb = PNG_color_rgb;
drv.draw_line = PNG_draw_line;
drv.draw_point = PNG_draw_point;
drv.draw_bitmap = PNG_draw_bitmap;
Modified: grass/trunk/lib/pngdriver/pngdriver.h
===================================================================
--- grass/trunk/lib/pngdriver/pngdriver.h 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/pngdriver/pngdriver.h 2008-08-30 18:12:48 UTC (rev 33172)
@@ -62,10 +62,9 @@
const unsigned char *);
extern void PNG_Respond(void);
extern void PNG_Set_window(double, double, double, double);
-extern void PNG_color(int);
+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);
-extern int PNG_lookup_color(int, int, int);
#endif /* __PNGDRIVER_H__ */
Modified: grass/trunk/lib/psdriver/Color.c
===================================================================
--- grass/trunk/lib/psdriver/Color.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/psdriver/Color.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -2,20 +2,10 @@
#include <grass/gis.h>
#include "psdriver.h"
-void PS_color(int number)
+void PS_color_rgb(int r, int g, int b)
{
- if (number >= NCOLORS || number < 0) {
- G_warning("Color: can't set color %d\n", number);
- return;
- }
-
- if (ps.true_color) {
- int r = (number >> 16) & 0xFF;
- int g = (number >> 8) & 0xFF;
- int b = (number >> 0) & 0xFF;
-
+ if (ps.true_color)
output("%d %d %d COLOR\n", r, g, b);
- }
else
- output("%d GRAY\n", number);
+ output("%d GRAY\n", (int)(r * 0.299 + g * 0.587 + b * 0.114));
}
Deleted: grass/trunk/lib/psdriver/Color_table.c
===================================================================
--- grass/trunk/lib/psdriver/Color_table.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/psdriver/Color_table.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -1,28 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <grass/gis.h>
-#include <grass/colors.h>
-#include "psdriver.h"
-
-void init_color_table(void)
-{
- NCOLORS = ps.true_color ? (1 << 24) : (1 << 8);
-}
-
-static int get_color_rgb(int r, int g, int b)
-{
- return (r << 16) + (g << 8) + b;
-}
-
-static int get_color_gray(int r, int g, int b)
-{
- return (int)(r * 0.299 + g * 0.587 + b * 0.114);
-}
-
-int PS_lookup_color(int r, int g, int b)
-{
- return ps.true_color ? get_color_rgb(r, g, b)
- : get_color_gray(r, g, b);
-}
Modified: grass/trunk/lib/psdriver/Driver.c
===================================================================
--- grass/trunk/lib/psdriver/Driver.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/psdriver/Driver.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -40,8 +40,7 @@
drv.Scaled_raster = PS_scaled_raster;
drv.End_scaled_raster = PS_end_scaled_raster;
drv.Respond = PS_Respond;
- drv.lookup_color = PS_lookup_color;
- drv.color = PS_color;
+ drv.color_rgb = PS_color_rgb;
drv.draw_line = PS_draw_line;
drv.draw_point = PS_draw_point;
drv.draw_bitmap = PS_draw_bitmap;
Modified: grass/trunk/lib/psdriver/Graph_set.c
===================================================================
--- grass/trunk/lib/psdriver/Graph_set.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/psdriver/Graph_set.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -200,8 +200,6 @@
get_paper();
- init_color_table();
-
ps.outfp = fopen(file_name, ps.no_header ? "a" : "w");
if (!ps.outfp)
Modified: grass/trunk/lib/psdriver/psdriver.h
===================================================================
--- grass/trunk/lib/psdriver/psdriver.h 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/psdriver/psdriver.h 2008-08-30 18:12:48 UTC (rev 33172)
@@ -22,6 +22,7 @@
extern void output(const char *, ...);
extern void init_color_table(void);
+extern int lookup_color(int, int, int);
extern const struct driver *PS_Driver(void);
@@ -33,11 +34,10 @@
extern void PS_Line_width(double);
extern void PS_Respond(void);
extern void PS_Set_window(double, double, double, double);
-extern void PS_color(int);
+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 int PS_lookup_color(int, int, int);
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 *,
Modified: grass/trunk/lib/raster/raster.c
===================================================================
--- grass/trunk/lib/raster/raster.c 2008-08-30 17:21:59 UTC (rev 33171)
+++ grass/trunk/lib/raster/raster.c 2008-08-30 18:12:48 UTC (rev 33172)
@@ -87,11 +87,6 @@
system(cmd);
}
-int R_get_num_colors(void)
-{
- return COM_Number_of_colors();
-}
-
/*!
* \brief select standard color
*
More information about the grass-commit
mailing list