Changeset 2812


Ignore:
Timestamp:
09/01/08 01:05:55 (5 years ago)
Author:
sam
Message:
  • Add a scale parameter to pipi_dither_ordered_ext().
  • Reimplement pipi_dither_halftone() using pipi_dither_ordered_ext().
Location:
libpipi/trunk/pipi
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/Makefile.am

    r2810 r2812  
    7777        dither/ediff.c \ 
    7878        dither/ordered.c \ 
    79         dither/halftone.c \ 
    8079        dither/ostromoukhov.c \ 
    8180        dither/dbs.c \ 
  • libpipi/trunk/pipi/context.c

    r2811 r2812  
    107107        else if(!strncmp(method, "ordered", 7)) 
    108108        { 
    109             double angle = .0; 
     109            double scale = 1., angle = .0; 
     110            if(ctx->nimages < 2) 
     111                return -1; 
    110112            method = strchr(method, ':'); 
    111113            if(method) 
    112                 angle = atof(method + 1); 
    113             if(ctx->nimages < 2) 
    114                 return -1; 
     114            { 
     115                scale = atof(method + 1); 
     116                method = strchr(method + 1, ':'); 
     117                if(method) 
     118                    angle = atof(method + 1); 
     119            } 
     120            if(scale <= 0.) 
     121                scale = 1.; 
    115122            dst = pipi_dither_ordered_ext(ctx->images[ctx->nimages - 2], src, 
    116                                           angle); 
     123                                          scale, angle); 
    117124            pipi_free(ctx->images[ctx->nimages - 2]); 
    118125            ctx->nimages--; 
  • libpipi/trunk/pipi/dither/ordered.c

    r2811 r2812  
    2626#include "pipi_internals.h" 
    2727 
     28pipi_image_t *pipi_dither_halftone(pipi_image_t *img, double r, double angle) 
     29{ 
     30#define PRECISION 4. 
     31    pipi_image_t *ret, *kernel; 
     32    int k = (r * PRECISION / sqrt(2.) + .5); 
     33 
     34    kernel = pipi_render_halftone(k, k); 
     35    ret = pipi_dither_ordered_ext(img, kernel, 1. / PRECISION, angle + 45.); 
     36    pipi_free(kernel); 
     37 
     38    return ret; 
     39} 
     40 
    2841pipi_image_t *pipi_dither_ordered(pipi_image_t *img, pipi_image_t *kernel) 
    2942{ 
    30     return pipi_dither_ordered_ext(img, kernel, 0.0); 
     43    return pipi_dither_ordered_ext(img, kernel, 1.0, 0.0); 
    3144} 
    3245 
    3346pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *img, pipi_image_t *kernel, 
    34                                       double angle) 
     47                                      double scale, double angle) 
    3548{ 
    3649    double sint, cost; 
     
    6174            float p, q; 
    6275 
    63             kx = (int)(cost * x - sint * y + 2 * w * h) % kw; 
    64             ky = (int)(cost * y + sint * x + 2 * w * h) % kh; 
     76            kx = (int)((cost * x - sint * y + 2 * w * h) / scale) % kw; 
     77            ky = (int)((cost * y + sint * x + 2 * w * h) / scale) % kh; 
    6578 
    6679            p = dstdata[y * w + x]; 
  • libpipi/trunk/pipi/pipi.h

    r2811 r2812  
    184184extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *); 
    185185extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *, 
    186                                              double); 
     186                                             double, double); 
    187187extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double); 
    188188extern pipi_image_t *pipi_dither_random(pipi_image_t *); 
Note: See TracChangeset for help on using the changeset viewer.