Import of pkgsrc-2013Q2

This commit is contained in:
2013-09-26 17:14:40 +02:00
commit 785076ae39
74991 changed files with 4380255 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
resize_image is a little utility to resize images. You can read
JPEG, GIF, Targa (TGA), PBM, PGM and PPM images. You will need
JPEG library to use it. You can only output in PPM or JPEG formats.
It is written in C so if you want to compile you'll needed a C
compiler (only tested with gcc under Linux i386).
+22
View File
@@ -0,0 +1,22 @@
# $NetBSD: Makefile,v 1.18 2012/11/01 19:52:03 joerg Exp $
#
DISTNAME= resize_image-0.6
PKGREVISION= 5
CATEGORIES= graphics
MASTER_SITES= http://lab.erasme.org/resize_image/
MAINTAINER= pkgsrc-users@NetBSD.org
HOMEPAGE= http://lab.erasme.org/resize_image/
COMMENT= Fast image resizing tool
USE_TOOLS+= gmake
CFLAGS+= -DUNIX
INSTALLATION_DIRS= bin
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/resize_image ${DESTDIR}${PREFIX}/bin
.include "../../mk/jpeg.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"
+2
View File
@@ -0,0 +1,2 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2003/09/10 21:44:46 itojun Exp $
bin/resize_image
+10
View File
@@ -0,0 +1,10 @@
$NetBSD: distinfo,v 1.5 2012/11/01 19:52:03 joerg Exp $
SHA1 (resize_image-0.6.tar.gz) = e26f53db67de09bc641caf1ced4742a97be0c4a4
RMD160 (resize_image-0.6.tar.gz) = 42d2ab8813835d51aa984546cb5f2c003e01f667
Size (resize_image-0.6.tar.gz) = 87249 bytes
SHA1 (patch-aa) = 65098e5be882473082afcf1411fe32f3fcb9dacc
SHA1 (patch-ab) = 1ef571f47e79a018dfa73d5996265059edd746d1
SHA1 (patch-ac) = 98b9d32e7d6ba96244a27288a9b36b3a7d41fbd1
SHA1 (patch-ad) = a11e21c71ef4dda8d4ff5311dc57c857fe84f064
SHA1 (patch-image_image__trans.c) = 1457b87bdbc7aa1f21c6cc8b0004cbbf9fe6b334
+42
View File
@@ -0,0 +1,42 @@
$NetBSD: patch-aa,v 1.2 2010/12/18 08:15:52 dsainty Exp $
--- Makefile.orig 2002-08-08 20:13:01.000000000 +0900
+++ Makefile 2003-09-11 06:40:40.000000000 +0900
@@ -1,17 +1,17 @@
# compilateur utilisé
-CC = gcc -O2 -DUNIX -Wall -g
+#CC = gcc -O2 -DUNIX -Wall -g
# compilateur utilisé quand une forte optimisation est nécessaire
-CC_OPT = gcc -O6 -DUNIX -Wall -g
+#CC_OPT = gcc -O6 -DUNIX -Wall -g
# répertoire on seront placés les fichiers .o
OBJ_DIR = obj
# tout les repertoires a rajouter dans le PATH utilise pour les includes
INCLUDE_PATH = -Iimage -Iutils
# tout les repertoires a rajouter dans le PATH utilise lors du linkage
LIBRARY_PATH =
# toutes les bibliotheques a utiliser au linkage
-LIBRARY = -lm -ljpeg
+LIBRARY = $(LDFLAGS) -lm -ljpeg
############################################################
# pour le programme final (le linkage)
@@ -38,14 +38,14 @@
include image/Makefile
resize_image : $(OBJ_DIR)/resize_image.o $(IMAGE_OBJS) $(UTILS_OBJS)
- $(CC) $(OBJ_DIR)/resize_image.o $(IMAGE_OBJS) $(UTILS_OBJS) $(LIBRARY_PATH)\
+ $(CC) $(CFLAGS) $(OBJ_DIR)/resize_image.o $(IMAGE_OBJS) $(UTILS_OBJS) $(LIBRARY_PATH)\
$(LIBRARY) -o $@
############################################################
# pour le programmes de demonstration
$(OBJ_DIR)/resize_image.o : resize_image.c $(IMAGE_H) $(UTILS_H)
- $(CC) -c resize_image.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c resize_image.c -o $@ $(INCLUDE_PATH)
############################################################
# pour faire le ménage
+54
View File
@@ -0,0 +1,54 @@
$NetBSD: patch-ab,v 1.1.1.1 2003/09/10 21:44:46 itojun Exp $
--- image/Makefile 2002-08-08 20:13:01.000000000 +0900
+++ image/Makefile 2003-09-11 06:36:38.000000000 +0900
@@ -35,38 +35,38 @@
# pour les images
$(OBJ_DIR)/image.o : $(IMAGE_DIR)/image.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC_OPT) -c $(IMAGE_DIR)/image.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_draw_func.o : $(IMAGE_DIR)/image.h $(IMAGE_DIR)/image_draw_func.c\
$(IMAGE_DIR)/image_draw_func.h $(UTILS_H)
- $(CC_OPT) -c $(IMAGE_DIR)/image_draw_func.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_draw_func.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_trans.o : $(IMAGE_DIR)/image_trans.c $(IMAGE_DIR)/image.h\
$(IMAGE_DIR)/image_draw_func.h $(IMAGE_DIR)/color.h $(UTILS_H)
- $(CC_OPT) -c $(IMAGE_DIR)/image_trans.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_trans.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_filter.o : $(IMAGE_DIR)/image_filter.c $(IMAGE_DIR)/image.h\
$(IMAGE_DIR)/image_draw_func.h $(IMAGE_DIR)/color.h $(UTILS_H)
- $(CC_OPT) -c $(IMAGE_DIR)/image_filter.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_filter.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_from_bmp.o : $(IMAGE_DIR)/image_from_bmp.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC) -c $(IMAGE_DIR)/image_from_bmp.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_from_bmp.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_from_gif.o : $(IMAGE_DIR)/image_from_gif.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC) -c $(IMAGE_DIR)/image_from_gif.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_from_gif.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_from_tga.o : $(IMAGE_DIR)/image_from_tga.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC) -c $(IMAGE_DIR)/image_from_tga.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_from_tga.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_from_jpeg.o : $(IMAGE_DIR)/image_from_jpeg.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC) -c $(IMAGE_DIR)/image_from_jpeg.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_from_jpeg.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_from_pgm.o : $(IMAGE_DIR)/image_from_pgm.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC) -c $(IMAGE_DIR)/image_from_pgm.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_from_pgm.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_from_ppm.o : $(IMAGE_DIR)/image_from_ppm.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC) -c $(IMAGE_DIR)/image_from_ppm.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_from_ppm.c -o $@ $(INCLUDE_PATH)
$(OBJ_DIR)/image_from_pbm.o : $(IMAGE_DIR)/image_from_pbm.c $(IMAGE_DIR)/image.h $(UTILS_H)
- $(CC) -c $(IMAGE_DIR)/image_from_pbm.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(IMAGE_DIR)/image_from_pbm.c -o $@ $(INCLUDE_PATH)
+10
View File
@@ -0,0 +1,10 @@
$NetBSD: patch-ac,v 1.1.1.1 2003/09/10 21:44:46 itojun Exp $
--- utils/Makefile- 2003-09-11 06:39:20.000000000 +0900
+++ utils/Makefile 2003-09-11 06:39:34.000000000 +0900
@@ -11,4 +11,4 @@
# pour gerer les listes doublements chainees
$(OBJ_DIR)/list.o : $(UTILS_DIR)/list.c $(UTILS_DIR)/list.h $(UTILS_DIR)/general.h
- $(CC_OPT) -c $(UTILS_DIR)/list.c -o $@ $(INCLUDE_PATH)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(UTILS_DIR)/list.c -o $@ $(INCLUDE_PATH)
+38
View File
@@ -0,0 +1,38 @@
$NetBSD: patch-ad,v 1.1 2007/10/10 22:47:46 rillig Exp $
Using macros for types belongs to the bad habits of C programmers.
--- utils/general.h.orig 2002-08-08 13:13:01.000000000 +0200
+++ utils/general.h 2007-10-11 00:45:50.000000000 +0200
@@ -9,9 +9,7 @@
#ifndef __GENERAL_H__
#define __GENERAL_H__
-#ifndef NULL
-#define NULL 0
-#endif
+#include <stddef.h>
#ifndef FALSE
#define FALSE 0
@@ -22,7 +20,8 @@
#endif
#ifndef uint
-#define uint unsigned int
+typedef unsigned int resizeimage_uint;
+#define uint resizeimage_uint
#endif
#ifndef int8
@@ -46,7 +45,9 @@
#endif
#ifndef boolean
-#define boolean int
+typedef int boolean;
+#define boolean boolean
+#define HAVE_BOOLEAN
#endif
#ifndef pointer
@@ -0,0 +1,573 @@
$NetBSD: patch-image_image__trans.c,v 1.1 2012/11/01 19:52:03 joerg Exp $
Remove nested functions.
--- image/image_trans.c.orig 2012-10-30 19:37:02.000000000 +0000
+++ image/image_trans.c
@@ -200,6 +200,7 @@ void image_resize_dct(image *pdest, imag
uint8 val[8][8];
float dct_res[8][8]; /* coefficient 3d qui correspondent a nos pixels */
float dc_coeff;
+ uint8 res;
/* initialise le tableau des fonctions de bases */
double f1,f2,tmp;
@@ -215,70 +216,65 @@ void image_resize_dct(image *pdest, imag
uint32 nb_pix;
float percent_done,percent_tmp;
- void init_dct(void)
- {
- f1 = 2.0*atan(1.0)/8.0;
- for(y=0;y<8;y++){ /* de la fonction 0 a la 7 */
- f2=(double)y*f1;
- for(x=0;x<8;x++){ /* du point 0 au point 7 de la fonction */
- tmp=cos((double)(2*x+1)*f2);
- if(y==0) dct_coeff[y][x]=(float)(1.0/sqrt(2.0));
- else dct_coeff[y][x]=(float)tmp;
- }
- }
- dc_coeff = 1.0/sqrt(2.0);
- }
-
- void calcul_dct(void)
- {
- for(i2 = 0; i2 < 8; i2++)
- {
- for(i1 = 0; i1 < 8; i1++)
- {
- dct_res[i2][i1] = 0.0;
-
- for(y = 0; y < 8; y++)
- for(x = 0; x < 8; x++)
- dct_res[i2][i1] += dct_coeff[i1][x] * dct_coeff[i2][y]
- * (float)val[y][x];
- dct_res[i2][i1] /= 16.0;
- }
- }
- } /* fin de calcul_dct() */
-
- uint8 calcul_pix(float px, float py)
- { uint8 res;
-
- float temp;
- float dct_coeff_hor[8],dct_coeff_ver[8];
-
- for(y=0;y<8;y++)
- {
- f2=(double)y*f1;
- if(y==0) {
- dct_coeff_hor[y]=dc_coeff;
- } else {
- tmp=cos((double)(2.0*(4.0-px)+1.0)*f2);
- dct_coeff_hor[y]=(float)tmp;
- }
- if(y==0) {
- dct_coeff_ver[y]=dc_coeff;
- } else {
- tmp=cos((double)(2.0*(4.0-py)+1.0)*f2);
- dct_coeff_ver[y]=(float)tmp;
- }
- }
-
- temp = 0.0;
- for(y=0;y<8;y++)
- for(x=0;x<8;x++)
- temp += dct_coeff_hor[x] * dct_coeff_ver[y] * dct_res[y][x];
-
- if(temp > 255.0) res = 255;
- else if(temp < 0.0) res = 0;
- else res = (uint8)temp;
- return(res);
- }
+#define init_dct() do { \
+ f1 = 2.0*atan(1.0)/8.0; \
+ for(y=0;y<8;y++){ /* de la fonction 0 a la 7 */ \
+ f2=(double)y*f1; \
+ for(x=0;x<8;x++){ /* du point 0 au point 7 de la fonction */ \
+ tmp=cos((double)(2*x+1)*f2); \
+ if(y==0) dct_coeff[y][x]=(float)(1.0/sqrt(2.0)); \
+ else dct_coeff[y][x]=(float)tmp; \
+ } \
+ } \
+ dc_coeff = 1.0/sqrt(2.0); \
+ } while (0)
+
+#define calcul_dct() do { \
+ for(i2 = 0; i2 < 8; i2++) \
+ { \
+ for(i1 = 0; i1 < 8; i1++) \
+ { \
+ dct_res[i2][i1] = 0.0; \
+ \
+ for(y = 0; y < 8; y++) \
+ for(x = 0; x < 8; x++) \
+ dct_res[i2][i1] += dct_coeff[i1][x] * dct_coeff[i2][y] \
+ * (float)val[y][x]; \
+ dct_res[i2][i1] /= 16.0; \
+ } \
+ } \
+ } /* fin de calcul_dct() */ while (0)
+
+#define calcul_pix(px, py) do { \
+ float temp; \
+ float dct_coeff_hor[8],dct_coeff_ver[8]; \
+ \
+ for(y=0;y<8;y++) \
+ { \
+ f2=(double)y*f1; \
+ if(y==0) { \
+ dct_coeff_hor[y]=dc_coeff; \
+ } else { \
+ tmp=cos((double)(2.0*(4.0-px)+1.0)*f2); \
+ dct_coeff_hor[y]=(float)tmp; \
+ } \
+ if(y==0) { \
+ dct_coeff_ver[y]=dc_coeff; \
+ } else { \
+ tmp=cos((double)(2.0*(4.0-py)+1.0)*f2); \
+ dct_coeff_ver[y]=(float)tmp; \
+ } \
+ } \
+ \
+ temp = 0.0; \
+ for(y=0;y<8;y++) \
+ for(x=0;x<8;x++) \
+ temp += dct_coeff_hor[x] * dct_coeff_ver[y] * dct_res[y][x]; \
+ \
+ if(temp > 255.0) res = 255; \
+ else if(temp < 0.0) res = 0; \
+ else res = (uint8)temp; \
+ } while(0)
/* corp de la procedure */
init_dct();
@@ -314,19 +310,22 @@ void image_resize_dct(image *pdest, imag
for(x=0;x<8;x++)
val[y][x] = COL_RED(get_pix(psrc,((int32)rx)-x+4,((int32)ry)-y+4));
calcul_dct();
- SET_COL_RED(vcol,calcul_pix(x_dist, y_dist));
+ calcul_pix(x_dist, y_dist);
+ SET_COL_RED(vcol, res);
/* pour le vert */
for(y=0;y<8;y++)
for(x=0;x<8;x++)
val[y][x] = COL_GREEN(get_pix(psrc,((int32)rx)-x+4,((int32)ry)-y+4));
calcul_dct();
- SET_COL_GREEN(vcol,calcul_pix(x_dist, y_dist));
+ calcul_pix(x_dist, y_dist);
+ SET_COL_GREEN(vcol,res);
/* pour le bleu */
for(y=0;y<8;y++)
for(x=0;x<8;x++)
val[y][x] = COL_BLUE(get_pix(psrc,((int32)rx)-x+4,((int32)ry)-y+4));
calcul_dct();
- SET_COL_BLUE(vcol,calcul_pix(x_dist, y_dist));
+ calcul_pix(x_dist, y_dist);
+ SET_COL_BLUE(vcol,res);
/* on place le pixel calcule */
put_pix_alpha_replace(pdest, vx, vy, vcol);
@@ -370,25 +369,26 @@ void image_resize_catmull_rom(image *pde
image *img_width;
/* calcul la valeur du point a la position t */
- void calcul_dot(float t)
- { float t2,t3;
- float xt,yt,zt,wt;
-
- /* calcul t au carre */
- t2 = t*t;
- /* calcul t au cube */
- t3 = t2*t;
-
- /* on multiplie le vecteur (t3,t2,t,1) par la matrice mat */
- xt = t3*mat[0] + t2*mat[4] + t*mat[ 8] + mat[12];
- yt = t3*mat[1] + t2*mat[5] + t*mat[ 9] + mat[13];
- zt = t3*mat[2] + t2*mat[6] + t*mat[10] + mat[14];
- wt = t3*mat[3] + t2*mat[7] + t*mat[11] + mat[15];
- /* on multiplie le resultat par la matrice des contraintes */
- x = xt*dot[0] + yt*dot[3] + zt*dot[6] + wt*dot[9];
- y = xt*dot[1] + yt*dot[4] + zt*dot[7] + wt*dot[10];
- z = xt*dot[2] + yt*dot[5] + zt*dot[8] + wt*dot[11];
- }
+#define calcul_dot(t_) do { \
+ float t = (t_); \
+ float t2,t3; \
+ float xt,yt,zt,wt; \
+ \
+ /* calcul t au carre */ \
+ t2 = t*t; \
+ /* calcul t au cube */ \
+ t3 = t2*t; \
+ \
+ /* on multiplie le vecteur (t3,t2,t,1) par la matrice mat */ \
+ xt = t3*mat[0] + t2*mat[4] + t*mat[ 8] + mat[12]; \
+ yt = t3*mat[1] + t2*mat[5] + t*mat[ 9] + mat[13]; \
+ zt = t3*mat[2] + t2*mat[6] + t*mat[10] + mat[14]; \
+ wt = t3*mat[3] + t2*mat[7] + t*mat[11] + mat[15]; \
+ /* on multiplie le resultat par la matrice des contraintes */ \
+ x = xt*dot[0] + yt*dot[3] + zt*dot[6] + wt*dot[9]; \
+ y = xt*dot[1] + yt*dot[4] + zt*dot[7] + wt*dot[10]; \
+ z = xt*dot[2] + yt*dot[5] + zt*dot[8] + wt*dot[11]; \
+ } while (0)
width_scale = (float)psrc->width / (float)width;
height_scale = (float)psrc->height / (float)height;
@@ -572,40 +572,43 @@ void image_resize_tv2(image *pdest, imag
{ pix vcol,vcol1,vcol2,vcol3,vcol4;
int32 vx,vy;
- void redim_col(float dim)
- {
- vcol = COL(
- (uint8)MIN(255,MAX(0,(((float)COL_RED(vcol))*dim))),
- (uint8)MIN(255,MAX(0,(((float)COL_GREEN(vcol))*dim))),
- (uint8)MIN(255,MAX(0,(((float)COL_BLUE(vcol))*dim))));
- }
-
- void redim_lum(float dim_y,float dim_cr,float dim_cb)
- { float cr,cb,y;
- float r,g,b;
-
- y = 0.299*(float)COL_RED(vcol)+
- 0.587*(float)COL_GREEN(vcol)+
- 0.114*(float)COL_BLUE(vcol);
- cr = (float)COL_RED(vcol) - y;
- cb = (float)COL_BLUE(vcol) - y;
-
-/* y = (1.0+cos(M_PI+((y/255.0)*M_PI)))*128.0;*/
-
- y *= dim_y;
- cr *= dim_cr;
- cb *= dim_cb;
-
- r = cr + y;
- b = cb + y;
- g = y*1.7 - r*0.509 - b*0.194;
-
- r = MIN(255.0,MAX(0,r));
- g = MIN(255.0,MAX(0,g));
- b = MIN(255.0,MAX(0,b));
-
- vcol = COL((uint8)r,(uint8)g,(uint8)b);
- }
+#define redim_col(dim_) do { \
+ float dim = (dim_); \
+ vcol = COL( \
+ (uint8)MIN(255,MAX(0,(((float)COL_RED(vcol))*dim))), \
+ (uint8)MIN(255,MAX(0,(((float)COL_GREEN(vcol))*dim))), \
+ (uint8)MIN(255,MAX(0,(((float)COL_BLUE(vcol))*dim)))); \
+ } while(0)
+
+#define redim_lum(dim_y_, dim_cr_, dim_cb_) do { \
+ float dim_y = (dim_y_); \
+ float dim_cr = (dim_cr_); \
+ float dim_cb = (dim_cb_); \
+ float cr,cb,y; \
+ float r,g,b; \
+ \
+ y = 0.299*(float)COL_RED(vcol)+ \
+ 0.587*(float)COL_GREEN(vcol)+ \
+ 0.114*(float)COL_BLUE(vcol); \
+ cr = (float)COL_RED(vcol) - y; \
+ cb = (float)COL_BLUE(vcol) - y; \
+ \
+/* y = (1.0+cos(M_PI+((y/255.0)*M_PI)))*128.0;*/ \
+ \
+ y *= dim_y; \
+ cr *= dim_cr; \
+ cb *= dim_cb; \
+ \
+ r = cr + y; \
+ b = cb + y; \
+ g = y*1.7 - r*0.509 - b*0.194; \
+ \
+ r = MIN(255.0,MAX(0,r)); \
+ g = MIN(255.0,MAX(0,g)); \
+ b = MIN(255.0,MAX(0,b)); \
+ \
+ vcol = COL((uint8)r,(uint8)g,(uint8)b); \
+ } while (0)
/* si les préconditions ne sont pas remplies, on quitte */
if((pdest == NULL) || (psrc == NULL) ||
@@ -653,135 +656,136 @@ void image_resize_tv2(image *pdest, imag
/* Redimentionne l'image psrc et place le resultat */
/* dans pdest. pdest doit être 2 fois plus grande que psrc. */
void image_resize_most(image *pdest, image *psrc)
-{ pix vcol1,vcol2,vcol3,vcol4,vcolm;
+{ pix vcol1,vcol2,vcol3,vcol4,vcolm, most_upper, most_left;
int32 vx,vy;
- pix find_most_middle(void)
- { float y[4];
- int pos[4];
- int min_pos, i1, i2;
- float swap_float;
- int swap_int;
-
- y[0] = (0.299*(float)COL_RED(vcol1)+
- 0.587*(float)COL_GREEN(vcol1)+
- 0.114*(float)COL_BLUE(vcol1))*1.2;
- y[1] = 0.299*(float)COL_RED(vcol2)+
- 0.587*(float)COL_GREEN(vcol2)+
- 0.114*(float)COL_BLUE(vcol2);
- y[2] = 0.299*(float)COL_RED(vcol3)+
- 0.587*(float)COL_GREEN(vcol3)+
- 0.114*(float)COL_BLUE(vcol3);
- y[3] = 0.299*(float)COL_RED(vcol4)+
- 0.587*(float)COL_GREEN(vcol4)+
- 0.114*(float)COL_BLUE(vcol4);
- pos[0] = 0; pos[1] = 1; pos[2] = 2; pos[3] = 3;
-
- for(i1=0;i1<4-1;i1++)
- {
- min_pos = i1;
- for(i2=i1;i2<4;i2++)
- {
- if(y[i2] < y[min_pos]) min_pos = i2;
- }
- swap_float = y[i1];
- swap_int = pos[i1];
- y[i1] = y[min_pos];
- pos[i1] = pos[min_pos];
- y[min_pos] = swap_float;
- pos[min_pos] = swap_int;
- }
- switch(pos[1])
- {
- case 0 : return(vcol1);
- case 1 : return(vcol2);
- case 2 : return(vcol3);
- case 3 : return(vcol4);
- }
- return(BLACK);
- }
-
- pix find_most_upper(void)
- { float y[3];
- int pos[3];
- int min_pos, i1, i2;
- float swap_float;
- int swap_int;
-
- y[0] = 0.299*(float)COL_RED(vcol1)+
- 0.587*(float)COL_GREEN(vcol1)+
- 0.114*(float)COL_BLUE(vcol1);
- y[1] = 0.299*(float)COL_RED(vcol2)+
- 0.587*(float)COL_GREEN(vcol2)+
- 0.114*(float)COL_BLUE(vcol2);
- y[2] = (0.299*(float)COL_RED(vcolm)+
- 0.587*(float)COL_GREEN(vcolm)+
- 0.114*(float)COL_BLUE(vcolm))*1.2;
- pos[0] = 0; pos[1] = 1; pos[2] = 2;
-
- for(i1=0;i1<3-1;i1++)
- {
- min_pos = i1;
- for(i2=i1;i2<3;i2++)
- {
- if(y[i2] < y[min_pos]) min_pos = i2;
- }
- swap_float = y[i1];
- swap_int = pos[i1];
- y[i1] = y[min_pos];
- pos[i1] = pos[min_pos];
- y[min_pos] = swap_float;
- pos[min_pos] = swap_int;
- }
- switch(pos[1])
- {
- case 0 : return(vcol1);
- case 1 : return(vcol2);
- case 2 : return(vcolm);
- }
- return(vcolm);
- }
-
- pix find_most_left(void)
- { float y[3];
- int pos[3];
- int min_pos, i1, i2;
- float swap_float;
- int swap_int;
-
- y[0] = 0.299*(float)COL_RED(vcol1)+
- 0.587*(float)COL_GREEN(vcol1)+
- 0.114*(float)COL_BLUE(vcol1);
- y[1] = 0.299*(float)COL_RED(vcol3)+
- 0.587*(float)COL_GREEN(vcol3)+
- 0.114*(float)COL_BLUE(vcol3);
- y[2] = (0.299*(float)COL_RED(vcolm)+
- 0.587*(float)COL_GREEN(vcolm)+
- 0.114*(float)COL_BLUE(vcolm))*1.2;
- pos[0] = 0; pos[1] = 1; pos[2] = 2;
-
- for(i1=0;i1<3-1;i1++)
- {
- min_pos = i1;
- for(i2=i1;i2<3;i2++)
- {
- if(y[i2] < y[min_pos]) min_pos = i2;
- }
- swap_float = y[i1];
- swap_int = pos[i1];
- y[i1] = y[min_pos];
- pos[i1] = pos[min_pos];
- y[min_pos] = swap_float;
- pos[min_pos] = swap_int;
- }
- switch(pos[1])
- {
- case 0 : return(vcol1);
- case 1 : return(vcol3);
- case 2 : return(vcolm);
- }
- return(vcolm);
- }
+#define find_most_middle() do { \
+ float y[4]; \
+ int pos[4]; \
+ int min_pos, i1, i2; \
+ float swap_float; \
+ int swap_int; \
+ \
+ y[0] = (0.299*(float)COL_RED(vcol1)+ \
+ 0.587*(float)COL_GREEN(vcol1)+ \
+ 0.114*(float)COL_BLUE(vcol1))*1.2; \
+ y[1] = 0.299*(float)COL_RED(vcol2)+ \
+ 0.587*(float)COL_GREEN(vcol2)+ \
+ 0.114*(float)COL_BLUE(vcol2); \
+ y[2] = 0.299*(float)COL_RED(vcol3)+ \
+ 0.587*(float)COL_GREEN(vcol3)+ \
+ 0.114*(float)COL_BLUE(vcol3); \
+ y[3] = 0.299*(float)COL_RED(vcol4)+ \
+ 0.587*(float)COL_GREEN(vcol4)+ \
+ 0.114*(float)COL_BLUE(vcol4); \
+ pos[0] = 0; pos[1] = 1; pos[2] = 2; pos[3] = 3; \
+ \
+ for(i1=0;i1<4-1;i1++) \
+ { \
+ min_pos = i1; \
+ for(i2=i1;i2<4;i2++) \
+ { \
+ if(y[i2] < y[min_pos]) min_pos = i2; \
+ } \
+ swap_float = y[i1]; \
+ swap_int = pos[i1]; \
+ y[i1] = y[min_pos]; \
+ pos[i1] = pos[min_pos]; \
+ y[min_pos] = swap_float; \
+ pos[min_pos] = swap_int; \
+ } \
+ switch(pos[1]) \
+ { \
+ case 0 : vcom = vcol1; break; \
+ case 1 : vcom = vcol2; break; \
+ case 2 : vcom = vcol3; break; \
+ case 3 : vcom = vcol4; break; \
+ default: \
+ vcom = BLACK; break; \
+ } \
+ } while(0)
+
+#define find_most_upper(void) do { \
+ float y[3]; \
+ int pos[3]; \
+ int min_pos, i1, i2; \
+ float swap_float; \
+ int swap_int; \
+ \
+ y[0] = 0.299*(float)COL_RED(vcol1)+ \
+ 0.587*(float)COL_GREEN(vcol1)+ \
+ 0.114*(float)COL_BLUE(vcol1); \
+ y[1] = 0.299*(float)COL_RED(vcol2)+ \
+ 0.587*(float)COL_GREEN(vcol2)+ \
+ 0.114*(float)COL_BLUE(vcol2); \
+ y[2] = (0.299*(float)COL_RED(vcolm)+ \
+ 0.587*(float)COL_GREEN(vcolm)+ \
+ 0.114*(float)COL_BLUE(vcolm))*1.2; \
+ pos[0] = 0; pos[1] = 1; pos[2] = 2; \
+ \
+ for(i1=0;i1<3-1;i1++) \
+ { \
+ min_pos = i1; \
+ for(i2=i1;i2<3;i2++) \
+ { \
+ if(y[i2] < y[min_pos]) min_pos = i2; \
+ } \
+ swap_float = y[i1]; \
+ swap_int = pos[i1]; \
+ y[i1] = y[min_pos]; \
+ pos[i1] = pos[min_pos]; \
+ y[min_pos] = swap_float; \
+ pos[min_pos] = swap_int; \
+ } \
+ switch(pos[1]) \
+ { \
+ case 0 : most_upper = vcol1; break; \
+ case 1 : most_upper = vcol2; break; \
+ case 2 : most_upper = vcolm; break; \
+ default: most_upper = vcolm; break; \
+ } \
+ } while (0)
+
+#define find_most_left() do { \
+ float y[3]; \
+ int pos[3]; \
+ int min_pos, i1, i2; \
+ float swap_float; \
+ int swap_int; \
+ \
+ y[0] = 0.299*(float)COL_RED(vcol1)+ \
+ 0.587*(float)COL_GREEN(vcol1)+ \
+ 0.114*(float)COL_BLUE(vcol1); \
+ y[1] = 0.299*(float)COL_RED(vcol3)+ \
+ 0.587*(float)COL_GREEN(vcol3)+ \
+ 0.114*(float)COL_BLUE(vcol3); \
+ y[2] = (0.299*(float)COL_RED(vcolm)+ \
+ 0.587*(float)COL_GREEN(vcolm)+ \
+ 0.114*(float)COL_BLUE(vcolm))*1.2; \
+ pos[0] = 0; pos[1] = 1; pos[2] = 2; \
+ \
+ for(i1=0;i1<3-1;i1++) \
+ { \
+ min_pos = i1;\
+ for(i2=i1;i2<3;i2++) \
+ { \
+ if(y[i2] < y[min_pos]) min_pos = i2; \
+ } \
+ swap_float = y[i1]; \
+ swap_int = pos[i1]; \
+ y[i1] = y[min_pos]; \
+ pos[i1] = pos[min_pos]; \
+ y[min_pos] = swap_float; \
+ pos[min_pos] = swap_int; \
+ } \
+ switch(pos[1]) \
+ { \
+ case 0 : most_left = vcol1; break; \
+ case 1 : most_left = vcol2; break; \
+ case 2 : most_left = vcolm; break; \
+ default : most_left = vcolm; break; \
+ } \
+ } while(0)
/* si les préconditions ne sont pas remplies, on quitte */
if((pdest == NULL) || (psrc == NULL) ||
@@ -798,10 +802,11 @@ void image_resize_most(image *pdest, ima
vcol4 = get_pix(psrc, vx+1, vy+1);
put_pix_alpha_replace(pdest, (vx<<1), (vy<<1), vcol1);
- vcolm = find_most_middle();
put_pix_alpha_replace(pdest, (vx<<1)+1, (vy<<1)+1, vcolm);
- put_pix_alpha_replace(pdest, (vx<<1)+1, (vy<<1), find_most_upper());
- put_pix_alpha_replace(pdest, (vx<<1), (vy<<1)+1, find_most_left());
+ find_most_upper();
+ put_pix_alpha_replace(pdest, (vx<<1)+1, (vy<<1), most_upper);
+ find_most_left();
+ put_pix_alpha_replace(pdest, (vx<<1), (vy<<1)+1, most_left);
}
}
}