Changeset 2811 for libpipi/trunk/pipi/dither/ordered.c
- Timestamp:
- 09/01/08 01:05:50 (5 years ago)
- File:
-
- 1 edited
-
libpipi/trunk/pipi/dither/ordered.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.
