- Timestamp:
- Aug 28, 2008, 7:19:30 PM (13 years ago)
- Location:
- libpipi/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/context.c
r2781 r2790 392 392 pipi_free(tmp); 393 393 } 394 else if(!strcmp(cmd, "order")) 395 { 396 pipi_image_t *tmp; 397 if(ctx->nimages < 1) 398 return -1; 399 tmp = ctx->images[ctx->nimages - 1]; 400 ctx->images[ctx->nimages - 1] = pipi_order(tmp); 401 pipi_free(tmp); 402 } 394 403 else if(!strcmp(cmd, "split")) 395 404 { -
libpipi/trunk/pipi/dither/ordered.c
r2696 r2790 19 19 #include "config.h" 20 20 #include "common.h" 21 22 #include <stdlib.h> 21 23 22 24 #include "pipi.h" … … 57 59 } 58 60 61 typedef struct 62 { 63 int x, y; 64 double val; 65 } 66 dot_t; 67 68 static int cmpdot(const void *p1, const void *p2) 69 { 70 return ((dot_t const *)p1)->val > ((dot_t const *)p2)->val; 71 } 72 73 pipi_image_t *pipi_order(pipi_image_t *src) 74 { 75 double epsilon; 76 pipi_image_t *dst; 77 pipi_pixels_t *dstp, *srcp; 78 float *dstdata, *srcdata; 79 dot_t *circle; 80 int x, y, w, h, n; 81 82 w = src->w; 83 h = src->h; 84 epsilon = 1. / (w * h + 1); 85 86 srcp = pipi_getpixels(src, PIPI_PIXELS_Y_F); 87 srcdata = (float *)srcp->pixels; 88 89 dst = pipi_new(w, h); 90 dstp = pipi_getpixels(dst, PIPI_PIXELS_Y_F); 91 dstdata = (float *)dstp->pixels; 92 93 circle = malloc(w * h * sizeof(dot_t)); 94 95 for(y = 0; y < h; y++) 96 for(x = 0; x < w; x++) 97 { 98 circle[y * w + x].x = x; 99 circle[y * w + x].y = y; 100 circle[y * w + x].val = srcdata[y * w + x]; 101 } 102 qsort(circle, w * h, sizeof(dot_t), cmpdot); 103 104 for(n = 0; n < w * h; n++) 105 { 106 x = circle[n].x; 107 y = circle[n].y; 108 dstdata[y * w + x] = (float)(n + 1) * epsilon; 109 } 110 111 free(circle); 112 113 return dst; 114 } 115 -
libpipi/trunk/pipi/pipi.h
r2788 r2790 151 151 extern pipi_image_t *pipi_erode(pipi_image_t *); 152 152 153 extern pipi_image_t *pipi_order(pipi_image_t *); 154 153 155 extern pipi_image_t *pipi_tile(pipi_image_t *, int, int); 154 156 extern int pipi_flood_fill(pipi_image_t *, -
libpipi/trunk/src/pipi.c
r2781 r2790 116 116 return EXIT_FAILURE; 117 117 } 118 else if(!strcmp(argv[0], "--order")) 119 { 120 if(pipi_command(ctx, "order") != 0) 121 return EXIT_FAILURE; 122 } 118 123 else if(!strcmp(argv[0], "--hflip")) 119 124 {
Note: See TracChangeset
for help on using the changeset viewer.