Changeset 2260 for libpipi


Ignore:
Timestamp:
Mar 11, 2008, 3:56:27 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • getpixel/setpixel functions use doubles instead of ints for now.
Location:
libpipi/trunk/pipi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/pipi.h

    r2244 r2260  
    3535extern int pipi_getgray(pipi_image_t const *img, int x, int y, int *g);
    3636extern int pipi_getpixel(pipi_image_t const *img,
    37                          int x, int y, int *r, int *g, int *b);
    38 extern int pipi_setpixel(pipi_image_t *img, int x, int y, int r, int g, int b);
     37                         int x, int y, double *r, double *g, double *b);
     38extern int pipi_setpixel(pipi_image_t *img, int x, int y,
     39                         double r, double g, double b);
    3940
    4041extern pipi_image_t *pipi_resize(pipi_image_t const *, int, int);
  • libpipi/trunk/pipi/pixels.c

    r2247 r2260  
    2626#include <math.h>
    2727
     28#include "pipi.h"
    2829#include "pipi_internals.h"
    29 #include "pipi.h"
    3030
    31 #define C2I(p) ((int)255.999*pow(((double)p)/255., 2.2))
    32 #define I2C(p) ((int)255.999*pow(((double)p)/255., 1./2.2))
     31#define C2I(p) (pow(((double)p)/255., 2.2))
     32#define I2C(p) ((int)255.999*pow(((double)p), 1./2.2))
    3333
    3434int pipi_getgray(pipi_image_t const *img, int x, int y, int *g)
     
    4646
    4747int pipi_getpixel(pipi_image_t const *img,
    48                   int x, int y, int *r, int *g, int *b)
     48                  int x, int y, double *r, double *g, double *b)
    4949{
    5050    uint8_t *pixel;
     
    5252    if(x < 0 || y < 0 || x >= img->width || y >= img->height)
    5353    {
    54         *r = 255;
    55         *g = 255;
    56         *b = 255;
     54        *r = *g = *b = 1.;
    5755        return -1;
    5856    }
     
    6765}
    6866
    69 int pipi_setpixel(pipi_image_t *img, int x, int y, int r, int g, int b)
     67int pipi_setpixel(pipi_image_t *img, int x, int y, double r, double g, double b)
    7068{
    7169    uint8_t *pixel;
  • libpipi/trunk/pipi/resize.c

    r2246 r2260  
    2323#include <string.h>
    2424
     25#include "pipi.h"
    2526#include "pipi_internals.h"
    26 #include "pipi.h"
    2727
    2828pipi_image_t *pipi_resize(pipi_image_t const *src, int w, int h)
    2929{
    30     int *aline, *line;
     30    double *aline, *line;
    3131    pipi_image_t *dst;
    3232    int x, y, x0, y0, sw, dw, sh, dh, remy;
     
    3737    dw = dst->width; dh = dst->height;
    3838
    39     aline = malloc(3 * dw * sizeof(int));
    40     line = malloc(3 * dw * sizeof(int));
     39    aline = malloc(3 * dw * sizeof(double));
     40    line = malloc(3 * dw * sizeof(double));
    4141
    42     memset(line, 0, 3 * dw * sizeof(int));
     42    memset(line, 0, 3 * dw * sizeof(double));
    4343    remy = 0;
    4444
     
    4747        int toty = 0, ny;
    4848
    49         memset(aline, 0, 3 * dw * sizeof(int));
     49        memset(aline, 0, 3 * dw * sizeof(double));
    5050
    5151        while(toty < sh)
     
    5353            if(remy == 0)
    5454            {
    55                 int r = 0, g = 0, b = 0;
     55                double r = 0, g = 0, b = 0;
    5656                int remx = 0;
    5757
    5858                for(x = 0, x0 = 0; x < dst->width; x++)
    5959                {
    60                     int ar = 0, ag = 0, ab = 0;
     60                    double ar = 0, ag = 0, ab = 0;
    6161                    int totx = 0, nx;
    6262
Note: See TracChangeset for help on using the changeset viewer.