소스 검색

* getpixel/setpixel functions use doubles instead of ints for now.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2260 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 년 전
부모
커밋
d8aa3a24c3
3개의 변경된 파일17개의 추가작업 그리고 18개의 파일을 삭제
  1. +3
    -2
      pipi/pipi.h
  2. +6
    -8
      pipi/pixels.c
  3. +8
    -8
      pipi/resize.c

+ 3
- 2
pipi/pipi.h 파일 보기

@@ -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_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);



+ 6
- 8
pipi/pixels.c 파일 보기

@@ -25,11 +25,11 @@

#include <math.h>

#include "pipi_internals.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)
{
@@ -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 x, int y, int *r, int *g, int *b)
int x, int y, double *r, double *g, double *b)
{
uint8_t *pixel;

if(x < 0 || y < 0 || x >= img->width || y >= img->height)
{
*r = 255;
*g = 255;
*b = 255;
*r = *g = *b = 1.;
return -1;
}

@@ -66,7 +64,7 @@ int pipi_getpixel(pipi_image_t const *img,
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;



+ 8
- 8
pipi/resize.c 파일 보기

@@ -22,12 +22,12 @@
#include <stdlib.h>
#include <string.h>

#include "pipi_internals.h"
#include "pipi.h"
#include "pipi_internals.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;
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;
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;

for(y = 0, y0 = 0; y < dst->height; y++)
{
int toty = 0, ny;

memset(aline, 0, 3 * dw * sizeof(int));
memset(aline, 0, 3 * dw * sizeof(double));

while(toty < sh)
{
if(remy == 0)
{
int r = 0, g = 0, b = 0;
double r = 0, g = 0, b = 0;
int remx = 0;

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;

while(totx < sw)


불러오는 중...
취소
저장