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.
73
2004
/
09
/
18
21
:
24
:
53
nilsson
Exp $
+
|| $Id: colors.c,v 1.
74
2005
/
03
/
15
20
:
56
:
20
per
Exp $
*/ /* **! 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:966:
sp[-1].u.array->item[2].type==T_INT && sp[-1].u.array->item[0].u.integer == THIS->rgb.r && sp[-1].u.array->item[1].u.integer == THIS->rgb.g && sp[-1].u.array->item[2].u.integer == THIS->rgb.b) { pop_stack(); push_int(1); return; } }
-
else if (sp[-1].type==T_INT)
-
{
-
if (sp[-1].u.integer == THIS->rgb.r &&
-
THIS->rgb.r==THIS->rgb.g &&
-
THIS->rgb.r==THIS->rgb.b)
-
{
-
pop_stack();
-
push_int(1);
-
return;
-
}
-
}
+
/*
else if (sp[-1].type==T_INT)
*/
+
/*
{
*/
+
/*
if (sp[-1].u.integer == THIS->rgb.r &&
*/
+
/*
THIS->rgb.r==THIS->rgb.g &&
*/
+
/*
THIS->rgb.r==THIS->rgb.b)
*/
+
/*
{
*/
+
/*
pop_stack();
*/
+
/*
push_int(1);
*/
+
/*
return;
*/
+
/*
}
*/
+
/*
}
*/
else if (sp[-1].type==T_STRING) { if (!THIS->name) try_find_name(THIS); if (sp[-1].u.string==THIS->name && THIS->name!=no_name) { pop_stack(); push_int(1); return; }
pike.git/src/modules/Image/colors.c:1501:
cs=(struct color_struct*) get_storage(sp[-1].u.object,image_color_program); cs->rgbl.r=(INT32)r; cs->rgbl.g=(INT32)g; cs->rgbl.b=(INT32)b; RGBL_TO_RGB(cs->rgb,cs->rgbl); }
+
static void image_color__encode( INT32 args )
+
{
+
push_int( THIS->rgbl.r );
+
push_int( THIS->rgbl.g );
+
push_int( THIS->rgbl.b );
+
f_aggregate( 3 );
+
}
+
+
static void image_color__decode( INT32 args )
+
{
+
struct svalue *a;
+
int r, g, b;
+
if( Pike_sp[-1].type != PIKE_T_ARRAY || Pike_sp[-1].u.array->size != 3 )
+
Pike_error("Illegal argument to _decode\n");
+
a=Pike_sp[-1].u.array->item;
+
THIS->rgbl.r = a[0].u.integer;
+
THIS->rgbl.g = a[1].u.integer;
+
THIS->rgbl.b = a[2].u.integer;
+
RGBL_TO_RGB(THIS->rgb,THIS->rgbl);
+
pop_stack();
+
}
+
static void _image_make_rgbf_color(double r, double g, double b) { #define FOO(X) FLOAT_TO_COLORL((X)<0.0?0.0:(X)>1.0?1.0:(X)) _image_make_rgbl_color(FOO(r),FOO(g),FOO(b)); #undef FOO } void _image_make_rgb_color(INT32 r,INT32 g,INT32 b) { struct color_struct *cs;
pike.git/src/modules/Image/colors.c:1713:
ADD_FUNCTION("cast",image_color_cast,tFunc(tStr,tOr(tArray,tStr)),0); ADD_FUNCTION("_sprintf",image_color__sprintf, tFunc(tInt tMap(tStr,tMix),tStr),0); ADD_FUNCTION("`[]",image_color_index,tFunc(tOr(tStr,tInt),tOr(tInt,tFunction)),0); ADD_FUNCTION("`->",image_color_index,tFunc(tOr(tStr,tInt),tOr(tInt,tFunction)),0); ADD_FUNCTION("`==",image_color_equal,tFunc(tOr(tObjImpl_IMAGE_COLOR_COLOR_ID,tInt), tInt),0); ADD_FUNCTION("__hash",image_color___hash,tFunc(tNone,tInt),0);
+
ADD_FUNCTION("_encode", image_color__encode,tFunc(tNone,tArr(tInt)),0);
+
ADD_FUNCTION("_decode", image_color__decode,tFunc(tInt,tVoid),0);
+
ADD_FUNCTION("name",image_color_name,tFunc(tNone,tStr),0); ADD_FUNCTION("hex",image_color_hex,tFunc(tNone,tStr),0); ADD_FUNCTION("html",image_color_html,tFunc(tNone,tStr),0); ADD_FUNCTION("bits",image_color_bits,tFunc(tInt tInt tInt tInt tInt tInt,tInt),0); ADD_FUNCTION("rgb",image_color_rgb,tFunc(tNone,tArr(tInt)),0); ADD_FUNCTION("rgbf",image_color_rgbf,tFunc(tNone,tArr(tFlt)),0); ADD_FUNCTION("hsv",image_color_hsv,tFunc(tNone,tArr(tInt)),0); ADD_FUNCTION("hsvf",image_color_hsvf,tFunc(tNone,tArr(tFlt)),0); ADD_FUNCTION("cmyk",image_color_cmyk,tFunc(tNone,tArr(tFlt)),0);