- Timestamp:
- Aug 29, 2008, 12:27:35 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/paint/line.c
r2798 r2799 83 83 s.color32 = c; 84 84 s.buf_u32 = dstdata; 85 s.draw = aliased_line_8bit;85 s.draw = line_8bit; 86 86 } 87 87 else … … 93 93 s.colorf[0] = (c&0x000000FF)/255.0f; /* XXX FIXME */ 94 94 s.buf_f = dstdata; 95 s.draw = a ntialiased_line;95 s.draw = aaline; 96 96 } 97 97 } … … 102 102 s.colorf[0] = (c & 0xff) / 255.0f; /* XXX FIXME */ 103 103 s.buf_f = dstdata; 104 s.draw = aa == 0 ? aliased_line_gray : antialiased_line_gray;104 s.draw = aa ? aaline_gray : line_gray; 105 105 } 106 106 else … … 112 112 s.colorf[0] = (c&0x000000FF)/255.0f; /* XXX FIXME */ 113 113 s.buf_f = dstdata; 114 s.draw = aa == 0 ? aliased_line : antialiased_line;114 s.draw = aa ? aaline : line; 115 115 } 116 116 … … 119 119 } 120 120 121 122 121 int pipi_draw_polyline(pipi_image_t *img, int const x[], int const y[], 123 122 int n, uint32_t c, int aa) 124 123 { 125 124 int i; 126 struct line s;127 128 if(img->last_modified == PIPI_PIXELS_RGBA_C)129 {130 if(!aa)131 {132 uint32_t *dstdata;133 dstdata = (uint32_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->pixels;134 s.color32 = c;135 s.buf_u32 = dstdata;136 s.draw = aliased_line_8bit;137 }138 else139 {140 float *dstdata;141 dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_RGBA_F)->pixels;142 s.colorf[2] = ((c&0x00FF0000)>>16)/255.0f; /* XXX FIXME */143 s.colorf[1] = ((c&0x0000FF00)>>8)/255.0f; /* XXX FIXME */144 s.colorf[0] = (c&0x000000FF)/255.0f; /* XXX FIXME */145 s.buf_f = dstdata;146 s.draw = antialiased_line;147 }148 }149 else if(img->last_modified == PIPI_PIXELS_Y_F)150 {151 float *dstdata;152 dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_Y_F)->pixels;153 s.colorf[0] = (c & 0xff) / 255.0f; /* XXX FIXME */154 s.buf_f = dstdata;155 s.draw = aa == 0 ? aliased_line_gray : antialiased_line_gray;156 }157 else158 {159 float *dstdata;160 dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_RGBA_F)->pixels;161 s.colorf[0] = (c&0x00FF0000)/255.0f; /* XXX FIXME */162 s.colorf[1] = (c&0x0000FF00)/255.0f; /* XXX FIXME */163 s.colorf[2] = (c&0x000000FF)/255.0f; /* XXX FIXME */164 s.buf_f = dstdata;165 s.draw = aa == 0 ? aliased_line : antialiased_line;166 img->last_modified = PIPI_PIXELS_RGBA_F;167 }168 125 169 126 for(i = 0; i < n; i++) 170 { 171 s.x1 = x[i]; 172 s.y1 = y[i]; 173 s.x2 = x[i+1]; 174 s.y2 = y[i+1]; 175 clip_line(img, &s); 176 } 127 pipi_draw_line(img, x[i], y[i], x[i + 1], y[i + 1], c, aa); 128 177 129 return 0; 178 130 } … … 256 208 257 209 #define PLOT(x, y, c) \ 258 if(FLAG_ GRAY) \210 if(FLAG_8BIT) \ 259 211 { \ 260 if(FLAG_8BIT)\261 {\262 /* TODO */\263 }\264 else\212 /* TODO */ \ 213 } \ 214 else \ 215 { \ 216 if(FLAG_GRAY) \ 265 217 { \ 266 218 s->buf_f[((int)(x))+((int)(y))*img->w] = \ … … 270 222 if(s->buf_f[((int)(x))+((int)(y))*img->w] < 0.0f) \ 271 223 s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \ 272 if(isnan(s->buf_f[((int)(x))+((int)(y))*img->w])) \273 s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \274 } \275 } \276 else \277 { \278 if(FLAG_8BIT) \279 { \280 /* TODO */ \281 224 } \ 282 225 else \ 283 226 { \ 284 227 int qwer = (((int)(x)*4))+((int)(y))*(img->w*4);\ 285 228 int qweg = (1+((int)(x)*4))+((int)(y))*(img->w*4); \ … … 288 231 s->buf_f[qweg] = (c*s->colorf[1]) + (1-c) * s->buf_f[qweg]; \ 289 232 s->buf_f[qweb] = (c*s->colorf[2]) + (1-c) * s->buf_f[qweb]; \ 290 if(s->buf_f[qwer] > 1.0f) \ 291 s->buf_f[qwer] = 1.0f; \ 292 if(s->buf_f[qwer] < 0.0f || isnan(s->buf_f[qwer])) \ 293 s->buf_f[qwer] = 0.0f; \ 294 if(s->buf_f[qweg] > 1.0f) \ 295 s->buf_f[qweg] = 1.0f; \ 296 if(s->buf_f[qweg] < 0.0f || isnan(s->buf_f[qweg])) \ 297 s->buf_f[qweg] = 0.0f; \ 298 if(s->buf_f[qweb] > 1.0f) \ 299 s->buf_f[qweb] = 1.0f; \ 300 if(s->buf_f[qweb] < 0.0f || isnan(s->buf_f[qweb])) \ 301 s->buf_f[qweb] = 0.0f; \ 233 if(s->buf_f[qwer] > 1.0f) s->buf_f[qwer] = 1.0f; \ 234 if(s->buf_f[qwer] < 0.0f) s->buf_f[qwer] = 0.0f; \ 235 if(s->buf_f[qweg] > 1.0f) s->buf_f[qweg] = 1.0f; \ 236 if(s->buf_f[qweg] < 0.0f) s->buf_f[qweg] = 0.0f; \ 237 if(s->buf_f[qweb] > 1.0f) s->buf_f[qweb] = 1.0f; \ 238 if(s->buf_f[qweb] < 0.0f) s->buf_f[qweb] = 0.0f; \ 302 239 } \ 303 240 } 304 241 305 static void SUFFIX(a ntialiased_line)(pipi_image_t *img, struct line* s)242 static void SUFFIX(aaline)(pipi_image_t *img, struct line* s) 306 243 { 307 244 float x1 = s->x1, y1 = s->y1, x2 = s->x2, y2 = s->y2; … … 424 361 /* Solid line drawing function, using Bresenham's mid-point line 425 362 * scan-conversion algorithm. */ 426 static void SUFFIX( aliased_line)(pipi_image_t *img, struct line* s)363 static void SUFFIX(line)(pipi_image_t *img, struct line* s) 427 364 { 428 365 int x1, y1, x2, y2;
Note: See TracChangeset
for help on using the changeset viewer.