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:
/* **! module Image **! note
-
**! $Id: colors.c,v 1.
45
2001/03/04
15
:27:
54
mirar Exp $
+
**! $Id: colors.c,v 1.
46
2001/03/04
19
:27:
19
mirar Exp $
**! submodule Color **! **! This module keeps names and easy handling **! for easy color support. It gives you an easy **! way to get colors from names. **! **! A color is here an object, containing color **! information and methods for conversion, see below. **! **! <ref>Image.Color</ref> can be called to make a color object.
pike.git/src/modules/Image/colors.c:172:
**! class Color **! This is the color object. It has six readable variables, **! <tt>r</tt>, <tt>g</tt>, <tt>b</tt>, for the <i>red</i>, **! <i>green</i> and <i>blue</i> values, **! and <tt>h</tt>, <tt>s</tt>, <tt>v</tt>, for **! the <i>hue</i>, <i>saturation</i> anv <i>value</i> values. */ #include "global.h"
-
RCSID("$Id: colors.c,v 1.
45
2001/03/04
15
:27:
54
mirar Exp $");
+
RCSID("$Id: colors.c,v 1.
46
2001/03/04
19
:27:
19
mirar Exp $");
#include "image_machine.h" #include <math.h> #include "stralloc.h" #include "pike_macros.h" #include "object.h" #include "constants.h" #include "interpret.h"
pike.git/src/modules/Image/colors.c:646:
push_text("#"); /* stupid */ return; } else if (i!=sizeof(COLORTYPE)*2) { ptrdiff_t sh; if (i>8) i=8; sh=4*(sizeof(COLORTYPE)*2-i); if (sh>0)
-
sprintf(buf,"#%0*x%0*x%0*x",i,(unsigned)(THIS->rgb.r>>sh),
-
i,(unsigned)(THIS->rgb.g>>sh),i,(unsigned)(THIS->rgb.b>>sh));
+
sprintf(buf,"#%0*x%0*x%0*x",
+
(int)
i,(unsigned)(THIS->rgb.r>>sh),
+
(int)
i,(unsigned)(THIS->rgb.g>>sh),
+
(int)
i,(unsigned)(THIS->rgb.b>>sh));
else { unsigned INT32 r=THIS->rgbl.r; unsigned INT32 g=THIS->rgbl.g; unsigned INT32 b=THIS->rgbl.b; sh=COLORLBITS-i*4; if (sh<0) { r=(r<<-sh)+(r>>(COLORLBITS+sh)); g=(g<<-sh)+(g>>(COLORLBITS+sh)); b=(b<<-sh)+(b>>(COLORLBITS+sh)); sh=0; } sprintf(buf,"#%0*x%0*x%0*x",
-
i,(unsigned)(r>>sh),i,(unsigned)(g>>sh),i,(unsigned)(b>>sh));
+
(int)
i,(unsigned)(r>>sh),
+
(int)
i,(unsigned)(g>>sh),
+
(int)
i,(unsigned)(b>>sh));
} } else switch (sizeof(COLORTYPE)) /* constant */ { case 1: sprintf(buf,"#%02x%02x%02x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b); break; case 2: sprintf(buf,"#%04x%04x%04x",THIS->rgb.r,THIS->rgb.g,THIS->rgb.b);