pixword.c
Go to the documentation of this file.
1 /*
2 pixword.c
3 (c)1995, Toshihiro Matsui, Electrotechnical Laboratory
4 */
5 static char *rcsid= "@(#)$Id: pixword.c,v 1.1.1.1 2003/11/20 07:46:30 eus Exp $";
6 
7 #include "../c/eus.h"
8 
9 #pragma init (init_object_module)
11 
12 static void init_object_module()
13  { add_module_initializer("pixword", pixword);}
14 
15 pointer SPLIT_RGB(ctx,n,argv)
16 context *ctx;
17 int n;
18 pointer *argv;
19 { register int size3, size1, s1, s3, offset;
20  byte *rgb, *r, *g, *b;
21  pointer rgbp, rp, gp, bp;
22 
23  /* a vector each of which element represents RGB colors is
24  split into three vectors for R, G, and B */
25 
26  ckarg2(4,6);
27  if (!isstring(argv[0])) error(E_NOSTRING);
28  if (!isstring(argv[1])) error(E_NOSTRING);
29  if (!isstring(argv[2])) error(E_NOSTRING);
30  if (!isstring(argv[3])) error(E_NOSTRING);
31 
32  if (n>=5) offset=ckintval(argv[4]); else offset=0;
33 
34  rgbp=argv[0]; rp=argv[1]; gp=argv[2]; bp=argv[3];
35  r=rp->c.str.chars; g=gp->c.str.chars; b=bp->c.str.chars;
36  rgb=rgbp->c.str.chars;
37  if (n==6) size3=ckintval(argv[5]);
38  else size3=vecsize(rgbp);
39 
40  size1=size3/3;
41  for (s1=0, s3=0; s1<size1; s1++) {
42  r[offset+s1]=rgb[s3++];
43  g[offset+s1]=rgb[s3++];
44  b[offset+s1]=rgb[s3++];}
45  return(makeint(size3));}
46 
47 pointer MERGE_RGB(ctx,n,argv)
48 context *ctx;
49 int n;
50 pointer *argv;
51 { register int size3, size1, s1, s3, offset;
52  byte *rgb, *r, *g, *b;
53 
54  /* three R,G, and B vectors are merged into one RGB vector */
55  /* (merge-rgb rgbvec red green blue) */
56  ckarg(5);
57  if (!isstring(argv[0])) error(E_NOSTRING);
58  if (!isstring(argv[1])) error(E_NOSTRING);
59  if (!isstring(argv[2])) error(E_NOSTRING);
60  if (!isstring(argv[3])) error(E_NOSTRING);
61  size1=vecsize(argv[0]);
62  rgb=argv[0]->c.str.chars;
63  r=argv[1]->c.str.chars;
64  g=argv[2]->c.str.chars;
65  b=argv[3]->c.str.chars;
66  offset=ckintval(argv[4]);
67  size3=vecsize(argv[0]);
68  for (s1=0, s3=0; s3<size3; s1++) {
69  rgb[s3++]=r[s1+offset];
70  rgb[s3++]=g[s1+offset];
71  rgb[s3++]=b[s1+offset];}
72  return(argv[0]);}
73 
74 pointer pixword(ctx,n,argv)
75  context *ctx;
76  int n;
77  pointer argv[];
78 { pointer mod=argv[0];
79  defun(ctx,"SPLIT-RGB",mod,SPLIT_RGB,NULL);
80  defun(ctx,"MERGE-RGB",mod,MERGE_RGB,NULL);
81  }
82 
#define makeint(v)
Definition: sfttest.c:2
Definition: eus.h:522
static long(* g)()
Definition: test_foreign.c:158
struct string str
Definition: eus.h:400
byte chars[1]
Definition: eus.h:210
static void init_object_module()
Definition: pixword.c:12
GLfloat n[6][3]
Definition: cube.c:15
pointer SPLIT_RGB(context *ctx, int n, pointer *argv)
Definition: pixword.c:15
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
ckarg(2)
void add_module_initializer(char *, pointer(*)())
Definition: loadelf.c:86
union cell::cellunion c
pointer pixword()
Definition: eus.h:379
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
Definition: eus.c:297
static int bp
Definition: helpsub.c:22
#define NULL
Definition: transargv.c:8
static char * rcsid
Definition: pixword.c:5
unsigned char byte
Definition: eus.h:161
pointer MERGE_RGB(context *ctx, int n, pointer *argv)
Definition: pixword.c:47


euslisp
Author(s): Toshihiro Matsui
autogenerated on Fri Feb 21 2020 03:20:54