pixword.c
Go to the documentation of this file.
00001 /*
00002 pixword.c
00003 (c)1995, Toshihiro Matsui, Electrotechnical Laboratory
00004 */
00005 static char *rcsid= "@(#)$Id: pixword.c,v 1.1.1.1 2003/11/20 07:46:30 eus Exp $";
00006 
00007 #include "../c/eus.h"
00008 
00009 #pragma init (init_object_module)
00010 extern void pixword(context *, int, pointer *);
00011 
00012 static init_object_module()
00013   { add_module_initializer("pixword", pixword);}
00014 
00015 pointer SPLIT_RGB(ctx,n,argv)
00016 context *ctx;
00017 int n;
00018 pointer *argv;
00019 { register int size3, size1, s1, s3, offset;
00020   byte *rgb, *r, *g, *b;
00021   pointer rgbp, rp, gp, bp;
00022 
00023   /* a vector each of which element represents RGB colors is
00024      split into three vectors for R, G, and B */
00025 
00026   ckarg2(4,6);
00027   if (!isstring(argv[0])) error(E_NOSTRING);
00028   if (!isstring(argv[1])) error(E_NOSTRING);
00029   if (!isstring(argv[2])) error(E_NOSTRING);
00030   if (!isstring(argv[3])) error(E_NOSTRING);
00031 
00032   if (n>=5) offset=ckintval(argv[4]); else offset=0;
00033 
00034   rgbp=argv[0];  rp=argv[1];  gp=argv[2];  bp=argv[3];
00035   r=rp->c.str.chars; g=gp->c.str.chars; b=bp->c.str.chars; 
00036   rgb=rgbp->c.str.chars;
00037   if (n==6)   size3=ckintval(argv[5]);
00038   else size3=vecsize(rgbp);
00039 
00040   size1=size3/3;
00041   for (s1=0, s3=0; s1<size1; s1++)  {
00042     r[offset+s1]=rgb[s3++];
00043     g[offset+s1]=rgb[s3++];
00044     b[offset+s1]=rgb[s3++];}
00045   return(makeint(size3));}
00046 
00047 pointer MERGE_RGB(ctx,n,argv)
00048 context *ctx;
00049 int n;
00050 pointer *argv;
00051 { register int size3, size1, s1, s3, offset;
00052   byte *rgb, *r, *g, *b;
00053 
00054   /* three R,G, and B vectors are merged into one RGB vector */
00055   /* (merge-rgb rgbvec red green blue) */
00056   ckarg(5);
00057   if (!isstring(argv[0])) error(E_NOSTRING);
00058   if (!isstring(argv[1])) error(E_NOSTRING);
00059   if (!isstring(argv[2])) error(E_NOSTRING);
00060   if (!isstring(argv[3])) error(E_NOSTRING);
00061   size1=vecsize(argv[0]);
00062   rgb=argv[0]->c.str.chars;
00063   r=argv[1]->c.str.chars;
00064   g=argv[2]->c.str.chars;
00065   b=argv[3]->c.str.chars; 
00066   offset=ckintval(argv[4]);
00067   size3=vecsize(argv[0]);
00068   for (s1=0, s3=0; s3<size3; s1++)  {
00069     rgb[s3++]=r[s1+offset];
00070     rgb[s3++]=g[s1+offset];
00071     rgb[s3++]=b[s1+offset];}
00072   return(argv[0]);}
00073 
00074 extern void pixword(ctx,n,argv)
00075   context *ctx;
00076   int n;
00077   pointer argv[];
00078 { pointer mod=argv[0];
00079   defun(ctx,"SPLIT-RGB",mod,SPLIT_RGB);
00080   defun(ctx,"MERGE-RGB",mod,MERGE_RGB);
00081   }
00082 


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Mar 9 2017 04:57:50