blender.c File Reference

#include "config.h"
#include <mmintrin.h>
#include <ctype.h>
#include "afterbase.h"
#include "asvisual.h"
#include "scanline.h"
#include "blender.h"

Go to the source code of this file.

Classes

struct  merge_scanlines_func_desc

Defines

#define HUE_RED_TO_YELLOW   0
#define HUE_YELLOW_TO_GREEN   1
#define HUE_GREEN_TO_CYAN   2
#define HUE_CYAN_TO_BLUE   3
#define HUE_BLUE_TO_MAGENTA   4
#define HUE_MAGENTA_TO_RED   5
#define HUE16_RED   (HUE16_RANGE*HUE_RED_TO_YELLOW)
#define HUE16_YELLOW   (HUE16_RANGE*HUE_YELLOW_TO_GREEN)
#define HUE16_GREEN   (HUE16_RANGE*HUE_GREEN_TO_CYAN)
#define HUE16_CYAN   (HUE16_RANGE*HUE_CYAN_TO_BLUE)
#define HUE16_BLUE   (HUE16_RANGE*HUE_BLUE_TO_MAGENTA)
#define HUE16_MAGENTA   (HUE16_RANGE*HUE_MAGENTA_TO_RED)
#define MAKE_HUE16(hue, red, green, blue, min_val, max_val, delta)
#define INTERPRET_HUE16(hue, delta, max_val, red, green, blue)
#define BLEND_SCANLINES_HEADER
#define DO_SCREEN_VALUE(b, t)
#define DO_OVERLAY_VALUE(b, t)
#define MAX_MY_RND32   0x00ffffffff
#define MY_RND32()   (rnd32_seed = (1664525L*rnd32_seed)+1013904223L)

Functions

CARD32 rgb2value (CARD32 red, CARD32 green, CARD32 blue)
CARD32 rgb2saturation (CARD32 red, CARD32 green, CARD32 blue)
int normalize_degrees_val (int degrees)
CARD32 degrees2hue16 (int degrees)
int hue162degrees (CARD32 hue)
CARD32 rgb2hue (CARD32 red, CARD32 green, CARD32 blue)
CARD32 rgb2hsv (CARD32 red, CARD32 green, CARD32 blue, CARD32 *saturation, CARD32 *value)
void hsv2rgb (CARD32 hue, CARD32 saturation, CARD32 value, CARD32 *red, CARD32 *green, CARD32 *blue)
CARD32 rgb2luminance (CARD32 red, CARD32 green, CARD32 blue)
CARD32 rgb2hls (CARD32 red, CARD32 green, CARD32 blue, CARD32 *luminance, CARD32 *saturation)
void hls2rgb (CARD32 hue, CARD32 luminance, CARD32 saturation, CARD32 *red, CARD32 *green, CARD32 *blue)
merge_scanlines_func blend_scanlines_name2func (const char *name)
void list_scanline_merging (FILE *stream, const char *format)
void alphablend_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void allanon_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void tint_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void add_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void sub_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void diff_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void darken_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void lighten_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void screen_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void overlay_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void hue_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void saturate_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void value_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void colorize_scanlines (ASScanline *bottom, ASScanline *top, int offset)
void dissipate_scanlines (ASScanline *bottom, ASScanline *top, int offset)

Variables

merge_scanlines_func_desc std_merge_scanlines_func_list []


Define Documentation

#define BLEND_SCANLINES_HEADER

Value:

register int i = -1, max_i = bottom->width ; \
        register CARD32 *ta = top->alpha, *tr = top->red, *tg = top->green, *tb = top->blue; \
        register CARD32 *ba = bottom->alpha, *br = bottom->red, *bg = bottom->green, *bb = bottom->blue; \
        if( offset < 0 ){ \
                offset = -offset ; \
                ta += offset ;  tr += offset ;  tg += offset ;  tb += offset ; \
                if( (int)top->width-offset < max_i )    max_i = (int)(top->width)-offset ; \
        }else{ \
                if( offset > 0 ){ \
                        ba += offset ;  br += offset ;  bg += offset ;  bb += offset ; \
                        max_i -= offset ; }     \
                if( (int)(top->width) < max_i ) max_i = top->width ; \
        }

Definition at line 364 of file blender.c.

Referenced by add_scanlines(), allanon_scanlines(), alphablend_scanlines(), colorize_scanlines(), darken_scanlines(), diff_scanlines(), dissipate_scanlines(), hue_scanlines(), lighten_scanlines(), overlay_scanlines(), saturate_scanlines(), screen_scanlines(), sub_scanlines(), tint_scanlines(), and value_scanlines().

#define DO_OVERLAY_VALUE ( b,
t   ) 

Value:

tmp_screen = 0x0000FFFF - (((0x0000FFFF - (int)b[i]) * (0x0000FFFF - (int)t[i])) >> 16); \
                                tmp_mult   = (b[i] * t[i]) >> 16; \
                                res = (b[i] * tmp_screen + (0x0000FFFF - (int)b[i]) * tmp_mult) >> 16; \
                                b[i] = res < 0 ? 0 : res

Referenced by overlay_scanlines().

#define DO_SCREEN_VALUE ( b,
t   ) 

Value:

res1 = 0x0000FFFF - (int)b[i] ; res2 = 0x0000FFFF - (int)t[i] ;\
                        res1 = 0x0000FFFF - ((res1*res2)>>16); b[i] = res1 < 0 ? 0 : res1

Referenced by screen_scanlines().

#define HUE16_BLUE   (HUE16_RANGE*HUE_BLUE_TO_MAGENTA)

Definition at line 109 of file blender.c.

#define HUE16_CYAN   (HUE16_RANGE*HUE_CYAN_TO_BLUE)

Definition at line 108 of file blender.c.

#define HUE16_GREEN   (HUE16_RANGE*HUE_GREEN_TO_CYAN)

Definition at line 107 of file blender.c.

#define HUE16_MAGENTA   (HUE16_RANGE*HUE_MAGENTA_TO_RED)

Definition at line 110 of file blender.c.

#define HUE16_RED   (HUE16_RANGE*HUE_RED_TO_YELLOW)

Definition at line 105 of file blender.c.

#define HUE16_YELLOW   (HUE16_RANGE*HUE_YELLOW_TO_GREEN)

Definition at line 106 of file blender.c.

#define HUE_BLUE_TO_MAGENTA   4

Definition at line 102 of file blender.c.

#define HUE_CYAN_TO_BLUE   3

Definition at line 101 of file blender.c.

#define HUE_GREEN_TO_CYAN   2

Definition at line 100 of file blender.c.

#define HUE_MAGENTA_TO_RED   5

Definition at line 103 of file blender.c.

#define HUE_RED_TO_YELLOW   0

Definition at line 98 of file blender.c.

#define HUE_YELLOW_TO_GREEN   1

Definition at line 99 of file blender.c.

#define INTERPRET_HUE16 ( hue,
delta,
max_val,
red,
green,
blue   ) 

Value:

do{     int range = (hue)/HUE16_RANGE ;                                  \
                int min_val = (max_val) - (delta);                                \
                int mid_val = ((hue) - HUE16_RANGE*range)*(delta) / HUE16_RANGE ;  \
                switch( range ) {                                              \
                        case HUE_RED_TO_YELLOW :    /* red was max, then green  */ \
                                (red)   = (max_val); (green)=mid_val+(min_val); (blue) = (min_val); break; \
                        case HUE_YELLOW_TO_GREEN :  /* green was max, then red */                      \
                                (green) = (max_val); (red) =(max_val)-mid_val;  (blue) = (min_val); break; \
                        case HUE_GREEN_TO_CYAN :    /* green was max, then blue*/                      \
                                (green) = (max_val); (blue)= mid_val+(min_val); (red)  = (min_val); break; \
                        case HUE_CYAN_TO_BLUE :     /* blue was max, then green  */                    \
                                (blue)  = (max_val); (green)=(max_val)-mid_val; (red)  = (min_val); break; \
                        case HUE_BLUE_TO_MAGENTA :  /* blue was max, then red   */                     \
                                (blue)  = (max_val); (red)  = mid_val+(min_val);(green)= (min_val); break; \
                        case HUE_MAGENTA_TO_RED :   /* red was max, then blue */                       \
                                (red)   = (max_val); (blue) = (max_val)-mid_val;(green)= (min_val); break; \
                }                                                                                  \
        }while(0)

Definition at line 131 of file blender.c.

Referenced by hls2rgb(), and hsv2rgb().

#define MAKE_HUE16 ( hue,
red,
green,
blue,
min_val,
max_val,
delta   ) 

Value:

do{     if( (red) == (max_val) ){ /* 300 to 60 degrees segment */ \
                        if( (blue) <= (green) ){  /* 0-60 degrees segment*/    \
                                (hue) = HUE16_RED    + (((green) - (blue)) * (HUE16_RANGE)) / (delta) ;\
                                if( (hue) == 0 ) (hue) = MIN_HUE16 ; \
                        }else {                /* 300-0 degrees segment*/ \
                                (hue) = HUE16_MAGENTA+ (((red)   - (blue)) * (HUE16_RANGE)) / (delta) ; \
                                if( (hue) == 0 ) (hue) = MAX_HUE16 ;                                 \
                        }                                                                   \
                }else if( (green) == (max_val) ){ /* 60 to 180 degrees segment */           \
                        if( (blue) >= (red) )    /* 120-180 degrees segment*/                   \
                                (hue) = HUE16_GREEN  + (((blue)-(red) ) * (HUE16_RANGE)) / (delta) ;    \
                        else                 /* 60-120 degrees segment */                   \
                                (hue) = HUE16_YELLOW + (((green)-(red)) * (HUE16_RANGE)) / (delta) ;    \
                }else if( (red) >= (green) )     /* 240 to 300 degrees segment */           \
                        (hue)     = HUE16_BLUE   + (((red) -(green))* (HUE16_RANGE)) / (delta) ;    \
                else                        /* 180 to 240 degrees segment */            \
                        (hue)     = HUE16_CYAN   + (((blue)-(green))* (HUE16_RANGE)) / (delta) ;    \
        }while(0)

Definition at line 112 of file blender.c.

Referenced by rgb2hls(), rgb2hsv(), and rgb2hue().

#define MAX_MY_RND32   0x00ffffffff

 
#define MY_RND32 (  )     (rnd32_seed = (1664525L*rnd32_seed)+1013904223L)

Referenced by dissipate_scanlines(), and main().


Function Documentation

void add_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 466 of file blender.c.

References BLEND_SCANLINES_HEADER, and i.

void allanon_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 435 of file blender.c.

References BLEND_SCANLINES_HEADER, and i.

Referenced by fill_with_pixmapped_background().

void alphablend_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 382 of file blender.c.

References a, BLEND_SCANLINES_HEADER, and i.

Referenced by TASImage::Bevel(), TASImage::Gradient(), and init_image_layers().

merge_scanlines_func blend_scanlines_name2func ( const char *  name  ) 

Definition at line 332 of file blender.c.

References merge_scanlines_func_desc::func, i, mystrncasecmp, NULL, and std_merge_scanlines_func_list.

Referenced by TASImage::CreateThumbnail(), handle_asxml_tag_composite(), and TASImage::Merge().

void colorize_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 666 of file blender.c.

References b, BLEND_SCANLINES_HEADER, fprintf(), g, h, hls2rgb(), i, l, rgb2hls(), rgb2luminance(), and s.

void darken_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 530 of file blender.c.

References BLEND_SCANLINES_HEADER, and i.

CARD32 degrees2hue16 ( int  degrees  ) 

Definition at line 160 of file blender.c.

References HUE16_RANGE, and MIN_HUE16.

Referenced by adjust_asimage_hsv().

void diff_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 509 of file blender.c.

References BLEND_SCANLINES_HEADER, i, and int.

void dissipate_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 695 of file blender.c.

References a, BLEND_SCANLINES_HEADER, i, MY_RND32, and rnd32_seed.

void hls2rgb ( CARD32  hue,
CARD32  luminance,
CARD32  saturation,
CARD32 *  red,
CARD32 *  green,
CARD32 *  blue 
)

Definition at line 284 of file blender.c.

References INTERPRET_HUE16.

Referenced by colorize_scanlines().

void hsv2rgb ( CARD32  hue,
CARD32  saturation,
CARD32  value,
CARD32 *  red,
CARD32 *  green,
CARD32 *  blue 
)

Definition at line 226 of file blender.c.

References INTERPRET_HUE16.

Referenced by adjust_asimage_hsv(), hue_scanlines(), saturate_scanlines(), and value_scanlines().

int hue162degrees ( CARD32  hue  ) 

Definition at line 172 of file blender.c.

References HUE16_RANGE, and MAX_HUE16.

Referenced by handle_asxml_tag_color(), and handle_asxml_tag_hsv().

void hue_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 611 of file blender.c.

References BLEND_SCANLINES_HEADER, hsv2rgb(), i, rgb2hue(), rgb2saturation(), rgb2value(), and value.

void lighten_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 548 of file blender.c.

References BLEND_SCANLINES_HEADER, and i.

void list_scanline_merging ( FILE *  stream,
const char *  format 
)

Definition at line 353 of file blender.c.

References fprintf(), i, name, NULL, and std_merge_scanlines_func_list.

int normalize_degrees_val ( int  degrees  ) 

Definition at line 152 of file blender.c.

Referenced by adjust_asimage_hsv().

void overlay_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 589 of file blender.c.

References BLEND_SCANLINES_HEADER, DO_OVERLAY_VALUE, and i.

CARD32 rgb2hls ( CARD32  red,
CARD32  green,
CARD32  blue,
CARD32 *  luminance,
CARD32 *  saturation 
)

Definition at line 255 of file blender.c.

References MAKE_HUE16, MAX, and MIN.

Referenced by colorize_scanlines().

CARD32 rgb2hsv ( CARD32  red,
CARD32  green,
CARD32  blue,
CARD32 *  saturation,
CARD32 *  value 
)

Definition at line 202 of file blender.c.

References MAKE_HUE16, MAX, and MIN.

Referenced by handle_asxml_tag_color(), saturate_scanlines(), and value_scanlines().

CARD32 rgb2hue ( CARD32  red,
CARD32  green,
CARD32  blue 
)

Definition at line 181 of file blender.c.

References MAKE_HUE16, MAX, and MIN.

Referenced by adjust_asimage_hsv(), handle_asxml_tag_hsv(), and hue_scanlines().

CARD32 rgb2luminance ( CARD32  red,
CARD32  green,
CARD32  blue 
)

Definition at line 239 of file blender.c.

References MAX, and MIN.

Referenced by colorize_scanlines().

CARD32 rgb2saturation ( CARD32  red,
CARD32  green,
CARD32  blue 
)

Definition at line 55 of file blender.c.

References MAX, and MIN.

Referenced by adjust_asimage_hsv(), hue_scanlines(), and saturate_scanlines().

CARD32 rgb2value ( CARD32  red,
CARD32  green,
CARD32  blue 
)

Definition at line 47 of file blender.c.

References MAX.

Referenced by adjust_asimage_hsv(), hue_scanlines(), and value_scanlines().

void saturate_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 631 of file blender.c.

References BLEND_SCANLINES_HEADER, hsv2rgb(), i, rgb2hsv(), rgb2saturation(), and value.

void screen_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 566 of file blender.c.

References BLEND_SCANLINES_HEADER, DO_SCREEN_VALUE, and i.

void sub_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 490 of file blender.c.

References BLEND_SCANLINES_HEADER, i, and int.

void tint_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 451 of file blender.c.

References BLEND_SCANLINES_HEADER, and i.

void value_scanlines ( ASScanline bottom,
ASScanline top,
int  offset 
)

Definition at line 648 of file blender.c.

References BLEND_SCANLINES_HEADER, hsv2rgb(), i, rgb2hsv(), rgb2value(), and value.


Variable Documentation

merge_scanlines_func_desc std_merge_scanlines_func_list[]

Initial value:

{
  { "add", 3, add_scanlines, "color addition with saturation" },
  { "alphablend", 10, alphablend_scanlines, "alpha-blending" },
  { "allanon", 7, allanon_scanlines, "color values averaging" },
  { "colorize", 8, colorize_scanlines, "hue and saturate bottom image same as top image" },
  { "darken", 6, darken_scanlines, "use lowest color value from both images" },
  { "diff", 4, diff_scanlines, "use absolute value of the color difference between two images" },
  { "dissipate", 9, dissipate_scanlines, "randomly alpha-blend images"},
  { "hue", 3, hue_scanlines, "hue bottom image same as top image"  },
  { "lighten", 7, lighten_scanlines, "use highest color value from both images" },
  { "overlay", 7, overlay_scanlines, "some wierd image overlaying(see GIMP)" },
  { "saturate", 8, saturate_scanlines, "saturate bottom image same as top image"},
  { "screen", 6, screen_scanlines, "another wierd image overlaying(see GIMP)" },
  { "sub", 3, sub_scanlines, "color substraction with saturation" },
  { "tint", 4, tint_scanlines, "tinting image with image" },
  { "value", 5, value_scanlines, "value bottom image same as top image" },
  { NULL, 0, NULL }
}

Definition at line 311 of file blender.c.

Referenced by blend_scanlines_name2func(), and list_scanline_merging().


Generated on Tue Jul 5 15:57:52 2011 for ROOT_528-00b_version by  doxygen 1.5.1