/* primitives graphiques deuxieme module (circa 2002) -------------------------------------------------- */ #include #include #include #include "../tthimage.h" /*::------------------------------------------------------------------::*/ #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) #endif /*::------------------------------------------------------------------::*/ /* * the easy one. */ int Image_paint_A_rect(Image_Desc *img, Image_Rect *rect, RGBA *rgba) { int xd, yd, xf, yf, x, y; int r, g, b, a0, a1, nbre; xd = max(0, rect->x); yd = max(0, rect->y); xf = min((img->width-1), (rect->x+rect->w)); yf = min((img->height-1), (rect->y+rect->h)); #if DEBUG_LEVEL fprintf(stderr, "Paint Alpha Rect: %d a; a1 = rgba->a; /* printf("a0 = %d a1 = %d\n", a0, a1); */ nbre = 0; for (x=xd; xr*a1 ) / 255; g = ( g*a0 + rgba->g*a1 ) / 255; b = ( b*a0 + rgba->b*a1 ) / 255; Image_plotRGB(img, x, y, r, g, b); nbre++; } } return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ /* * new 15 Janvier 2003. * premiere utilisation: l'ecriture des titres des * image de l'expovsition. */ int Image_fade_A_rect(Image_Desc *img, Image_Rect *rect, int alpha) { int xd, yd, xf, yf, x, y; int r, g, b ; xd = max(0, rect->x); yd = max(0, rect->y); xf = min((img->width-1), (rect->x+rect->w)); yf = min((img->height-1), (rect->y+rect->h)); #if DEBUG_LEVEL fprintf(stderr, "Fade Alpha Rect: %d < X < %d %d < Y < %d\n", xd, xf, yd, yf); fprintf(stderr, " coefficient alpha = %d\n", alpha); #endif for (x=xd; xheight; y++) { for (x=0; xwidth; x++) { Image_getRGB(src, x, y, &rs, &gs, &bs); Image_getRGB(tampon, x, y, &rt, >, &bt); rd = (rs * rt) / 256; } } if (clean_tampon) { fprintf(stderr, "clean %p in %s\n", tampon, __func__); Image_DeAllocate(tampon); free(tampon); } return FUNC_IS_ALPHA; } /*::------------------------------------------------------------------::*/