Branch: Tag:

2000-09-10

2000-09-10 01:23:59 by Per Hedbor <ph@opera.com>

Added _sprintf methods, and a new 'bits' method in the color objects. As an example, to get a 333 RGB palette from a colortable: ((array)Image.Colortable(Image.Image(100,100)->test()))->bits( 3,3,3, 6,3,0 )

Rev: src/modules/Image/colors.c:1.40
Rev: src/modules/Image/colortable.c:1.98
Rev: src/modules/Image/image.c:1.178
Rev: src/modules/Image/layers.c:1.56

1:   /*   **! module Image   **! note - **! $Id: layers.c,v 1.55 2000/08/15 12:44:50 grubba Exp $ + **! $Id: layers.c,v 1.56 2000/09/10 01:23:59 per Exp $   **! class Layer   **! see also: layers   **!
215:      #include <math.h> /* floor */    - RCSID("$Id: layers.c,v 1.55 2000/08/15 12:44:50 grubba Exp $"); + RCSID("$Id: layers.c,v 1.56 2000/09/10 01:23:59 per Exp $");      #include "image_machine.h"   
2890:   }       + static void image_layer__sprintf( INT32 args ) + { +  extern void f_sprintf( INT32 args ); +  int x; +  if (args != 2 ) +  SIMPLE_TOO_FEW_ARGS_ERROR("_sprintf",2); +  if (sp[-args].type!=T_INT) +  SIMPLE_BAD_ARG_ERROR("_sprintf",0,"integer"); +  if (sp[1-args].type!=T_MAPPING) +  SIMPLE_BAD_ARG_ERROR("_sprintf",1,"mapping"); +  +  x = sp[-2].u.integer; +  +  pop_n_elems( 2 ); +  switch( x ) +  { +  case 't': +  push_constant_text("Image.Layer"); +  return; +  case 'O': +  push_constant_text( "Image.Layer(%O i=%O a=%O)" ); +  image_layer_mode(0); +  if( THIS->image ) ref_push_object( THIS->image ); else push_int( 0 ); +  if( THIS->alpha ) ref_push_object( THIS->alpha ); else push_int( 0 ); +  f_sprintf( 4 ); +  return; +  default: +  push_int(0); +  return; +  } + } +    /******************************************************/      void init_image_layers(void)
2915:    tFunc(tInt tInt    tOr(tColor,tVoid) tOr(tColor,tVoid),tVoid)),0);    +  +  ADD_FUNCTION("_sprintf",image_layer__sprintf, +  tFunc(tInt tMapping,tString),0);    ADD_FUNCTION("cast",image_layer_cast,    tFunc(tString,tMapping),0);