pike.git
/
src
/
modules
/
Image
/
colors.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/Image/colors.c:1:
/* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
||
$Id: colors.c,v 1.77 2008/12/13 08:23:45 nilsson Exp $
+
||
$Id$
*/ /* **! module Image **! submodule Color **! **! This module keeps names and easy handling **! for easy color support. It gives you an easy **! way to get colors from names. **!
pike.git/src/modules/Image/colors.c:217:
static struct mapping *colors=NULL; static struct object *colortable=NULL; static struct array *colornames=NULL; struct program *image_color_program=NULL; extern struct program *image_colortable_program; static struct pike_string *str_array; static struct pike_string *str_string;
+
static struct pike_string *str_int;
static struct pike_string *str_r; static struct pike_string *str_g; static struct pike_string *str_b; static struct pike_string *str_h; static struct pike_string *str_s; static struct pike_string *str_v; static struct pike_string *no_name; /* forward */
pike.git/src/modules/Image/colors.c:765:
if (sp[-1].u.string==str_array) { image_color_rgb(args); return; } if (sp[-1].u.string==str_string) { image_color_name(args); return; }
+
if (sp[-1].u.string==str_int)
+
{
+
pop_stack();
+
push_int( (THIS->rgb.r << 8 | THIS->rgb.g) << 8 | THIS->rgb.b );
+
return;
+
}
Pike_error("Image.Color.Color->cast(): Can't cast to that\n"); } static void image_color__sprintf(INT32 args) { int prec,x; if (args<2) SIMPLE_TOO_FEW_ARGS_ERROR("_sprintf",2);
pike.git/src/modules/Image/colors.c:1552:
cs->rgb.r=(COLORTYPE)r; cs->rgb.g=(COLORTYPE)g; cs->rgb.b=(COLORTYPE)b; RGB_TO_RGBL(cs->rgbl,cs->rgb); } static void image_make_rgb_color(INT32 args) { INT_TYPE r=0,g=0,b=0;
+
if( args==1 && sp[-1].type==T_INT )
+
{
+
r = sp[-1].u.integer;
+
b = r & 0xff;
+
r >>= 8;
+
g = r & 0xff;
+
r >>= 8;
+
r &= 0xff;
+
}
+
else
get_all_args("Image.Color.rgb()",args,"%i%i%i",&r,&g,&b); _image_make_rgb_color(r,g,b); } static void image_make_hsv_color(INT32 args) { FLOAT_TYPE h,s,v; FLOAT_TYPE r=0,g=0,b=0; /* to avoid warning */
pike.git/src/modules/Image/colors.c:1706:
pop_n_elems(args); if (!colors) make_colors(); ref_push_mapping(colors); f_values(1); } void init_image_colors(void) { str_array=make_shared_string("array"); str_string=make_shared_string("string");
+
str_int=make_shared_string("int");
str_r=make_shared_string("r"); str_g=make_shared_string("g"); str_b=make_shared_string("b"); str_h=make_shared_string("h"); str_s=make_shared_string("s"); str_v=make_shared_string("v"); no_name=make_shared_string(""); /* make color object program */
pike.git/src/modules/Image/colors.c:1777:
image_color_program->flags |= PROGRAM_CONSTANT | PROGRAM_NO_EXPLICIT_DESTRUCT ; PIKE_MODULE_EXPORT(Image, image_color_program); /* this is the Image.Color stuff */ ADD_FUNCTION("`[]",image_colors_index,tFunc(tStr,tObjIs_IMAGE_COLOR_COLOR_ID),0); ADD_FUNCTION("`()",image_make_color,
-
tOr
(tFunc(tStr,tObjIs_IMAGE_COLOR_COLOR_ID),
+
tOr3
(tFunc(tStr,tObjIs_IMAGE_COLOR_COLOR_ID),
+
tFunc(tInt,tObjIs_IMAGE_COLOR_COLOR_ID),
tFunc(tInt tInt tInt,tObjIs_IMAGE_COLOR_COLOR_ID)),0); ADD_FUNCTION("rgb",image_make_rgb_color,
-
tFunc(tInt tInt tInt,tObjIs_IMAGE_COLOR_COLOR_ID),0);
+
tOr(
tFunc(tInt
,tObjIs_IMAGE_COLOR_COLOR_ID),
+
tFunc(
tInt tInt
tInt
,tObjIs_IMAGE_COLOR_COLOR_ID)
)
,0);
ADD_FUNCTION("hsv",image_make_hsv_color, tOr(tFunc(tInt tInt tInt,tObjIs_IMAGE_COLOR_COLOR_ID), tFunc(tFlt tFlt tFlt,tObjIs_IMAGE_COLOR_COLOR_ID)) ,0); ADD_FUNCTION("cmyk",image_make_cmyk_color,tFunc(tOr(tInt,tFlt) tOr(tInt,tFlt) tOr(tInt,tFlt) tOr(tInt,tFlt), tObjIs_IMAGE_COLOR_COLOR_ID), 0); ADD_FUNCTION("html",image_make_html_color, tFunc(tStr,tObjIs_IMAGE_COLOR_COLOR_ID),0);
pike.git/src/modules/Image/colors.c:1825:
colors=NULL; colortable=NULL; colornames=NULL; for (i=0; (size_t)i<sizeof(html_color)/sizeof(html_color[0]); i++) free_string(html_color[i].pname); } free_string(str_array); free_string(str_string);
+
free_string(str_int);
free_string(str_r); free_string(str_g); free_string(str_b); free_string(str_h); free_string(str_s); free_string(str_v); free_string(no_name); }