colors

extract colors from pictures
git clone git://git.2f30.org/colors.git
Log | Files | Refs | README | LICENSE

commit fd4989bb968aa7d72440cf2d2709e990ea0de272
parent e980a0e445c08a18ae5a79a02ffd2e0d38f4d2d1
Author: sin <sin@2f30.org>
Date:   Sat Jun  6 12:11:56 +0100

No need to use sqrtf() in distance()

This halves the processing time for large pictures.

Diffstat:
Makefile | 2+-
colors.c | 3+--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile @@ -5,7 +5,7 @@ MANPREFIX = $(PREFIX)/man CPPFLAGS = -I/usr/local/include CFLAGS = -Wall -O3 -LDFLAGS = -L/usr/local/lib -lm -lpng +LDFLAGS = -L/usr/local/lib -lpng OBJ = colors.o png.o BIN = colors diff --git a/colors.c b/colors.c @@ -2,7 +2,6 @@ #include <err.h> #include <errno.h> #include <limits.h> -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -43,7 +42,7 @@ distance(struct point *p1, struct point *p2) dx = (p1->x - p2->x) * (p1->x - p2->x); dy = (p1->y - p2->y) * (p1->y - p2->y); dz = (p1->z - p2->z) * (p1->z - p2->z); - return sqrtf(dx + dy + dz) + 0.5f; + return dx + dy + dz; } void