- Timestamp:
- Sep 1, 2008, 1:05:50 AM (12 years ago)
- Location:
- libpipi/trunk/pipi
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/context.c
r2790 r2811 105 105 ctx->nimages--; 106 106 } 107 else if(!str cmp(method, "ordered"))107 else if(!strncmp(method, "ordered", 7)) 108 108 { 109 double angle = .0; 110 method = strchr(method, ':'); 111 if(method) 112 angle = atof(method + 1); 109 113 if(ctx->nimages < 2) 110 114 return -1; 111 dst = pipi_dither_ordered(ctx->images[ctx->nimages - 2], src); 115 dst = pipi_dither_ordered_ext(ctx->images[ctx->nimages - 2], src, 116 angle); 112 117 pipi_free(ctx->images[ctx->nimages - 2]); 113 118 ctx->nimages--; -
libpipi/trunk/pipi/dither/ordered.c
r2790 r2811 21 21 22 22 #include <stdlib.h> 23 #include <math.h> 23 24 24 25 #include "pipi.h" … … 27 28 pipi_image_t *pipi_dither_ordered(pipi_image_t *img, pipi_image_t *kernel) 28 29 { 30 return pipi_dither_ordered_ext(img, kernel, 0.0); 31 } 32 33 pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *img, pipi_image_t *kernel, 34 double angle) 35 { 36 double sint, cost; 29 37 pipi_image_t *dst; 30 38 pipi_pixels_t *dstp, *kernelp; 31 39 float *dstdata, *kerneldata; 32 int x, y, w, h, k w, kh;40 int x, y, w, h, kx, ky, kw, kh; 33 41 34 42 w = img->w; … … 36 44 kw = kernel->w; 37 45 kh = kernel->h; 46 47 cost = cos(angle * (M_PI / 180)); 48 sint = sin(angle * (M_PI / 180)); 38 49 39 50 dst = pipi_copy(img); … … 50 61 float p, q; 51 62 63 kx = (int)(cost * x - sint * y + 2 * w * h) % kw; 64 ky = (int)(cost * y + sint * x + 2 * w * h) % kh; 65 52 66 p = dstdata[y * w + x]; 53 q = p > kerneldata[ (y % kh) * kw + (x % kw)] ? 1. : 0.;67 q = p > kerneldata[ky * kw + kx] ? 1. : 0.; 54 68 dstdata[y * w + x] = q; 55 69 } -
libpipi/trunk/pipi/pipi.h
r2810 r2811 183 183 pipi_scan_t); 184 184 extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *); 185 extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *, 186 double); 185 187 extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double); 186 188 extern pipi_image_t *pipi_dither_random(pipi_image_t *);
Note: See TracChangeset
for help on using the changeset viewer.