git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2260 92316355-f0b4-4df1-b90c-862c8a59935fremotes/tiles
| @@ -34,8 +34,9 @@ extern void pipi_save(pipi_image_t *img, const char *name); | |||||
| extern int pipi_getgray(pipi_image_t const *img, int x, int y, int *g); | extern int pipi_getgray(pipi_image_t const *img, int x, int y, int *g); | ||||
| extern int pipi_getpixel(pipi_image_t const *img, | extern int pipi_getpixel(pipi_image_t const *img, | ||||
| int x, int y, int *r, int *g, int *b); | |||||
| extern int pipi_setpixel(pipi_image_t *img, int x, int y, int r, int g, int b); | |||||
| int x, int y, double *r, double *g, double *b); | |||||
| extern int pipi_setpixel(pipi_image_t *img, int x, int y, | |||||
| double r, double g, double b); | |||||
| extern pipi_image_t *pipi_resize(pipi_image_t const *, int, int); | extern pipi_image_t *pipi_resize(pipi_image_t const *, int, int); | ||||
| @@ -25,11 +25,11 @@ | |||||
| #include <math.h> | #include <math.h> | ||||
| #include "pipi_internals.h" | |||||
| #include "pipi.h" | #include "pipi.h" | ||||
| #include "pipi_internals.h" | |||||
| #define C2I(p) ((int)255.999*pow(((double)p)/255., 2.2)) | |||||
| #define I2C(p) ((int)255.999*pow(((double)p)/255., 1./2.2)) | |||||
| #define C2I(p) (pow(((double)p)/255., 2.2)) | |||||
| #define I2C(p) ((int)255.999*pow(((double)p), 1./2.2)) | |||||
| int pipi_getgray(pipi_image_t const *img, int x, int y, int *g) | int pipi_getgray(pipi_image_t const *img, int x, int y, int *g) | ||||
| { | { | ||||
| @@ -45,15 +45,13 @@ int pipi_getgray(pipi_image_t const *img, int x, int y, int *g) | |||||
| } | } | ||||
| int pipi_getpixel(pipi_image_t const *img, | int pipi_getpixel(pipi_image_t const *img, | ||||
| int x, int y, int *r, int *g, int *b) | |||||
| int x, int y, double *r, double *g, double *b) | |||||
| { | { | ||||
| uint8_t *pixel; | uint8_t *pixel; | ||||
| if(x < 0 || y < 0 || x >= img->width || y >= img->height) | if(x < 0 || y < 0 || x >= img->width || y >= img->height) | ||||
| { | { | ||||
| *r = 255; | |||||
| *g = 255; | |||||
| *b = 255; | |||||
| *r = *g = *b = 1.; | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| @@ -66,7 +64,7 @@ int pipi_getpixel(pipi_image_t const *img, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int pipi_setpixel(pipi_image_t *img, int x, int y, int r, int g, int b) | |||||
| int pipi_setpixel(pipi_image_t *img, int x, int y, double r, double g, double b) | |||||
| { | { | ||||
| uint8_t *pixel; | uint8_t *pixel; | ||||
| @@ -22,12 +22,12 @@ | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "pipi_internals.h" | |||||
| #include "pipi.h" | #include "pipi.h" | ||||
| #include "pipi_internals.h" | |||||
| pipi_image_t *pipi_resize(pipi_image_t const *src, int w, int h) | pipi_image_t *pipi_resize(pipi_image_t const *src, int w, int h) | ||||
| { | { | ||||
| int *aline, *line; | |||||
| double *aline, *line; | |||||
| pipi_image_t *dst; | pipi_image_t *dst; | ||||
| int x, y, x0, y0, sw, dw, sh, dh, remy; | int x, y, x0, y0, sw, dw, sh, dh, remy; | ||||
| @@ -36,28 +36,28 @@ pipi_image_t *pipi_resize(pipi_image_t const *src, int w, int h) | |||||
| sw = src->width; sh = src->height; | sw = src->width; sh = src->height; | ||||
| dw = dst->width; dh = dst->height; | dw = dst->width; dh = dst->height; | ||||
| aline = malloc(3 * dw * sizeof(int)); | |||||
| line = malloc(3 * dw * sizeof(int)); | |||||
| aline = malloc(3 * dw * sizeof(double)); | |||||
| line = malloc(3 * dw * sizeof(double)); | |||||
| memset(line, 0, 3 * dw * sizeof(int)); | |||||
| memset(line, 0, 3 * dw * sizeof(double)); | |||||
| remy = 0; | remy = 0; | ||||
| for(y = 0, y0 = 0; y < dst->height; y++) | for(y = 0, y0 = 0; y < dst->height; y++) | ||||
| { | { | ||||
| int toty = 0, ny; | int toty = 0, ny; | ||||
| memset(aline, 0, 3 * dw * sizeof(int)); | |||||
| memset(aline, 0, 3 * dw * sizeof(double)); | |||||
| while(toty < sh) | while(toty < sh) | ||||
| { | { | ||||
| if(remy == 0) | if(remy == 0) | ||||
| { | { | ||||
| int r = 0, g = 0, b = 0; | |||||
| double r = 0, g = 0, b = 0; | |||||
| int remx = 0; | int remx = 0; | ||||
| for(x = 0, x0 = 0; x < dst->width; x++) | for(x = 0, x0 = 0; x < dst->width; x++) | ||||
| { | { | ||||
| int ar = 0, ag = 0, ab = 0; | |||||
| double ar = 0, ag = 0, ab = 0; | |||||
| int totx = 0, nx; | int totx = 0, nx; | ||||
| while(totx < sw) | while(totx < sw) | ||||