1 /****************************************************************************** 2 * $Id$ 3 * 4 * Project: MapServer 5 * Purpose: symbolObj related declarations. 6 * Author: Steve Lime and the MapServer team. 7 * 8 ****************************************************************************** 9 * Copyright (c) 1996-2005 Regents of the University of Minnesota. 10 * 11 * Permission is hereby granted, free of charge, to any person obtaining a 12 * copy of this software and associated documentation files (the "Software"), 13 * to deal in the Software without restriction, including without limitation 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 * and/or sell copies of the Software, and to permit persons to whom the 16 * Software is furnished to do so, subject to the following conditions: 17 * 18 * The above copyright notice and this permission notice shall be included in 19 * all copies of this Software or works derived from this Software. 20 * 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 * DEALINGS IN THE SOFTWARE. 28 ****************************************************************************/ 29 30 #ifndef MAPSYMBOL_H 31 #define MAPSYMBOL_H 32 33 #include "mapserver-api.h" 34 #include <assert.h> 35 36 enum MS_SYMBOL_TYPE {MS_SYMBOL_SIMPLE=1000, MS_SYMBOL_VECTOR, MS_SYMBOL_ELLIPSE, MS_SYMBOL_PIXMAP, MS_SYMBOL_TRUETYPE, MS_SYMBOL_HATCH, MS_SYMBOL_SVG}; 37 38 #define MS_SYMBOL_ALLOCSIZE 64 /* number of symbolObj ptrs to allocate for a symbolset at once */ 39 #define MS_MAXVECTORPOINTS 100 /* shade, marker and line symbol parameters */ 40 #define MS_MAXPATTERNLENGTH 10 41 42 #define MS_IMAGECACHESIZE 6 43 44 /* COLOR OBJECT */ 45 typedef struct { 46 int red; 47 int green; 48 int blue; 49 int alpha; 50 } colorObj; 51 52 #ifndef SWIG 53 enum MS_RASTER_BUFFER_TYPE { MS_BUFFER_NONE=2000, MS_BUFFER_BYTE_RGBA, MS_BUFFER_BYTE_PALETTE }; 54 55 typedef struct { 56 unsigned char *pixels; 57 unsigned int pixel_step, row_step; 58 unsigned char *a,*r,*g,*b; 59 } rgbaArrayObj; 60 61 typedef struct { 62 unsigned char b,g,r,a; 63 } rgbaPixel; 64 65 typedef struct { 66 unsigned char r,g,b; 67 } rgbPixel; 68 69 70 typedef struct { 71 unsigned char *pixels; /*stores the actual pixel indexes*/ 72 rgbaPixel *palette; /*rgba palette entries*/ 73 unsigned int num_entries; /*number of palette entries*/ 74 unsigned int scaling_maxval; 75 } paletteArrayObj; 76 77 typedef struct { 78 int type; 79 unsigned int width,height; 80 union { 81 rgbaArrayObj rgba; 82 paletteArrayObj palette; 83 } data; 84 } rasterBufferObj; 85 86 /* NOTE: RB_SET_PIXEL() will premultiply by alpha, inputs should not be 87 premultiplied */ 88 89 #define RB_SET_PIXEL(rb,x,y,red,green,blue,alpha) \ 90 { \ 91 int _rb_off = (x) * (rb)->data.rgba.pixel_step + (y) * (rb)->data.rgba.row_step; \ 92 if( !(rb)->data.rgba.a ) { \ 93 (rb)->data.rgba.r[_rb_off] = red; \ 94 (rb)->data.rgba.g[_rb_off] = green; \ 95 (rb)->data.rgba.b[_rb_off] = blue; \ 96 } else { \ 97 double a = alpha/255.0; \ 98 (rb)->data.rgba.r[_rb_off] = red * a; \ 99 (rb)->data.rgba.g[_rb_off] = green * a; \ 100 (rb)->data.rgba.b[_rb_off] = blue * a; \ 101 (rb)->data.rgba.a[_rb_off] = alpha; \ 102 } \ 103 } 104 105 /* This versions receives an input red/green/blue that is already 106 premultiplied with alpha */ 107 #define RB_SET_PIXEL_PM(rb,x,y,red,green,blue,alpha) \ 108 { \ 109 int _rb_off = (x) * (rb)->data.rgba.pixel_step + (y) * (rb)->data.rgba.row_step; \ 110 (rb)->data.rgba.r[_rb_off] = red; \ 111 (rb)->data.rgba.g[_rb_off] = green; \ 112 (rb)->data.rgba.b[_rb_off] = blue; \ 113 if( rb->data.rgba.a ) { \ 114 (rb)->data.rgba.a[_rb_off] = alpha; \ 115 } \ 116 } 117 118 /* NOTE: RB_MIX_PIXEL() will premultiply by alpha, inputs should not be 119 premultiplied */ 120 121 #define RB_MIX_PIXEL(rb,x,y,red,green,blue,alpha) \ 122 { \ 123 int _rb_off = (x) * (rb)->data.rgba.pixel_step + (y) * (rb)->data.rgba.row_step; \ 124 \ 125 msAlphaBlend( red, green, blue, alpha, \ 126 (rb)->data.rgba.r + _rb_off, \ 127 (rb)->data.rgba.g + _rb_off, \ 128 (rb)->data.rgba.b + _rb_off, \ 129 ((rb)->data.rgba.a == NULL ) ? NULL : (rb)->data.rgba.a + _rb_off ); \ 130 } 131 132 133 134 struct imageCacheObj { 135 int symbol; 136 int size; 137 colorObj color; 138 colorObj outlinecolor; 139 colorObj backgroundcolor; 140 rasterBufferObj img; 141 struct imageCacheObj *next; 142 }; 143 144 145 #endif /* SWIG */ 146 147 148 struct symbolObj{ 149 char *name; 150 int type; 151 int inmapfile; /* boolean value for writing */ 152 153 #ifndef SWIG 154 /* 155 ** Pointer to his map 156 */ 157 struct mapObj *map; 158 #endif /* SWIG */ 159 /* 160 ** MS_SYMBOL_VECTOR and MS_SYMBOL_ELLIPSE options 161 */ 162 double sizex, sizey; 163 double minx,miny,maxx,maxy; 164 165 #ifndef SWIG 166 pointObj points[MS_MAXVECTORPOINTS]; 167 #endif 168 169 #ifdef SWIG 170 %immutable; 171 #endif /* SWIG */ 172 int refcount; 173 int numpoints; 174 #ifdef SWIG 175 %mutable; 176 #endif /* SWIG */ 177 int filled; 178 179 double anchorpoint_x, anchorpoint_y; 180 181 /* 182 ** MS_SYMBOL_PIXMAP options 183 */ 184 #ifndef SWIG 185 rendererVTableObj *renderer; 186 void (*renderer_free_func)(symbolObj *self); 187 rasterBufferObj *pixmap_buffer; 188 void *renderer_cache; 189 char *full_pixmap_path; 190 #endif /* SWIG */ 191 192 #ifdef SWIG 193 %immutable; 194 #endif /* SWIG */ 195 char *imagepath; 196 #ifdef SWIG 197 %mutable; 198 #endif /* SWIG */ 199 200 int transparent; 201 int transparentcolor; 202 203 /* 204 ** MS_SYMBOL_TRUETYPE options 205 */ 206 char *character; 207 char *font; 208 } ; 209 210 #endif /* MAPSYMBOL_H */ 211