q-lang-cvs Mailing List for Q - Equational Programming Language (Page 128)
                
                Brought to you by:
                
                    agraef
                    
                
            
            
        
        
        
    You can subscribe to this list here.
| 2003 | 
          Jan
           | 
        
        
        
        
          Feb
           | 
        
        
        
        
          Mar
           | 
        
        
        
        
          Apr
           | 
        
        
        
        
          May
           | 
        
        
        
        
          Jun
           | 
        
        
        
        
          Jul
           | 
        
        
        
        
          Aug
           | 
        
        
        
        
          Sep
           | 
        
        
        
        
          Oct
           | 
        
        
        
        
          Nov
           | 
        
        
        
        
          Dec
           (106)  | 
        
      
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 | 
          Jan
           (219)  | 
        
        
        
        
          Feb
           (152)  | 
        
        
        
        
          Mar
           | 
        
        
        
        
          Apr
           (92)  | 
        
        
        
        
          May
           (45)  | 
        
        
        
        
          Jun
           (3)  | 
        
        
        
        
          Jul
           | 
        
        
        
        
          Aug
           (3)  | 
        
        
        
        
          Sep
           (111)  | 
        
        
        
        
          Oct
           (52)  | 
        
        
        
        
          Nov
           | 
        
        
        
        
          Dec
           | 
        
      
| 2005 | 
          Jan
           | 
        
        
        
        
          Feb
           (1)  | 
        
        
        
        
          Mar
           (1)  | 
        
        
        
        
          Apr
           (2)  | 
        
        
        
        
          May
           (23)  | 
        
        
        
        
          Jun
           (46)  | 
        
        
        
        
          Jul
           (158)  | 
        
        
        
        
          Aug
           (22)  | 
        
        
        
        
          Sep
           | 
        
        
        
        
          Oct
           (26)  | 
        
        
        
        
          Nov
           (11)  | 
        
        
        
        
          Dec
           (49)  | 
        
      
| 2006 | 
          Jan
           (57)  | 
        
        
        
        
          Feb
           (196)  | 
        
        
        
        
          Mar
           (10)  | 
        
        
        
        
          Apr
           (41)  | 
        
        
        
        
          May
           (149)  | 
        
        
        
        
          Jun
           (308)  | 
        
        
        
        
          Jul
           (11)  | 
        
        
        
        
          Aug
           (25)  | 
        
        
        
        
          Sep
           (15)  | 
        
        
        
        
          Oct
           | 
        
        
        
        
          Nov
           | 
        
        
        
        
          Dec
           (15)  | 
        
      
| 2007 | 
          Jan
           | 
        
        
        
        
          Feb
           | 
        
        
        
        
          Mar
           | 
        
        
        
        
          Apr
           (15)  | 
        
        
        
        
          May
           (204)  | 
        
        
        
        
          Jun
           (112)  | 
        
        
        
        
          Jul
           (7)  | 
        
        
        
        
          Aug
           (16)  | 
        
        
        
        
          Sep
           (134)  | 
        
        
        
        
          Oct
           (313)  | 
        
        
        
        
          Nov
           (262)  | 
        
        
        
        
          Dec
           (83)  | 
        
      
| 2008 | 
          Jan
           (81)  | 
        
        
        
        
          Feb
           (83)  | 
        
        
        
        
          Mar
           (21)  | 
        
        
        
        
          Apr
           | 
        
        
        
        
          May
           | 
        
        
        
        
          Jun
           (1)  | 
        
        
        
        
          Jul
           (2)  | 
        
        
        
        
          Aug
           (6)  | 
        
        
        
        
          Sep
           | 
        
        
        
        
          Oct
           | 
        
        
        
        
          Nov
           | 
        
        
        
        
          Dec
           (2)  | 
        
      
| 2015 | 
          Jan
           | 
        
        
        
        
          Feb
           | 
        
        
        
        
          Mar
           | 
        
        
        
        
          Apr
           | 
        
        
        
        
          May
           (2)  | 
        
        
        
        
          Jun
           | 
        
        
        
        
          Jul
           | 
        
        
        
        
          Aug
           | 
        
        
        
        
          Sep
           | 
        
        
        
        
          Oct
           | 
        
        
        
        
          Nov
           | 
        
        
        
        
          Dec
           | 
        
      
| 
     
      
      
      From: <ag...@us...> - 2004-01-02 04:33:44
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv23775 Added Files: Makefile.msc Removed Files: Makefile.mingw Log Message: MSC Makefile for magick module --- NEW FILE: Makefile.msc --- # $Id: Makefile.msc,v 1.1 2004/01/02 04:33:40 agraef Exp $ # this still needs testing QCC = ../../src/qcc QCCFLAGS = CFLAGS = -O SHLEXT = .dll DEFS = -DSTDC_HEADERS=1 -DHAVE_STRDUP=1 -DHAVE_MEMCPY=1 -DHAVE_LIMITS_H=1 .PHONY: all clean mostlyclean distclean maintainer-clean all: magick$(SHLEXT) magick$(SHLEXT): magick.c $(QCC) $(QCCFLAGS) --msc -o magick$(SHLEXT) magick.c -- $(DEFS) -I../../libq -I../../../magick/include -I../../../gmp --link CORE_RL_magick_.lib libgmp.lib "/link/LIBPATH:../../libq;../../../gmp" clean mostlyclean distclean maintainer-clean:: rm -f *.o *$(SHLEXT) *.a *.def *% *~ *.bak q.out .q_vars core distclean maintainer-clean:: rm -f TAGS Makefile config.h config.status config.cache config.log --- Makefile.mingw DELETED ---  | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-02 04:30:56
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv23233/modules/magick
Modified Files:
	magick.c 
Log Message:
Windows port
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** magick.c	1 Jan 2004 02:03:06 -0000	1.35
--- magick.c	2 Jan 2004 04:30:52 -0000	1.36
***************
*** 910,914 ****
    Image *img;
    if (argc == 1 && isobj(argv[0], type(Image), (void**)&img))
!     return mkint(img->fuzz);
    else
      return __FAIL;
--- 910,914 ----
    Image *img;
    if (argc == 1 && isobj(argv[0], type(Image), (void**)&img))
!     return mkfloat(img->fuzz);
    else
      return __FAIL;
***************
*** 918,924 ****
  {
    Image *img;
!   long fuzz;
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
!       isint(argv[1], &fuzz)) {
      img->fuzz = fuzz;
      return mkvoid;
--- 918,924 ----
  {
    Image *img;
!   double fuzz;
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
!       (isfloat(argv[1], &fuzz) || ismpz_float(argv[1], &fuzz))) {
      img->fuzz = fuzz;
      return mkvoid;
***************
*** 2375,2380 ****
    double radius;
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
!       (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius))) {
!     img = SpreadImage(img, radius, &exception);
      if (check_exception(&exception))
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
--- 2375,2381 ----
    double radius;
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
!       (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) &&
!       radius >= 0.0) {
!     img = SpreadImage(img, (unsigned)radius, &exception);
      if (check_exception(&exception))
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
 | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-02 04:30:56
      
     
   | 
Update of /cvsroot/q-lang/q/src In directory sc8-pr-cvs1:/tmp/cvs-serv23233/src Modified Files: Makefile.mingw Log Message: Windows port Index: Makefile.mingw =================================================================== RCS file: /cvsroot/q-lang/q/src/Makefile.mingw,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.mingw 15 Dec 2003 12:07:14 -0000 1.2 --- Makefile.mingw 2 Jan 2004 04:30:52 -0000 1.3 *************** *** 42,46 **** # the following variable may be used to overwrite settings specified in sys.h ! DEFS = -DHAVE_MINGW_H -DYEAR=\\\"2003\\\" -DSYSINFO=\\\"$(host)\\\" -DQPATH=\\\".;$(libdir)\\\" -DQEXEC=\\\"$(prefix)/q\\\" -DREADLINE_LIBRARY -DUSE_THREADS EXEEXT = .exe --- 42,46 ---- # the following variable may be used to overwrite settings specified in sys.h ! DEFS = -DHAVE_MINGW_H -DYEAR='"2003"' -DSYSINFO='"$(host)"' -DQPATH='".;$(libdir)"' -DQEXEC='"$(prefix)/q"' -DREADLINE_LIBRARY -DUSE_THREADS EXEEXT = .exe  | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-02 04:30:56
      
     
   | 
Update of /cvsroot/q-lang/q/modules/odbc In directory sc8-pr-cvs1:/tmp/cvs-serv23233/modules/odbc Modified Files: Makefile.msc Log Message: Windows port Index: Makefile.msc =================================================================== RCS file: /cvsroot/q-lang/q/modules/odbc/Makefile.msc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.msc 15 Dec 2003 10:21:21 -0000 1.1.1.1 --- Makefile.msc 2 Jan 2004 04:30:52 -0000 1.2 *************** *** 15,19 **** odbc$(SHLEXT): odbc.c ! $(QCC) $(QCCFLAGS) --msc -o odbc$(SHLEXT) odbc.c -- $(CFLAGS) -I../../libq -I../../../gmp $(DEFS) --link odbc32.lib libgmp.lib /link/LIBPATH:../../libq;../../../gmp clean mostlyclean distclean maintainer-clean:: --- 15,19 ---- odbc$(SHLEXT): odbc.c ! $(QCC) $(QCCFLAGS) --msc -o odbc$(SHLEXT) odbc.c -- $(CFLAGS) -I../../libq -I../../../gmp $(DEFS) --link odbc32.lib libgmp.lib "/link/LIBPATH:../../libq;../../../gmp" clean mostlyclean distclean maintainer-clean::  | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-02 04:30:56
      
     
   | 
Update of /cvsroot/q-lang/q/regex In directory sc8-pr-cvs1:/tmp/cvs-serv23233/regex Modified Files: Makefile.mingw Log Message: Windows port Index: Makefile.mingw =================================================================== RCS file: /cvsroot/q-lang/q/regex/Makefile.mingw,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.mingw 15 Dec 2003 10:18:38 -0000 1.1.1.1 --- Makefile.mingw 2 Jan 2004 04:30:52 -0000 1.2 *************** *** 47,52 **** SHELL = /bin/sh - subdirs = doc test - default all:: libregex.a .PHONY: default all --- 47,50 ---- *************** *** 66,104 **** extraclean:: distclean rm -f patch* *~* *\#* *.orig *.rej *.bak core a.out - - configure: configure.in - autoconf - - config.status: configure - sh configure --no-create - - Makefile: Makefile.in config.status - sh config.status - - makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)' \ - DEFS='$(DEFS)' LDFLAGS='$(LDFLAGS)' LOADLIBES='$(LOADLIBES)' - - default all install \ - mostlyclean clean distclean extraclean realclean \ - TAGS check:: - for d in $(subdirs); do (cd $$d; $(MAKE) $(makeargs) $@); done - .PHONY: install mostlyclean clean distclean extraclean realclean TAGS check - - # Prevent GNU make 3 from overflowing arg limit on system V. - .NOEXPORT: - - distfiles = AUTHORS ChangeLog COPYING INSTALL NEWS README \ - *.in configure regex.c regex.h - distdir = regex-$(version) - distargs = version=$(version) distdir=../$(distdir)/$$d - dist: TAGS configure - @echo "Version numbers in: Makefile.in, ChangeLog, NEWS," - @echo " regex.c, regex.h," - @echo " and doc/xregex.texi (if modified)." - rm -rf $(distdir) - mkdir $(distdir) - ln $(distfiles) $(distdir) - for d in $(subdirs); do (cd $$d; $(MAKE) $(distargs) dist); done - tar czhf $(distdir).tar.Z $(distdir) - rm -rf $(distdir) - .PHONY: dist --- 64,65 ----  | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-02 04:30:56
      
     
   | 
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv23233/modules/ggi Modified Files: Makefile.mingw Log Message: Windows port Index: Makefile.mingw =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/Makefile.mingw,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.mingw 23 Dec 2003 01:15:02 -0000 1.3 --- Makefile.mingw 2 Jan 2004 04:30:52 -0000 1.4 *************** *** 7,11 **** SHLEXT = .dll ! DEFS = -DSTDC_HEADERS=1 -DHAVE_STRDUP=1 -DHAVE_MEMCPY=1 -DHAVE_LIMITS_H=1 .PHONY: all clean mostlyclean distclean maintainer-clean --- 7,11 ---- SHLEXT = .dll ! DEFS = -DSTDC_HEADERS=1 -DHAVE_STRDUP=1 -DHAVE_MEMCPY=1 -DHAVE_LIMITS_H=1 -DHAVE_FT2=1 .PHONY: all clean mostlyclean distclean maintainer-clean *************** *** 13,18 **** all: ggi$(SHLEXT) ggi$(SHLEXT): ggi.c ggilib.h ggilib.c draw_line.c ! qcc -o ggi$(SHLEXT) ggi.c ggilib.c draw_line.c -- $(DEFS) -I. -I../../libq -I../../../ggi/include -I../../../gmp --link -L. -L../../../ggi/lib -lggi -lgii -lgg -L../../../gmp -lgmp -L../../libq clean mostlyclean distclean maintainer-clean:: --- 13,22 ---- all: ggi$(SHLEXT) + # KLUDGE ALERT: must not name the output dll ggi.dll here, otherwise gcc wants + # to read it as -lggi; so we first name it differently and rename it later + ggi$(SHLEXT): ggi.c ggilib.h ggilib.c draw_line.c ! $(QCC) $(QCCFLAGS) -o ggidll$(SHLEXT) ggi.c ggilib.c draw_line.c -- $(DEFS) -I. -I../../libq -I../../../ggi/include -I../../../freetype/include -I../../../gmp --link -L. -L../../../ggi/lib -lggi -lgii -lgg -L../../../freetype/lib -lfreetype -L../../../gmp -lgmp -L../../libq ! mv ggidll$(SHLEXT) ggi$(SHLEXT) clean mostlyclean distclean maintainer-clean::  | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-02 04:30:56
      
     
   | 
Update of /cvsroot/q-lang/q/modules/tk In directory sc8-pr-cvs1:/tmp/cvs-serv23233/modules/tk Modified Files: Makefile.msc Log Message: Windows port Index: Makefile.msc =================================================================== RCS file: /cvsroot/q-lang/q/modules/tk/Makefile.msc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.msc 15 Dec 2003 10:20:14 -0000 1.1.1.1 --- Makefile.msc 2 Jan 2004 04:30:52 -0000 1.2 *************** *** 18,22 **** tk$(SHLEXT): tk.c $(QCC) $(QCCFLAGS) --msc -o tk$(SHLEXT) tk.c -- $(CFLAGS) -I../../libq -I../../../pthread $(DEFS) \ ! --link $(TK_LIBS) pthreadVC.lib /link/LIBPATH:../../libq;../../../pthread clean mostlyclean distclean maintainer-clean:: --- 18,22 ---- tk$(SHLEXT): tk.c $(QCC) $(QCCFLAGS) --msc -o tk$(SHLEXT) tk.c -- $(CFLAGS) -I../../libq -I../../../pthread $(DEFS) \ ! --link $(TK_LIBS) pthreadVC.lib "/link/LIBPATH:../../libq;../../../pthread" clean mostlyclean distclean maintainer-clean::  | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-01 02:49:52
      
     
   | 
Update of /cvsroot/q-lang/q/modules/ggi
In directory sc8-pr-cvs1:/tmp/cvs-serv15766
Modified Files:
	ggi.q 
Log Message:
typo fix
Index: ggi.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.q,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ggi.q	23 Dec 2003 01:15:02 -0000	1.8
--- ggi.q	1 Jan 2004 02:49:49 -0000	1.9
***************
*** 213,217 ****
     visual. This is useful for handling graphics involving transparent or
     translucent pixels. Please note that in the current implementation only the
!    depth 0, 8 and 16 are supported.  Also note that since this a Q-GGI
     specific extension, the .A mode cannot be used in the GGI_DEFMODE
     environment variable.
--- 213,217 ----
     visual. This is useful for handling graphics involving transparent or
     translucent pixels. Please note that in the current implementation only the
!    depths 0, 8 and 16 are supported. Also note that since this a Q-GGI
     specific extension, the .A mode cannot be used in the GGI_DEFMODE
     environment variable.
 | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-01 02:48:53
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv15656/examples
Modified Files:
	magicktest.q 
Log Message:
added capture example
Index: magicktest.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** magicktest.q	31 Dec 2003 15:01:34 -0000	1.14
--- magicktest.q	1 Jan 2004 02:48:49 -0000	1.15
***************
*** 135,138 ****
--- 135,151 ----
  /****************************************************************************/
  
+ /* capture VIS: Sometimes you will also want to go the other way round, i.e.,
+    grab the contents of a GGI visual and return it as an image which can then
+    be manipulated and saved in a file. Here's how to do this. */
+ 
+ capture VIS
+ 
+ = create_image (W,H,0,8,MATTE) (ggi_get_box VIS (0,0) (W,H))
+ 
+     where MODE = ggi_get_mode VIS, (W,H) = sscanf MODE "%dx%d",
+       MATTE = ifelse (pos "A" MODE >= 0) 1 0;
+ 
+ /****************************************************************************/
+ 
  /* animate IMGS: Animate a list of images. Shows each image for 1/FPS seconds,
     then displays the next one. You can abort the animation at any time by
 | 
| 
     
      
      
      From: <ag...@us...> - 2004-01-01 02:03:11
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv10303
Modified Files:
	magick.c 
Log Message:
bug fix in set_pixel function
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** magick.c	31 Dec 2003 15:56:43 -0000	1.34
--- magick.c	1 Jan 2004 02:03:06 -0000	1.35
***************
*** 510,513 ****
--- 510,514 ----
        q->green=ScaleShortToQuantum(*p++);
        q->blue=ScaleShortToQuantum(*p++);
+       p++;
        q++;
      }
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 15:56:46
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv10261
Modified Files:
	magick.c magick.q 
Log Message:
added magick_colors function
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** magick.c	31 Dec 2003 15:01:34 -0000	1.33
--- magick.c	31 Dec 2003 15:56:43 -0000	1.34
***************
*** 1162,1165 ****
--- 1162,1182 ----
  }
  
+ FUNCTION(magick,magick_colors,argc,argv)
+ {
+   char *s;
+   if (argc == 1 && isstr(argv[0], &s)) {
+     unsigned long n;
+     char **color_list = GetColorList(s, &n);
+     if (color_list) {
+       expr *x = mknil;
+       while (n > 0 && x)
+ 	x = mkcons(mkstr(color_list[--n]), x);
+       return x;
+     } else
+       return __FAIL;
+   } else
+     return __FAIL;
+ }
+ 
  FUNCTION(magick,create_image,argc,argv)
  {
Index: magick.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** magick.q	31 Dec 2003 15:01:34 -0000	1.31
--- magick.q	31 Dec 2003 15:56:43 -0000	1.32
***************
*** 157,160 ****
--- 157,165 ----
  public extern magick_pixel COLOR, magick_color PIXEL;
  
+ /* The magick_colors function returns all color names known to ImageMagick
+    which match the given glob pattern. */
+ 
+ public extern magick_colors PATTERN;
+ 
  /***************************************************************************/
  
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 15:01:38
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv2047
Modified Files:
	README-Magick magick.c magick.q 
Log Message:
more final touches: added colorspace constants, simplified quantize interface, overhauled magicktest example
Index: README-Magick
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/README-Magick,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** README-Magick	31 Dec 2003 01:47:52 -0000	1.5
--- README-Magick	31 Dec 2003 15:01:34 -0000	1.6
***************
*** 12,18 ****
  
  The module requires that you have ImageMagick installed, which should be
! readily available in most Linux distributions. The Windows Qpad package will
! include all necessary support files once this module is released. At present a
! fairly recent ImageMagick version (>= 5.5) is required.
  
  Please see magick.q for a description of the functions provided by this
--- 12,19 ----
  
  The module requires that you have ImageMagick installed, which should be
! readily available in most Linux distributions. At present a fairly recent
! ImageMagick version (>= 5.5) is required. The Windows Qpad package will
! include all necessary support files once this module is included in the
! official release.
  
  Please see magick.q for a description of the functions provided by this
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** magick.c	31 Dec 2003 06:18:38 -0000	1.32
--- magick.c	31 Dec 2003 15:01:34 -0000	1.33
***************
*** 157,161 ****
    if (argc != 0) return __FAIL;
    return mktuplel
!     (72,
       mkuint(NoCompression),
       mkuint(BZipCompression),
--- 157,161 ----
    if (argc != 0) return __FAIL;
    return mktuplel
!     (84,
       mkuint(NoCompression),
       mkuint(BZipCompression),
***************
*** 180,183 ****
--- 180,196 ----
       mkuint(StaticGravity),
  
+      mkuint(RGBColorspace),
+      mkuint(GRAYColorspace),
+      mkuint(TransparentColorspace),
+      mkuint(OHTAColorspace),
+      mkuint(XYZColorspace),
+      mkuint(YCbCrColorspace),
+      mkuint(YCCColorspace),
+      mkuint(YIQColorspace),
+      mkuint(YPbPrColorspace),
+      mkuint(YUVColorspace),
+      mkuint(CMYKColorspace),
+      mkuint(sRGBColorspace),
+ 
       mkuint(PointFilter),
       mkuint(BoxFilter),
***************
*** 1467,1483 ****
  {
    Image *img = NULL, *imgs = NULL, *img2 = NULL;
!   unsigned long space = 1, ncolors = 255;
    int dither = 0, res;
    int n;
    expr *xv;
!   if (argc == 3 &&
        (isobj(argv[0], type(Image), (void**)&img) ||
         is_image_list(argv[0], &imgs)) &&
!       (isobj(argv[1], type(Image), (void**)&img2) ||
!        isuint(argv[1], &space) && space <= 1 ||
!        istuple(argv[1], &n, &xv) && n == 2 &&
!        isuint(xv[0], &space) && space <= 1 &&
!        isuint(xv[1], &ncolors) && ncolors <= MaxRGB) &&
!       isbool(argv[2], &dither)) {
      if (img2) {
        if (imgs) {
--- 1480,1506 ----
  {
    Image *img = NULL, *imgs = NULL, *img2 = NULL;
!   unsigned long space = RGBColorspace, ncolors = 255;
    int dither = 0, res;
    int n;
    expr *xv;
!   if (argc == 2 &&
        (isobj(argv[0], type(Image), (void**)&img) ||
         is_image_list(argv[0], &imgs)) &&
!       (isuint(argv[1], &space) ||
!        isobj(argv[1], type(Image), (void**)&img2) ||
!        istuple(argv[1], &n, &xv) &&
!        (n == 1 &&
! 	(isuint(xv[0], &space) ||
! 	 isobj(xv[0], type(Image), (void**)&img2)) ||
! 	n == 2 &&
! 	(isuint(xv[0], &space) &&
! 	 (isuint(xv[1], &ncolors) || isbool(xv[1], &dither)) ||
! 	 isobj(xv[0], type(Image), (void**)&img2) &&
! 	 isbool(xv[1], &dither)) ||
! 	n == 3 &&
! 	isuint(xv[0], &space) &&
! 	isuint(xv[1], &ncolors) &&
! 	isbool(xv[2], &dither))) &&
!        ncolors <= MaxRGB) {
      if (img2) {
        if (imgs) {
***************
*** 1491,1495 ****
        info.dither = dither;
        info.number_colors = ncolors;
!       info.colorspace = (space==0)?GRAYColorspace:RGBColorspace;
        if (imgs) {
  	res = QuantizeImages(&info, imgs);
--- 1514,1518 ----
        info.dither = dither;
        info.number_colors = ncolors;
!       info.colorspace = space;
        if (imgs) {
  	res = QuantizeImages(&info, imgs);
***************
*** 1980,1989 ****
    double cluster, smooth;
    if (argc == 5 && isobj(argv[0], type(Image), (void**)&img) &&
!       isuint(argv[1], &space) && space <= 1 &&
        isbool(argv[2], &verbose) &&
        (isfloat(argv[3], &cluster) || ismpz_float(argv[3], &cluster)) &&
        (isfloat(argv[4], &smooth) || ismpz_float(argv[4], &smooth))) {
!     int res = SegmentImage(img, (space==0)?GRAYColorspace:RGBColorspace,
! 			   verbose, cluster, smooth);
      if (!res)
        return __FAIL;
--- 2003,2011 ----
    double cluster, smooth;
    if (argc == 5 && isobj(argv[0], type(Image), (void**)&img) &&
!       isuint(argv[1], &space) &&
        isbool(argv[2], &verbose) &&
        (isfloat(argv[3], &cluster) || ismpz_float(argv[3], &cluster)) &&
        (isfloat(argv[4], &smooth) || ismpz_float(argv[4], &smooth))) {
!     int res = SegmentImage(img, space, verbose, cluster, smooth);
      if (!res)
        return __FAIL;
Index: magick.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** magick.q	31 Dec 2003 06:18:38 -0000	1.30
--- magick.q	31 Dec 2003 15:01:34 -0000	1.31
***************
*** 20,31 ****
  
  /* This module provides access to the ImageMagick C API (libMagick), a
!    comprehensive library for image manipulation. Requires ImageMagick,
!    available from http://www.imagemagick.org/. All essential ImageMagick
!    operations are supported, including creating, reading and writing images in
!    a plethora of different formats, retrieving and changing the pixel data of
!    an image, davanced image manipulation and effect functions, and drawing
!    primitives. As the external pixel representation is the same as that of the
!    GGI module, it is easy to exchange pixel data with GGI visuals to actually
!    display the images. */
  
  import clib;
--- 20,31 ----
  
  /* This module provides access to the ImageMagick C API (libMagick), a
!    comprehensive library for image manipulation, which is available from
!    http://www.imagemagick.org/. All essential ImageMagick operations are
!    supported, thus you can create, read and write images in all ImageMagick-
!    supported formats, access the pixel data of an image, apply advanced image
!    manipulation and effect functions, and draw a variety of graphic primitives
!    on an image. Since the external pixel representation is compatible with
!    that of the Q-GGI module, you can easily exchange pixel data between images
!    and GGI visuals as well. */
  
  import clib;
***************
*** 35,42 ****
  /* Manifest constants. */
  
- /* Colorspace values, used by the quantize and segment operations. */
- public var const GRAY, RGB;
- def GRAY = 0, RGB = 1;
- 
  /* This is used to indicate the default value for various options. */
  public var const DEFAULT;
--- 35,38 ----
***************
*** 51,54 ****
--- 47,54 ----
    SOUTH, SOUTH_EAST, STATIC,
  
+   /* Colorspace values, used by the quantize and segment operations. */
+   RGB, GRAY, TRANSPARENT, OHTA, XYZ, YCbCr, YCC, YIQ, YPbPr, YUV, CMYK,
+   SRGB,
+ 
    /* Filter types for the resize function. */
    POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER,
***************
*** 74,77 ****
--- 74,80 ----
       SOUTH, SOUTH_EAST, STATIC,
  
+      RGB, GRAY, TRANSPARENT, OHTA, XYZ, YCbCr, YCC, YIQ, YPbPr, YUV, CMYK,
+      SRGB,
+ 
       POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER,
       HANNING_FILTER, HAMMING_FILTER, BLACKMAN_FILTER, GAUSSIAN_FILTER,
***************
*** 477,481 ****
     named `flipy' and `flipx'. (Or was it the other way round? Go figure. ;-)
     (2) `RaiseImage' is named `button' (that's more suggestive, too, and btw a
!    `raise' function is already in clib, so we don't want to abuse that name).
  
     A note on parameters: IMG always denotes a singleton input image, IMGS an
--- 480,484 ----
     named `flipy' and `flipx'. (Or was it the other way round? Go figure. ;-)
     (2) `RaiseImage' is named `button' (that's more suggestive, too, and btw a
!    `raise' function is already in clib, so we don't want to reuse that name).
  
     A note on parameters: IMG always denotes a singleton input image, IMGS an
***************
*** 493,512 ****
  /* FIXME: Some of the stuff below really needs further documentation. For the
     time being, please take a look at what the corresponding C or Perl
!    functions, or ImageMagick command line options do. */
  
! /* Quantization. */
  
! /* NOTE: The COLORSPACE parameter designates the target colorspace, and can be
!    either (1) one of the constant values GRAY and RGB, or (2) a pair
!    (COLORSPACE, COLORS) denoting both the colorspace and the desired maximum
!    number of colors, or (3) a reference image specifying the colormap to be
!    applied to the target image. In case (1) the number of colors defaults to
!    256. The DITHER flag determines whether to apply Floyd/Steinberg dithering
!    to the image. The target image IMG can also be a list of images which are
!    to be mapped to the same colormap. Please note that this is a BANG! type
!    operation, thus if you you want to retain the original images you will have
!    to clone them first. */
  
! public extern quantize IMG COLORSPACE DITHER;			// BANG!
  
  /* Resizing, scaling and transformations. */
--- 496,520 ----
  /* FIXME: Some of the stuff below really needs further documentation. For the
     time being, please take a look at what the corresponding C or Perl
!    functions or ImageMagick command line options do. */
  
! /* Quantization. This operation is used to remap the colors of an image to a
!    fixed number of "similar" colors in a given colorspace.
  
!    - The COLORSPACE argument designates the target colorspace, and can be
!      either (1) one of the colorspace values listed in the manifest constants
!      section (RGB, GRAY etc.), or (2) a reference image IMG2 specifying the
!      colormap to be applied to the target image, or (3) a tuple with up to 3
!      fields, either (COLORSPACE[,MAXCOLORS][,DITHER]) or (IMG2[,DITHER]). The
!      MAXCOLORS value denotes the maximum number of colors in the quantized
!      image and defaults to 256. The DITHER flag determines whether to apply
!      Floyd/Steinberg dithering to the image; it defaults to true.
  
!    - The target image IMG can also be a list of images which are all to be
!      mapped to the same colormap.
! 
!    - Please note that this is a BANG! type operation, thus if you you want to
!      retain the original images you will have to clone them first. */
! 
! public extern quantize IMG COLORSPACE;				// BANG!
  
  /* Resizing, scaling and transformations. */
***************
*** 564,568 ****
  
     Note that this operation may also return a list of images, if the tiles do
!    not fit all on one page. Also note that to get labels on the images, you
     have to set them first with the set_image_attr function. */
  
--- 572,576 ----
  
     Note that this operation may also return a list of images, if the tiles do
!    not all fit on one page. Also note that to get labels on the images, you
     have to set them first with the set_image_attr function. */
  
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 15:01:38
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv2047/examples
Modified Files:
	magicktest.q 
Log Message:
more final touches: added colorspace constants, simplified quantize interface, overhauled magicktest example
Index: magicktest.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** magicktest.q	31 Dec 2003 06:27:57 -0000	1.13
--- magicktest.q	31 Dec 2003 15:01:34 -0000	1.14
***************
*** 8,13 ****
  /****************************************************************************/
  
  /* display IMG: Display the given image in a GGI visual. Returns the created
!    visual. Some examples:
  
     Display an image read from a file, use defaults:
--- 8,20 ----
  /****************************************************************************/
  
+ /* Display driver. Assume DirectX on Windows, X11 everywhere else. */
+ 
+ target		= "directx" if pos "mingw" sysinfo >= 0;
+ 		= "x" otherwise;
+ 
+ /****************************************************************************/
+ 
  /* display IMG: Display the given image in a GGI visual. Returns the created
!    visual. Here are some examples for you to try:
  
     Display an image read from a file, use defaults:
***************
*** 38,42 ****
     Display a screenshot of an X11 window:
  
!    ==> display (read_image "x:" ())
  
     (When the cross cursor appears, click on the window to capture. You can
--- 45,49 ----
     Display a screenshot of an X11 window:
  
!    ==> def IMG = read_image "x:" (); display IMG
  
     (When the cross cursor appears, click on the window to capture. You can
***************
*** 44,61 ****
     its id. See ImageMagick(1) for more details.)
  
!    As a final example, let's render some inline PostScript code:
  
     ==> def PS = "%!PS-Adobe-3.0 EPSF-3.0\n\
!    %%BoundingBox: 0 0 100 100\n\
!    50 50 50 0 360 arc stroke showpage\n"
  
     ==> display (blob_to_image (bytestr PS) ())
  
!    Cute, isn't it? By these means, you can employ the full power of PostScript
!    to draw complicated stuff in a GGI visual, which would be hard to do using
!    only GGI's very basic drawing operations. Of course, we could also employ
!    the graphics.q script in the standard library to create the PostScript
!    source in a convenient manner. This is left as an exercise to the
!    interested reader. :) */
  
  /* The simple case: our image is opaque. In this case we just render it on a
--- 51,101 ----
     its id. See ImageMagick(1) for more details.)
  
!    Show the same image, converted to grayscale (we first clone the image so
!    that the original image is not modified):
! 
!    ==> def IMG2 = clone_image IMG; quantize IMG2 GRAY; display IMG2
! 
!    The same image quantized to the colors in "netscape:":
! 
!    ==> def IMG2 = clone_image IMG; quantize IMG2 (read_image "netscape:" ())
! 
!    ==> display IMG2
! 
!    As a final example, let's see how we can draw something on an image. We
!    start out with a white canvas:
! 
!    ==> def IMG = read_image "xc:white" (320,240)
! 
!    Now draw some stuff and display the resulting image in a GGI visual:
! 
!    ==> draw IMG "stroke black fill none circle 160,120 240,120"
! 
!    ==> draw IMG "text 160,120 \"Hello, world!\""
! 
!    ==> display IMG
! 
!    It goes without saying that this method is much more convenient than using
!    GGI's own, very basic, drawing primitives.
! 
!    Now if we were *real* hackers, of course we'd do the same in PostScript
!    instead. ;-) Actually, we *are* real hackers, so here's how we can render
!    some "inline" PostScript code in a GGI visual (note that ImageMagick needs
!    ghostscript to make this work):
  
     ==> def PS = "%!PS-Adobe-3.0 EPSF-3.0\n\
!    %%BoundingBox: 0 0 320 240\n\
!    /Helvetica findfont 12 scalefont setfont \
!    160 120 80 0 360 arc stroke 160 120 moveto (Hello, world!) show \
!    showpage\n"
  
     ==> display (blob_to_image (bytestr PS) ())
  
!    Here we used the blob_to_image function to convert the PostScript code in
!    "blob" (i.e., byte string) format to an image which can then be shown in a
!    GGI visual. By these means, you can employ the full power of PostScript to
!    draw complicated stuff in a GGI visual. Of course, we could also employ the
!    graphics.q script in the standard library to create the PostScript source
!    in a convenient manner. This is left as an exercise to the interested
!    reader. :) */
  
  /* The simple case: our image is opaque. In this case we just render it on a
***************
*** 167,175 ****
      LABELS = map (sprintf CMD) SCENES, _ = zipwith draw IMGS LABELS,
      IMGS = morph (append IMGS (hd IMGS)) 50;
- 
- /****************************************************************************/
- 
- /* Display driver. Assume DirectX on Windows, X11 everywhere else. */
- 
- target		= "directx" if pos "mingw" sysinfo >= 0;
- 		= "x" otherwise;
--- 207,208 ----
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 06:34:58
      
     
   | 
Update of /cvsroot/q-lang/q In directory sc8-pr-cvs1:/tmp/cvs-serv22201 Modified Files: ChangeLog Log Message: updated ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/q-lang/q/ChangeLog,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ChangeLog 30 Dec 2003 05:43:48 -0000 1.11 --- ChangeLog 31 Dec 2003 06:34:54 -0000 1.12 *************** *** 1,2 **** --- 1,6 ---- + 2003-12-31 Albert Graef <Dr....@t-...> + + * magick: added drawing ops, this one is finished! + 2003-12-30 Albert Graef <Dr....@t-...>  | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 06:28:00
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv21541/examples
Modified Files:
	magicktest.q 
Log Message:
bug fix in draw example
Index: magicktest.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** magicktest.q	31 Dec 2003 06:18:39 -0000	1.12
--- magicktest.q	31 Dec 2003 06:27:57 -0000	1.13
***************
*** 162,166 ****
  = animate IMGS
  
!   where IMGS = map (IMGS!) SCENES, H:Int = image_height (hd IMGS),
      CMD = sprintf "fill white text 10,%d #%%d" (H-10),
      LABELS = map (sprintf CMD) SCENES, _ = zipwith draw IMGS LABELS,
--- 162,167 ----
  = animate IMGS
  
!   where IMGS = map (compose clone_image (IMGS!)) SCENES,
!     H:Int = image_height (hd IMGS),
      CMD = sprintf "fill white text 10,%d #%%d" (H-10),
      LABELS = map (sprintf CMD) SCENES, _ = zipwith draw IMGS LABELS,
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 06:18:42
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples In directory sc8-pr-cvs1:/tmp/cvs-serv20315/examples Modified Files: magicktest.q Log Message: added draw example, bug fixes Index: magicktest.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** magicktest.q 31 Dec 2003 01:47:53 -0000 1.11 --- magicktest.q 31 Dec 2003 06:18:39 -0000 1.12 *************** *** 162,166 **** = animate IMGS ! where IMGS = map (IMGS!) SCENES, IMGS = morph (append IMGS (hd IMGS)) 50; /****************************************************************************/ --- 162,169 ---- = animate IMGS ! where IMGS = map (IMGS!) SCENES, H:Int = image_height (hd IMGS), ! CMD = sprintf "fill white text 10,%d #%%d" (H-10), ! LABELS = map (sprintf CMD) SCENES, _ = zipwith draw IMGS LABELS, ! IMGS = morph (append IMGS (hd IMGS)) 50; /****************************************************************************/  | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 06:18:42
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv20315
Modified Files:
	magick.c magick.q 
Log Message:
added draw example, bug fixes
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** magick.c	31 Dec 2003 05:37:52 -0000	1.31
--- magick.c	31 Dec 2003 06:18:38 -0000	1.32
***************
*** 682,686 ****
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->fill, m->v, 1, img->matte);
      return mkvoid;
    } else
--- 682,686 ----
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->fill, m->v, 1, 1);
      return mkvoid;
    } else
***************
*** 696,700 ****
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->stroke, m->v, 1, img->matte);
      return mkvoid;
    } else
--- 696,700 ----
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->stroke, m->v, 1, 1);
      return mkvoid;
    } else
***************
*** 710,714 ****
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->undercolor, m->v, 1, img->matte);
      return mkvoid;
    } else
--- 710,714 ----
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->undercolor, m->v, 1, 1);
      return mkvoid;
    } else
***************
*** 724,728 ****
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->border_color, m->v, 1, img->matte);
      return mkvoid;
    } else
--- 724,728 ----
        (draw_info = get_draw_info(img)) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&draw_info->border_color, m->v, 1, 1);
      return mkvoid;
    } else
***************
*** 811,815 ****
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&img->background_color, m->v, 1, img->matte);
      return mkvoid;
    } else
--- 811,815 ----
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&img->background_color, m->v, 1, 1);
      return mkvoid;
    } else
***************
*** 838,842 ****
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&img->border_color, m->v, 1, img->matte);
      return mkvoid;
    } else
--- 838,842 ----
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&img->border_color, m->v, 1, 1);
      return mkvoid;
    } else
***************
*** 865,869 ****
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&img->matte_color, m->v, 1, img->matte);
      return mkvoid;
    } else
--- 865,869 ----
    if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
        isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
!     set_pixels(&img->matte_color, m->v, 1, 1);
      return mkvoid;
    } else
Index: magick.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** magick.q	31 Dec 2003 05:37:52 -0000	1.29
--- magick.q	31 Dec 2003 06:18:38 -0000	1.30
***************
*** 220,224 ****
       the graphics primitives. The FILL color is used for the interior, STROKE
       for the outline of graphic objects; use FILL = magick_pixel "none" if no
!      filling is desired. UNDERCOLOR determines the color for underlining text.
  
     - BORDER_COLOR: Pixel value, determines the border color for flood fill
--- 220,225 ----
       the graphics primitives. The FILL color is used for the interior, STROKE
       for the outline of graphic objects; use FILL = magick_pixel "none" if no
!      filling is desired. UNDERCOLOR determines the background color for text
!      rendering.
  
     - BORDER_COLOR: Pixel value, determines the border color for flood fill
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 05:37:55
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv15199
Modified Files:
	magick.c magick.q 
Log Message:
added draw info stuff, finishing touches
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** magick.c	31 Dec 2003 01:47:52 -0000	1.30
--- magick.c	31 Dec 2003 05:37:52 -0000	1.31
***************
*** 124,127 ****
--- 124,147 ----
  }
  
+ static inline expr mkbool(int val)
+ {
+   if (val)
+     return mktrue;
+   else
+     return mkfalse;
+ }
+ 
+ static inline int isbool(expr x, int *val)
+ {
+   if (istrue(x)) {
+     *val = 1;
+     return 1;
+   } else if (isfalse(x)) {
+     *val = 0;
+     return 1;
+   } else
+     return 0;
+ }
+ 
  /* ByteStr data structure, see clib.c */
  
***************
*** 137,141 ****
    if (argc != 0) return __FAIL;
    return mktuplel
!     (61,
       mkuint(NoCompression),
       mkuint(BZipCompression),
--- 157,161 ----
    if (argc != 0) return __FAIL;
    return mktuplel
!     (72,
       mkuint(NoCompression),
       mkuint(BZipCompression),
***************
*** 148,151 ****
--- 168,183 ----
       mkuint(ZipCompression),
  
+      mkuint(ForgetGravity),
+      mkuint(NorthWestGravity),
+      mkuint(NorthGravity),
+      mkuint(NorthEastGravity),
+      mkuint(WestGravity),
+      mkuint(CenterGravity),
+      mkuint(EastGravity),
+      mkuint(SouthWestGravity),
+      mkuint(SouthGravity),
+      mkuint(SouthEastGravity),
+      mkuint(StaticGravity),
+ 
       mkuint(PointFilter),
       mkuint(BoxFilter),
***************
*** 469,472 ****
--- 501,515 ----
  }
  
+ static inline expr mkpixel(PixelPacket *pixel)
+ {
+   bstr_t *m;
+   if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(8))) {
+     if (m) free(m); return __ERROR;
+   }
+   m->size = 8;
+   get_pixels(m->v, pixel, 1, 1);
+   return mkobj(type(ByteStr), m);
+ }
+ 
  /* parse info tuples */
  
***************
*** 538,541 ****
--- 581,793 ----
  }
  
+ FUNCTION(magick,draw_info,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   if (argc == 1 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img))) {
+     expr font, tile;
+     if (draw_info->font)
+       font = mkstr(strdup(draw_info->font));
+     else
+       font = mkvoid;
+     if (draw_info->tile)
+       tile = mkobj(type(Image), ReferenceImage(draw_info->tile));
+     else
+       tile = mkvoid;
+     return mktuplel(11, font,
+ 		    mkfloat(draw_info->pointsize),
+ 		    mkuint(draw_info->gravity),
+ 		    mkpixel(&draw_info->fill),
+ 		    mkpixel(&draw_info->stroke),
+ 		    mkpixel(&draw_info->undercolor),
+ 		    mkpixel(&draw_info->border_color),
+ 		    mkfloat(draw_info->stroke_width),
+ 		    mkbool(draw_info->stroke_antialias),
+ 		    mkbool(draw_info->text_antialias),
+ 		    tile);
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,type_metrics,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   if (argc == 1 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img))) {
+     TypeMetric metrics;
+     if (GetTypeMetrics(img, draw_info, &metrics))
+       return mktuplel(9, mkfloat(metrics.pixels_per_em.x),
+ 		      mkfloat(metrics.pixels_per_em.y),
+ 		      mkfloat(metrics.ascent),
+ 		      mkfloat(metrics.descent),
+ 		      mkfloat(metrics.width),
+ 		      mkfloat(metrics.height),
+ 		      mkfloat(metrics.max_advance),
+ 		      mkfloat(metrics.underline_position),
+ 		      mkfloat(metrics.underline_thickness));
+     else
+       return __FAIL;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_font,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   char *font;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) && isstr(argv[1], &font) &&
+       CloneString(&draw_info->font, font))
+     return mkvoid;
+   else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_pointsize,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   double val;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) &&
+       (isfloat(argv[1], &val) || ismpz_float(argv[1], &val))) {
+     draw_info->pointsize = val;
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_gravity,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   unsigned long val;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) && isuint(argv[1], &val)) {
+     draw_info->gravity = val;
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_fill,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   bstr_t *m;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) &&
+       isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
+     set_pixels(&draw_info->fill, m->v, 1, img->matte);
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_stroke,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   bstr_t *m;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) &&
+       isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
+     set_pixels(&draw_info->stroke, m->v, 1, img->matte);
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_undercolor,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   bstr_t *m;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) &&
+       isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
+     set_pixels(&draw_info->undercolor, m->v, 1, img->matte);
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_border_color,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   bstr_t *m;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) &&
+       isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) {
+     set_pixels(&draw_info->border_color, m->v, 1, img->matte);
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_stroke_width,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   double val;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) &&
+       (isfloat(argv[1], &val) || ismpz_float(argv[1], &val))) {
+     draw_info->stroke_width = val;
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_stroke_antialias,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   int val;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) && isbool(argv[1], &val)) {
+     draw_info->stroke_antialias = val;
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_text_antialias,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   int val;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) && isbool(argv[1], &val)) {
+     draw_info->text_antialias = val;
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,set_draw_tile,argc,argv)
+ {
+   Image *img, *tile;
+   DrawInfo *draw_info;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) &&
+       isobj(argv[1], type(Image), (void**)&tile)) {
+     /* we better clone the image here, to avoid nasty circular references */
+     tile = CloneImage(tile, 0, 0, 1, &exception);
+     if (check_exception(&exception))
+       return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
+     else if (tile)
+       draw_info->tile = tile;
+     else
+       return __FAIL;
+     return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
  FUNCTION(magick,image_background_color,argc,argv)
  {
***************
*** 751,755 ****
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return res?mktrue:mkfalse;
    } else
      return __FAIL;
--- 1003,1007 ----
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return mkbool(res);
    } else
      return __FAIL;
***************
*** 764,768 ****
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return res?mktrue:mkfalse;
    } else
      return __FAIL;
--- 1016,1020 ----
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return mkbool(res);
    } else
      return __FAIL;
***************
*** 777,781 ****
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return res?mktrue:mkfalse;
    } else
      return __FAIL;
--- 1029,1033 ----
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return mkbool(res);
    } else
      return __FAIL;
***************
*** 790,794 ****
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return res?mktrue:mkfalse;
    } else
      return __FAIL;
--- 1042,1046 ----
        return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
      else
!       return mkbool(res);
    } else
      return __FAIL;
***************
*** 1210,1225 ****
    } else
      return __FAIL;
- }
- 
- static inline int isbool(expr x, int *val)
- {
-   if (istrue(x)) {
-     *val = 1;
-     return 1;
-   } else if (isfalse(x)) {
-     *val = 0;
-     return 1;
-   } else
-     return 0;
  }
  
--- 1462,1465 ----
Index: magick.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** magick.q	31 Dec 2003 01:47:52 -0000	1.28
--- magick.q	31 Dec 2003 05:37:52 -0000	1.29
***************
*** 26,30 ****
     an image, davanced image manipulation and effect functions, and drawing
     primitives. As the external pixel representation is the same as that of the
!    GGI module, GGI visuals can be employed to actually display the images. */
  
  import clib;
--- 26,31 ----
     an image, davanced image manipulation and effect functions, and drawing
     primitives. As the external pixel representation is the same as that of the
!    GGI module, it is easy to exchange pixel data with GGI visuals to actually
!    display the images. */
  
  import clib;
***************
*** 46,49 ****
--- 47,54 ----
    NONE, BZIP, FAX, GROUP4, JPEG, LOSSLESS, LZW, RLE, ZIP,
  
+   /* Gravity types used by the DRAW_INFO structure. */
+   FORGET, NORTH_WEST, NORTH, NORTH_EAST, WEST, CENTER, EAST, SOUTH_WEST,
+   SOUTH, SOUTH_EAST, STATIC,
+ 
    /* Filter types for the resize function. */
    POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER,
***************
*** 66,69 ****
--- 71,77 ----
  def (NONE, BZIP, FAX, GROUP4, JPEG, LOSSLESS, LZW, RLE, ZIP,
  
+      FORGET, NORTH_WEST, NORTH, NORTH_EAST, WEST, CENTER, EAST, SOUTH_WEST,
+      SOUTH, SOUTH_EAST, STATIC,
+ 
       POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER,
       HANNING_FILTER, HAMMING_FILTER, BLACKMAN_FILTER, GAUSSIAN_FILTER,
***************
*** 192,211 ****
    image_matte IMG, image_magick IMG;
  
! image_width IMG		= W where (W,H,O,D,A,M) = image_info IMG;
! image_height IMG	= H where (W,H,O,D,A,M) = image_info IMG;
! image_offset IMG	= O where (W,H,O,D,A,M) = image_info IMG;
! image_depth IMG		= D where (W,H,O,D,A,M) = image_info IMG;
! image_matte IMG		= A where (W,H,O,D,A,M) = image_info IMG;
! image_magick IMG	= M where (W,H,O,D,A,M) = image_info IMG;
  
! /* The DRAW_INFO structure of an image summarizes various properties which
!    control the rendering of graphics primitives with the draw function. It can
!    be retrieved and changed with the following operations. */
  
! // TODO:
! //public extern draw_info IMG, set_draw_info IMG INFO;
  
! /* A few other properties can be retrieved and changed with the following
!    operations. These properties are currently supported:
  
     - background_color, border_color, matte_color: The image background, border
--- 200,299 ----
    image_matte IMG, image_magick IMG;
  
! image_width IMG		= INFO!0 where INFO:Tuple = image_info IMG;
! image_height IMG	= INFO!1 where INFO:Tuple = image_info IMG;
! image_offset IMG	= INFO!2 where INFO:Tuple = image_info IMG;
! image_depth IMG		= INFO!3 where INFO:Tuple = image_info IMG;
! image_matte IMG		= INFO!4 where INFO:Tuple = image_info IMG;
! image_magick IMG	= INFO!5 where INFO:Tuple = image_info IMG;
  
! /* Image attributes related to drawing are kept in a separate DRAW_INFO
!    structure which has the following fields:
  
!    - FONT: A string, the name of the font to be used for drawing text.
  
!    - POINTSIZE: Integer or floating point number, the font size.
! 
!    - GRAVITY: The default gravity of rendered text. Can be any of the gravity
!      values listed in the manifest constants section.
! 
!    - FILL, STROKE, UNDERCOLOR: Pixel values specifying the default colors for
!      the graphics primitives. The FILL color is used for the interior, STROKE
!      for the outline of graphic objects; use FILL = magick_pixel "none" if no
!      filling is desired. UNDERCOLOR determines the color for underlining text.
! 
!    - BORDER_COLOR: Pixel value, determines the border color for flood fill
!      operations.
! 
!    - STROKE_WIDTH: Integer or floating point value, the linewidth of outlines
!      drawn with the graphic primitives.
! 
!    - STROKE_ANTIALIAS, TEXT_ANTIALIAS: Two flags (either true or false),
!      indicating whether to perform antialiasing when rendering text and other
!      graphic objects.
! 
!    - TILE: An image to be tiled when filling a graphic object, () if none.
! 
!    The DRAW_INFO structure and its members can be accessed with the operations
!    listed below. */
! 
! /* FIXME: What about the other font properties (family, style, stretch,
!    weight, alignment) and rendering attributes (gradients, fill rule,
!    linecaps/-joins, miterlimit, dash offset and pattern) which are
!    undocumented but can be found in libMagick's DrawInfo struct? */
! 
! public extern draw_info IMG;
! 
! public draw_font IMG, draw_pointsize IMG, draw_gravity IMG, draw_fill IMG,
!   draw_stroke IMG, draw_undercolor IMG, draw_border_color IMG,
!   draw_stroke_width IMG, draw_stroke_antialias IMG, draw_text_antialias IMG,
!   draw_tile IMG;
! 
! draw_font IMG		= INFO!0 where INFO:Tuple = draw_info IMG;
! draw_pointsize IMG	= INFO!1 where INFO:Tuple = draw_info IMG;
! draw_gravity IMG	= INFO!2 where INFO:Tuple = draw_info IMG;
! draw_fill IMG		= INFO!3 where INFO:Tuple = draw_info IMG;
! draw_stroke IMG		= INFO!4 where INFO:Tuple = draw_info IMG;
! draw_undercolor IMG	= INFO!5 where INFO:Tuple = draw_info IMG;
! draw_border_color IMG	= INFO!6 where INFO:Tuple = draw_info IMG;
! draw_stroke_width IMG	= INFO!7 where INFO:Tuple = draw_info IMG;
! draw_stroke_antialias IMG
! 			= INFO!8 where INFO:Tuple = draw_info IMG;
! draw_text_antialias IMG	= INFO!9 where INFO:Tuple = draw_info IMG;
! draw_tile IMG		= INFO!10 where INFO:Tuple = draw_info IMG;
! 
! public extern set_draw_font IMG FONT,
!   set_draw_pointsize IMG POINTSIZE,
!   set_draw_gravity IMG GRAVITY,
!   set_draw_fill IMG FILL,
!   set_draw_stroke IMG STROKE,
!   set_draw_undercolor IMG UNDERCOLOR,
!   set_draw_border_color IMG BORDER_COLOR,
!   set_draw_stroke_width IMG STROKE_WIDTH,
!   set_draw_stroke_antialias IMG STROKE_ANTIALIAS,
!   set_draw_text_antialias IMG TEXT_ANTIALIAS,
!   set_draw_tile IMG TILE;
! 
! /* To provide support for laying out text in an image, the type_metrics
!    function gives access to the type metrics of the current font set on an
!    image. It returns a tuple with the following information:
! 
!    - PPEM_X, PPEM_Y: pixels per em, character width and height in pixels
! 
!    - ASCENT, DESCENT: ascent and descent of the font
! 
!    - WIDTH, HEIGHT: text width and height
! 
!    - ADVANCE: maximum horizontal advance
! 
!    - UNDERLINE_POSITION, UNDERLINE_THICKNESS: underline position and
!      thickness
! 
!    Note that all figures are in pixel units. Since fractional font sizes are
!    supported, the values are reported as floating point numbers. */
! 
! public extern type_metrics IMG;
! 
! /* A few other image properties can be retrieved and changed with the
!    operations listed below. The following properties are currently supported:
  
     - background_color, border_color, matte_color: The image background, border
***************
*** 245,259 ****
     list of an image, specify () as the VAL parameter of set_image_attr.
     Otherwise the given value is added to the attribute (an existing value is
!    *not* overridden automatically). Attributes used by ImageMagick include
!    "comment", "label" and "signature". In particular, the "label" attribute is
!    useful with the montage operation (see below). */
  
  public extern image_attr IMG KEY, set_image_attr IMG KEY VAL;
  
! /* Convenience functions to access the "label" attribute. */
  
  public image_label IMG, set_image_label IMG LABEL;
  
! image_label IMG:Image	= LABEL where LABEL:String = image_attr IMG "label";
  set_image_label IMG:Image LABEL:String
  			= set_image_attr IMG "label" () ||
--- 333,357 ----
     list of an image, specify () as the VAL parameter of set_image_attr.
     Otherwise the given value is added to the attribute (an existing value is
!    *not* overridden automatically, you first have to set the attribute to ()
!    to accomplish this). Attributes used by ImageMagick include "comment",
!    "label" and "signature". In particular, the "label" attribute is useful
!    with the montage operation (see below). */
  
  public extern image_attr IMG KEY, set_image_attr IMG KEY VAL;
  
! /* Convenience functions to access the "comment" and "label" attributes. */
! 
! public image_comment IMG, set_image_comment IMG COMMENT;
! 
! image_comment IMG:Image	= COMMENT
! 			    where COMMENT:String = image_attr IMG "comment";
! set_image_comment IMG:Image COMMENT:String
! 			= set_image_attr IMG "comment" () ||
! 			  set_image_attr IMG "comment" COMMENT;
  
  public image_label IMG, set_image_label IMG LABEL;
  
! image_label IMG:Image	= LABEL
! 			    where LABEL:String = image_attr IMG "label";
  set_image_label IMG:Image LABEL:String
  			= set_image_attr IMG "label" () ||
***************
*** 374,380 ****
     unchanged.
  
!    Most operations have the same name as in the C API (without the Image
!    suffix), with the following exceptions: `FlipImage' and `FlopImage' are
!    named `flipy' and `flipx', and `RaiseImage' is named `button'.
  
     A note on parameters: IMG always denotes a singleton input image, IMGS an
--- 472,480 ----
     unchanged.
  
!    Most operations have the same name as in the C API (without the `Image'
!    suffix), with the following exceptions: (1) `FlipImage' and `FlopImage' are
!    named `flipy' and `flipx'. (Or was it the other way round? Go figure. ;-)
!    (2) `RaiseImage' is named `button' (that's more suggestive, too, and btw a
!    `raise' function is already in clib, so we don't want to abuse that name).
  
     A note on parameters: IMG always denotes a singleton input image, IMGS an
***************
*** 389,392 ****
--- 489,496 ----
     various algorithms. These are explained in more detail in the ImageMagick
     manual. */
+ 
+ /* FIXME: Some of the stuff below really needs further documentation. For the
+    time being, please take a look at what the corresponding C or Perl
+    functions, or ImageMagick command line options do. */
  
  /* Quantization. */
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 01:47:56
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv13713 Modified Files: README-Magick magick.c magick.q Log Message: added magick_color and image_label/set_image_label functions, updated examples and docs Index: README-Magick =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/README-Magick,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README-Magick 29 Dec 2003 03:17:53 -0000 1.4 --- README-Magick 31 Dec 2003 01:47:52 -0000 1.5 *************** *** 3,23 **** ======== = =========== ========= === === = =========== ======== ! This module implements a simple interface to the ImageMagick C API ! (libMagick), a comprehensive library for image manipulation, see ! http://www.imagemagick.org/. With this module, you can create, load, save and ! manipulate images stored in a plethora of different file formats. Operations ! to retrieve and modify the pixel data of an image are also provided. Since the ! external pixel representation is compatible with that of the Q-GGI module, you ! can easily exchange pixel data between images and GGI visuals as well. ! ! Please note that this is still work in progress. The basic operations to ! create, load and save images, operations to retrieve and change the pixel ! data, and most image manipulation functions are already in place. Some of the ! more advanced image manipulation routines still need to be done. The module requires that you have ImageMagick installed, which should be ! readily available in most Linux distributions. The Windows Qpad package ! already includes all necessary support files. At present a fairly recent ! ImageMagick version (>= 5.5) is required. Please see magick.q for a description of the functions provided by this --- 3,18 ---- ======== = =========== ========= === === = =========== ======== ! This module provides an interface to the ImageMagick C API (libMagick), a ! comprehensive library for image manipulation, see http://www.imagemagick.org/. ! With this module, you can create, load, save and manipulate images stored in a ! plethora of different file formats. Operations to retrieve and modify the ! pixel data of an image are also provided. Since the external pixel ! representation is compatible with that of the Q-GGI module, you can easily ! exchange pixel data between images and GGI visuals as well. The module requires that you have ImageMagick installed, which should be ! readily available in most Linux distributions. The Windows Qpad package will ! include all necessary support files once this module is released. At present a ! fairly recent ImageMagick version (>= 5.5) is required. Please see magick.q for a description of the functions provided by this *************** *** 30,34 **** Enjoy! :) ! Dec 29 2003 Albert Graef ag...@mu..., Dr....@t-... --- 25,29 ---- Enjoy! :) ! Dec 31 2003 Albert Graef ag...@mu..., Dr....@t-... Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** magick.c 31 Dec 2003 00:22:52 -0000 1.29 --- magick.c 31 Dec 2003 01:47:52 -0000 1.30 *************** *** 869,872 **** --- 869,900 ---- } + FUNCTION(magick,magick_color,argc,argv) + { + bstr_t *m; + if (argc == 1 && isobj(argv[0], type(ByteStr), (void**)&m) && + m->size%8 == 0) { + if (m->size == 0) + return mknil; + else if (m->size == 8) { + unsigned short *v = (unsigned short*)m->v; + unsigned short r, g, b, a; + r = *v++; g = *v++; b = *v++; a = *v++; + return mktuplel(4, mkuint(r), mkuint(g), mkuint(b), mkuint(a)); + } else { + expr x = mknil; + int i, n = m->size/8; + unsigned short *v = (unsigned short*)(m->v+m->size); + unsigned short r, g, b, a; + for (i = 0; x && i < n; i++) { + a = *--v; b = *--v; g = *--v; r = *--v; + x = mkcons(mktuplel(4, mkuint(r), mkuint(g), mkuint(b), mkuint(a)), + x); + } + return x; + } + } else + return __FAIL; + } + FUNCTION(magick,create_image,argc,argv) { Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** magick.q 31 Dec 2003 00:22:52 -0000 1.27 --- magick.q 31 Dec 2003 01:47:52 -0000 1.28 *************** *** 1,4 **** ! /* magick.q: poor man's ImageMagick interface $Id$ */ --- 1,4 ---- ! /* magick.q: the Q programmer's ImageMagick interface $Id$ */ *************** *** 19,28 **** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! /* This module implements a simple interface to the ImageMagick C API ! (libMagick), a comprehensive library for image manipulation, see ! http://www.imagemagick.org/. Please note that this is still work in ! progress. The basic operations to create, load, save and manipulate images, ! and to retrieve and change image pixels are already in place. The ! annotation, draw and paint operations still need to be done. */ import clib; --- 19,30 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! /* This module provides access to the ImageMagick C API (libMagick), a ! comprehensive library for image manipulation. Requires ImageMagick, ! available from http://www.imagemagick.org/. All essential ImageMagick ! operations are supported, including creating, reading and writing images in ! a plethora of different formats, retrieving and changing the pixel data of ! an image, davanced image manipulation and effect functions, and drawing ! primitives. As the external pixel representation is the same as that of the ! GGI module, GGI visuals can be employed to actually display the images. */ import clib; *************** *** 137,143 **** 0xffff if it is missing. The function also packs a list of such values into a single byte string. The returned value can be passed as the PIXELS ! parameter of create_image and set_image_pixels. */ ! public extern magick_pixel COLOR; /***************************************************************************/ --- 139,148 ---- 0xffff if it is missing. The function also packs a list of such values into a single byte string. The returned value can be passed as the PIXELS ! parameter of create_image and set_image_pixels. ! The magick_color function converts an RGBA byte string back to an (R,G,B,A) ! tuple or a list of such tuples. */ ! ! public extern magick_pixel COLOR, magick_color PIXEL; /***************************************************************************/ *************** *** 194,199 **** image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; ! /* Some secondary image properties can be retrieved and changed with the ! following operations. The following properties are currently supported: - background_color, border_color, matte_color: The image background, border --- 199,211 ---- image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; ! /* The DRAW_INFO structure of an image summarizes various properties which ! control the rendering of graphics primitives with the draw function. It can ! be retrieved and changed with the following operations. */ ! ! // TODO: ! //public extern draw_info IMG, set_draw_info IMG INFO; ! ! /* A few other properties can be retrieved and changed with the following ! operations. These properties are currently supported: - background_color, border_color, matte_color: The image background, border *************** *** 229,246 **** public extern image_page IMG, set_image_page IMG PAGE; ! /* The following operations let you retrieve and change attributes (string ! values) associated with an image. To delete a key from the attributes list ! of an image, specify () as the VAL parameter of set_image_attr. Attributes ! used by ImageMagick include "comment", "label" and "signature". The "label" ! attribute is useful with the montage operation (see below). */ public extern image_attr IMG KEY, set_image_attr IMG KEY VAL; ! /* The DRAW_INFO structure of an image summarizes various properties which ! control the rendering of graphics primitives with the draw function. It can ! be retrieved and changed with the following operations. */ ! // TODO: ! //public extern draw_info IMG, set_draw_info IMG INFO; /***************************************************************************/ --- 241,262 ---- public extern image_page IMG, set_image_page IMG PAGE; ! /* The following operations let you retrieve and change named string ! attributes associated with an image. To delete a key from the attributes ! list of an image, specify () as the VAL parameter of set_image_attr. ! Otherwise the given value is added to the attribute (an existing value is ! *not* overridden automatically). Attributes used by ImageMagick include ! "comment", "label" and "signature". In particular, the "label" attribute is ! useful with the montage operation (see below). */ public extern image_attr IMG KEY, set_image_attr IMG KEY VAL; ! /* Convenience functions to access the "label" attribute. */ ! public image_label IMG, set_image_label IMG LABEL; ! ! image_label IMG:Image = LABEL where LABEL:String = image_attr IMG "label"; ! set_image_label IMG:Image LABEL:String ! = set_image_attr IMG "label" () || ! set_image_attr IMG "label" LABEL; /***************************************************************************/ *************** *** 496,500 **** public extern annotate IMG P TEXT; // BANG! ! public extern draw IMG CMD; // BANG! /* Painting. */ --- 512,516 ---- public extern annotate IMG P TEXT; // BANG! ! public extern draw IMG COMMAND; // BANG! /* Painting. */  | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 01:47:56
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv13713/examples
Modified Files:
	magicktest.q 
Log Message:
added magick_color and image_label/set_image_label functions, updated examples and docs
Index: magicktest.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** magicktest.q	31 Dec 2003 00:36:52 -0000	1.10
--- magicktest.q	31 Dec 2003 01:47:53 -0000	1.11
***************
*** 145,151 ****
  
    where IMGS = map (IMGS!) SCENES, LABELS = map (sprintf "#%d") SCENES,
!     _ = zipwith (flip set_image_attr "label") IMGS LABELS,
!     IMG = montage IMGS ("Gallery","5x4","120x120",(),10,true),
!     _ = zipwith (flip set_image_attr "label") IMGS (map (cst ()) LABELS);
  
  /****************************************************************************/
--- 145,150 ----
  
    where IMGS = map (IMGS!) SCENES, LABELS = map (sprintf "#%d") SCENES,
!     _ = zipwith set_image_label IMGS LABELS,
!     IMG = montage IMGS ("Gallery","5x4","120x120",(),10,true);
  
  /****************************************************************************/
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 00:36:55
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv1836
Modified Files:
	magicktest.q 
Log Message:
fixed examples in comments
Index: magicktest.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** magicktest.q	30 Dec 2003 14:08:41 -0000	1.9
--- magicktest.q	31 Dec 2003 00:36:52 -0000	1.10
***************
*** 17,29 ****
     Display raw RGBA file -- must specify the dimensions and depth here:
  
!    ==> display (read_image "mozilla_48x48.rgba" (48,48,8))
  
     Display a white image obtained from create_image:
  
!    ==> display (create_image (100,100,8) (magick_pixel "white"))
  
     Same using read_image with the "xc:" source specifier:
  
!    ==> display (read_image "xc:white" (100,100,8))
  
     Now for something a little more interesting. Show some of the builtin
--- 17,29 ----
     Display raw RGBA file -- must specify the dimensions and depth here:
  
!    ==> display (read_image "mozilla_48x48.rgba" (48,48,0,8))
  
     Display a white image obtained from create_image:
  
!    ==> display (create_image (100,100,0,8) (magick_pixel "white"))
  
     Same using read_image with the "xc:" source specifier:
  
!    ==> display (read_image "xc:white" (100,100,0,8))
  
     Now for something a little more interesting. Show some of the builtin
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-31 00:22:56
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv31482
Modified Files:
	magick.c magick.q 
Log Message:
added missing client_data initalizations, drawing ops
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** magick.c	30 Dec 2003 20:29:58 -0000	1.28
--- magick.c	31 Dec 2003 00:22:52 -0000	1.29
***************
*** 290,294 ****
  } ImageData;
  
! static ImageData *init_data(void)
  {
    ImageData *data = malloc(sizeof(ImageData));
--- 290,294 ----
  } ImageData;
  
! static inline ImageData *init_data(void)
  {
    ImageData *data = malloc(sizeof(ImageData));
***************
*** 300,303 ****
--- 300,314 ----
  }
  
+ static inline DrawInfo *get_draw_info(Image *img)
+ {
+   ImageData *data = (ImageData*)img->client_data;
+   if (data) {
+     if (!data->draw_info)
+       data->draw_info = CloneDrawInfo(NULL, NULL);
+     return data->draw_info;
+   } else
+     return NULL;
+ }
+ 
  /* image type */
  
***************
*** 313,316 ****
--- 324,414 ----
  }
  
+ static expr mk_image(Image *img)
+ {
+   img->scene = 0;
+   if ((img->client_data = init_data()))
+     return mkobj(type(Image), img);
+   else {
+     DestroyImage(img);
+     return __ERROR;
+   }
+ }
+ 
+ static void decompose_image_list(Image *img)
+ {
+   Image *tmp, *tmp2;
+   for (tmp = img; tmp; tmp = tmp2) {
+     tmp2 = tmp->next;
+     tmp->previous = tmp->next = NULL;
+     if (!tmp->client_data)
+       /* dispose temporary */
+       DestroyImage(tmp);
+     else
+       ((ImageData*)tmp->client_data)->tag = 0;
+   }
+ }
+ 
+ static expr mk_image_list(Image *img)
+ {
+   expr x = mknil;
+   Image *imgs;
+   /* convert image sequence into list of images */
+   for (imgs = img; imgs->next; imgs = imgs->next)
+     ;
+   /* imgs now points at the last image in the sequence */
+   while (x && imgs) {
+     Image *tmp = imgs->previous;
+     imgs->scene = 0;
+     if ((imgs->client_data = init_data()))
+       x = mkcons(mkobj(type(Image), imgs), x);
+     else {
+       dispose(x); x = __ERROR;
+     }
+     imgs = tmp;
+   }
+   if (x)
+     decompose_image_list(img);
+   else {
+     for (imgs = img; imgs; imgs = imgs->next)
+       if (imgs->client_data) free(imgs->client_data);
+     DestroyImageList(img);
+   }
+   return x;
+ }
+ 
+ static int is_image_list(expr x, Image **img)
+ {
+   expr y, hd, tl;
+   Image *tmp, *tmp2;
+   for (y = x; iscons(y, &hd, &tl); y = tl)
+     if (!(isobj(hd, type(Image), (void**)&tmp) &&
+ 	  tmp->columns > 0 && tmp->rows > 0))
+       return 0;
+   if (!isnil(y)) return 0;
+   *img = NULL;
+   if (isnil(x)) return 1;
+   tmp2 = NULL;
+   for (y = x; iscons(y, &hd, &tl); y = tl) {
+     isobj(hd, type(Image), (void**)&tmp);
+     if (tmp->client_data && ((ImageData*)tmp->client_data)->tag) {
+       /* this image is already in the list, create a temporary copy */
+       tmp = CloneImage(tmp, 0, 0, 1, &exception);
+       if (check_exception(&exception)) {
+ 	decompose_image_list(*img);
+ 	return 0;
+       }
+       tmp->client_data = NULL;
+     } else
+       ((ImageData*)tmp->client_data)->tag = 1;
+     if (tmp2) {
+       tmp->previous = tmp2;
+       tmp2->next = tmp;
+     } else
+       *img = tmp;
+     tmp2 = tmp;
+   }
+   return 1;
+ }
+ 
  /* Read RGBA pixels from a buffer. The color values are scaled to 16 bit and
     returned in RGBA order which matches the layout of GGI color values. */
***************
*** 783,787 ****
      ImageInfo info;
      Image *img;
-     ImageData *data;
      int matte;
      GetImageInfo(&info);
--- 881,884 ----
***************
*** 789,803 ****
  	!parse_info(n, xv, &info, &matte))
        return __FAIL;
-     if (!(data = init_data())) return __ERROR;
      img = AllocateImage(&info);
!     if (!img) {
!       free(data);
        return __ERROR;
!     } else {
        PixelPacket *pixels;
-       img->client_data = data;
        if (matte >= 0) img->matte = (unsigned)matte;
        if (!(pixels = SetImagePixels(img, 0, 0, w, h))) {
- 	free(img->client_data);
  	DestroyImage(img);
  	return __FAIL;
--- 886,896 ----
  	!parse_info(n, xv, &info, &matte))
        return __FAIL;
      img = AllocateImage(&info);
!     if (!img)
        return __ERROR;
!     else {
        PixelPacket *pixels;
        if (matte >= 0) img->matte = (unsigned)matte;
        if (!(pixels = SetImagePixels(img, 0, 0, w, h))) {
  	DestroyImage(img);
  	return __FAIL;
***************
*** 813,819 ****
        img->storage_class = DirectClass;
        if (SyncImagePixels(img))
! 	return mkobj(type(Image), img);
        else {
- 	free(img->client_data);
  	DestroyImage(img);
  	return __FAIL;
--- 906,911 ----
        img->storage_class = DirectClass;
        if (SyncImagePixels(img))
! 	return mk_image(img);
        else {
  	DestroyImage(img);
  	return __FAIL;
***************
*** 834,884 ****
        return __ERROR;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
  }
  
- static void decompose_image_list(Image *img)
- {
-   Image *tmp, *tmp2;
-   for (tmp = img; tmp; tmp = tmp2) {
-     tmp2 = tmp->next;
-     tmp->previous = tmp->next = NULL;
-     if (!tmp->client_data)
-       /* dispose temporary */
-       DestroyImage(tmp);
-     else
-       ((ImageData*)tmp->client_data)->tag = 0;
-   }
- }
- 
- static expr mk_image_list(Image *img)
- {
-   expr x = mknil;
-   Image *imgs;
-   /* convert image sequence into list of images */
-   for (imgs = img; imgs->next; imgs = imgs->next)
-     ;
-   /* imgs now points at the last image in the sequence */
-   while (x && imgs) {
-     Image *tmp = imgs->previous;
-     imgs->scene = 0;
-     if ((imgs->client_data = init_data()))
-       x = mkcons(mkobj(type(Image), imgs), x);
-     else {
-       dispose(x); x = NULL;
-     }
-     imgs = tmp;
-   }
-   if (x)
-     decompose_image_list(img);
-   else {
-     for (imgs = img; imgs; imgs = imgs->next)
-       if (imgs->client_data) free(imgs->client_data);
-     DestroyImageList(img);
-   }
-   return x;
- }
- 
  FUNCTION(magick,read_image,argc,argv)
  {
--- 926,934 ----
        return __ERROR;
      else
!       return mk_image(img);
    } else
      return __FAIL;
  }
  
  FUNCTION(magick,read_image,argc,argv)
  {
***************
*** 907,918 ****
        return mk_image_list(img);
      } else {
-       ImageData *data = init_data();
-       if (!data) {
- 	DestroyImage(img);
- 	return __ERROR;
-       }
-       img->client_data = data;
        if (matte >= 0) img->matte = (unsigned)matte;
!       return mkobj(type(Image), img);
      }
    } else
--- 957,962 ----
        return mk_image_list(img);
      } else {
        if (matte >= 0) img->matte = (unsigned)matte;
!       return mk_image(img);
      }
    } else
***************
*** 946,957 ****
        return mk_image_list(img);
      } else {
-       ImageData *data = init_data();
-       if (!data) {
- 	DestroyImage(img);
- 	return __ERROR;
-       }
-       img->client_data = data;
        if (matte >= 0) img->matte = (unsigned)matte;
!       return mkobj(type(Image), img);
      }
    } else
--- 990,995 ----
        return mk_image_list(img);
      } else {
        if (matte >= 0) img->matte = (unsigned)matte;
!       return mk_image(img);
      }
    } else
***************
*** 959,996 ****
  }
  
- static int is_image_list(expr x, Image **img)
- {
-   expr y, hd, tl;
-   Image *tmp, *tmp2;
-   for (y = x; iscons(y, &hd, &tl); y = tl)
-     if (!(isobj(hd, type(Image), (void**)&tmp) &&
- 	  tmp->columns > 0 && tmp->rows > 0))
-       return 0;
-   if (!isnil(y)) return 0;
-   *img = NULL;
-   if (isnil(x)) return 1;
-   tmp2 = NULL;
-   for (y = x; iscons(y, &hd, &tl); y = tl) {
-     isobj(hd, type(Image), (void**)&tmp);
-     if (tmp->client_data && ((ImageData*)tmp->client_data)->tag) {
-       /* this image is already in the list, create a temporary copy */
-       tmp = CloneImage(tmp, 0, 0, 1, &exception);
-       if (check_exception(&exception)) {
- 	decompose_image_list(*img);
- 	return 0;
-       }
-       tmp->client_data = NULL;
-     } else
-       ((ImageData*)tmp->client_data)->tag = 1;
-     if (tmp2) {
-       tmp->previous = tmp2;
-       tmp2->next = tmp;
-     } else
-       *img = tmp;
-     tmp2 = tmp;
-   }
-   return 1;
- }
- 
  FUNCTION(magick,write_image,argc,argv)
  {
--- 997,1000 ----
***************
*** 1108,1119 ****
        return mk_image_list(img);
      } else {
-       ImageData *data = init_data();
-       if (!data) {
- 	DestroyImage(img);
- 	return __ERROR;
-       }
-       img->client_data = data;
        if (matte >= 0) img->matte = (unsigned)matte;
!       return mkobj(type(Image), img);
      }
    } else
--- 1112,1117 ----
        return mk_image_list(img);
      } else {
        if (matte >= 0) img->matte = (unsigned)matte;
!       return mk_image(img);
      }
    } else
***************
*** 1261,1265 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1259,1263 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1287,1291 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1285,1289 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1307,1311 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1305,1309 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1330,1334 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1328,1332 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1345,1349 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1343,1347 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1360,1364 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1358,1362 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1383,1387 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1381,1385 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1403,1407 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1401,1405 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1423,1427 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1421,1425 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1443,1447 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1441,1445 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1458,1462 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1456,1460 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1473,1477 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1471,1475 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1490,1494 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1488,1492 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1511,1515 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1509,1513 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1537,1541 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1535,1539 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1569,1573 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1567,1571 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1585,1589 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1583,1587 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1686,1690 ****
        return mk_image_list(img);
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1684,1688 ----
        return mk_image_list(img);
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1852,1856 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1850,1854 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1869,1873 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1867,1871 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1887,1891 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1885,1889 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1902,1906 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1900,1904 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1919,1923 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1917,1921 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1937,1941 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1935,1939 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1952,1956 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1950,1954 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1970,1974 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1968,1972 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 1987,1991 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 1985,1989 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2006,2010 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2004,2008 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2023,2027 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2021,2025 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2041,2045 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2039,2043 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2059,2063 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2057,2061 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2076,2080 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2074,2078 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2111,2115 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2109,2113 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2129,2133 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2127,2131 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2150,2154 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2148,2152 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2178,2182 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2176,2180 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2195,2199 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2193,2197 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2230,2234 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2228,2232 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2261,2265 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2259,2263 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2277,2281 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2275,2279 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2294,2298 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2292,2296 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2312,2316 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2310,2314 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2334,2338 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2332,2336 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2363,2367 ****
        return __FAIL;
      else
!       return mkobj(type(Image), img);
    } else
      return __FAIL;
--- 2361,2365 ----
        return __FAIL;
      else
!       return mk_image(img);
    } else
      return __FAIL;
***************
*** 2385,2388 ****
--- 2383,2432 ----
      else
        return __FAIL;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,annotate,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   expr *xv;
+   int n;
+   long x, y;
+   char *s;
+   if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) && istuple(argv[1], &n, &xv) &&
+       isint(xv[0], &x) && isint(xv[1], &y) &&
+       isstr(argv[2], &s)) {
+     int res;
+     char geom[100];
+     sprintf(geom, "%+d%+d", x, y);
+     draw_info->text = s;
+     draw_info->geometry = geom;
+     res = AnnotateImage(img, draw_info);
+     draw_info->text = draw_info->geometry = NULL;
+     if (!res)
+       return __FAIL;
+     else
+       return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,draw,argc,argv)
+ {
+   Image *img;
+   DrawInfo *draw_info;
+   char *s;
+   if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) &&
+       (draw_info = get_draw_info(img)) && isstr(argv[1], &s)) {
+     int res;
+     draw_info->primitive = s;
+     res = DrawImage(img, draw_info);
+     draw_info->primitive = NULL;
+     if (!res)
+       return __FAIL;
+     else
+       return mkvoid;
    } else
      return __FAIL;
Index: magick.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** magick.q	30 Dec 2003 20:29:58 -0000	1.26
--- magick.q	31 Dec 2003 00:22:52 -0000	1.27
***************
*** 237,240 ****
--- 237,249 ----
  public extern image_attr IMG KEY, set_image_attr IMG KEY VAL;
  
+ /* The DRAW_INFO structure of an image summarizes various properties which
+    control the rendering of graphics primitives with the draw function. It can
+    be retrieved and changed with the following operations. */
+ 
+ // TODO:
+ //public extern draw_info IMG, set_draw_info IMG INFO;
+ 
+ /***************************************************************************/
+ 
  /* Retrieve various other useful information about an image. The count_image_
     colors function determines the number of unique colors in an image. The
***************
*** 484,487 ****
--- 493,501 ----
  public extern button IMG DIM RAISE;				// BANG!
  
+ /* Drawing. */
+ 
+ public extern annotate IMG P TEXT;				// BANG!
+ public extern draw IMG CMD;					// BANG!
+ 
  /* Painting. */
  
***************
*** 491,496 ****
  public extern opaque IMG PIXEL FILL;				// BANG!
  public extern transparent IMG PIXEL OPACITY;			// BANG!
- 
- /* Drawing. */
- 
- // TODO
--- 505,506 ----
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-30 20:30:02
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick
In directory sc8-pr-cvs1:/tmp/cvs-serv16794
Modified Files:
	magick.c magick.q 
Log Message:
added painting ops
Index: magick.c
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** magick.c	30 Dec 2003 13:53:03 -0000	1.27
--- magick.c	30 Dec 2003 20:29:58 -0000	1.28
***************
*** 305,309 ****
  {
    Image *img = (Image*)ptr;
!   if (img->client_data) free(img->client_data);
    DestroyImage(img);
  }
--- 305,313 ----
  {
    Image *img = (Image*)ptr;
!   if (img->client_data) {
!     ImageData *data = (ImageData*)img->client_data;
!     if (data->draw_info) DestroyDrawInfo(data->draw_info);
!     free(img->client_data);
!   }
    DestroyImage(img);
  }
***************
*** 2381,2384 ****
--- 2385,2502 ----
      else
        return __FAIL;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,color_flood_fill,argc,argv)
+ {
+   Image *img;
+   int n;
+   expr *xv;
+   long x, y;
+   bstr_t *m1, *m2 = NULL;
+   if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) &&
+       istuple(argv[1], &n, &xv) && n == 2 &&
+       isint(xv[0], &x) && isint(xv[1], &y) &&
+       x >= 0 && x < img->columns && y >= 0 && y < img->rows &&
+       isobj(argv[2], type(ByteStr), (void**)&m1) && m1->size == 8 &&
+       (isvoid(argv[3]) ||
+        isobj(argv[3], type(ByteStr), (void**)&m2) && m2->size == 8)) {
+     int res;
+     DrawInfo *draw_info = CloneDrawInfo(NULL, NULL);
+     PixelPacket fill, target;
+     if (!draw_info) return __ERROR;
+     set_pixels(&fill, m1->v, 1, 1);
+     draw_info->fill = fill;
+     if (m2)
+       set_pixels(&target, m2->v, 1, 1);
+     else {
+       target = AcquireOnePixel(img, x, y, &exception);
+       if (check_exception(&exception)) {
+ 	DestroyDrawInfo(draw_info);
+ 	return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
+       }
+     }
+     res = ColorFloodfillImage(img, draw_info, target, x, y,
+ 			      m2?FillToBorderMethod:FloodfillMethod);
+     DestroyDrawInfo(draw_info);
+     if (!res)
+       return __FAIL;
+     else
+       return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,matte_flood_fill,argc,argv)
+ {
+   Image *img;
+   int n;
+   expr *xv;
+   long x, y;
+   unsigned long opacity;
+   bstr_t *m2 = NULL;
+   if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) &&
+       istuple(argv[1], &n, &xv) && n == 2 &&
+       isint(xv[0], &x) && isint(xv[1], &y) &&
+       x >= 0 && x < img->columns && y >= 0 && y < img->rows &&
+       isuint(argv[2], &opacity) && opacity <= 0xffff &&
+       (isvoid(argv[3]) ||
+        isobj(argv[3], type(ByteStr), (void**)&m2) && m2->size == 8)) {
+     int res;
+     PixelPacket target;
+     if (m2)
+       set_pixels(&target, m2->v, 1, 1);
+     else {
+       target = AcquireOnePixel(img, x, y, &exception);
+       if (check_exception(&exception))
+ 	return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg)));
+     }
+     res = MatteFloodfillImage(img, target, opacity, x, y,
+ 			      m2?FillToBorderMethod:FloodfillMethod);
+     if (!res)
+       return __FAIL;
+     else
+       return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,opaque,argc,argv)
+ {
+   Image *img;
+   bstr_t *m1, *m2;
+   if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) &&
+       isobj(argv[1], type(ByteStr), (void**)&m1) && m1->size == 8 &&
+       isobj(argv[2], type(ByteStr), (void**)&m2) && m2->size == 8) {
+     int res;
+     PixelPacket target, fill;
+     set_pixels(&target, m1->v, 1, 1);
+     set_pixels(&fill, m2->v, 1, 1);
+     res = OpaqueImage(img, target, fill);
+     if (!res)
+       return __FAIL;
+     else
+       return mkvoid;
+   } else
+     return __FAIL;
+ }
+ 
+ FUNCTION(magick,transparent,argc,argv)
+ {
+   Image *img;
+   bstr_t *m1;
+   unsigned long opacity;
+   if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) &&
+       isobj(argv[1], type(ByteStr), (void**)&m1) && m1->size == 8 &&
+       isuint(argv[2], &opacity) && opacity <= 0xffff) {
+     int res;
+     PixelPacket target;
+     set_pixels(&target, m1->v, 1, 1);
+     res = TransparentImage(img, target, opacity);
+     if (!res)
+       return __FAIL;
+     else
+       return mkvoid;
    } else
      return __FAIL;
Index: magick.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** magick.q	30 Dec 2003 12:00:22 -0000	1.25
--- magick.q	30 Dec 2003 20:29:58 -0000	1.26
***************
*** 484,492 ****
  public extern button IMG DIM RAISE;				// BANG!
  
! /* Annotations. */
  
! // TODO
  
! /* Drawing and painting. */
  
  // TODO
--- 484,496 ----
  public extern button IMG DIM RAISE;				// BANG!
  
! /* Painting. */
  
! public extern color_flood_fill IMG P FILL BORDER;		// BANG!
! public extern matte_flood_fill IMG P OPACITY BORDER;		// BANG!
  
! public extern opaque IMG PIXEL FILL;				// BANG!
! public extern transparent IMG PIXEL OPACITY;			// BANG!
! 
! /* Drawing. */
  
  // TODO
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-30 14:08:44
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv6779
Modified Files:
	magicktest.q 
Log Message:
fixed typo
Index: magicktest.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** magicktest.q	30 Dec 2003 14:02:12 -0000	1.8
--- magicktest.q	30 Dec 2003 14:08:41 -0000	1.9
***************
*** 152,156 ****
  
  /* slideshow IMGS SCENES: Show a slide show of the given images SCENES in the
!    given list of images IMGS, using morph to blend between the different
     images. Example:
  
--- 152,156 ----
  
  /* slideshow IMGS SCENES: Show a slide show of the given images SCENES in the
!    given list of images IMGS, using morph to crossfade between the different
     images. Example:
  
 | 
| 
     
      
      
      From: <ag...@us...> - 2003-12-30 14:02:16
      
     
   | 
Update of /cvsroot/q-lang/q/modules/magick/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv5632
Modified Files:
	magicktest.q 
Log Message:
added new example functions
Index: magicktest.q
===================================================================
RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** magicktest.q	28 Dec 2003 11:36:32 -0000	1.7
--- magicktest.q	30 Dec 2003 14:02:12 -0000	1.8
***************
*** 133,136 ****
--- 133,170 ----
  /****************************************************************************/
  
+ /* gallery IMGS SCENES: Show a thumbnail gallery of the given images SCENES (a
+    list of image indexes) in the given list of images IMGS. Example:
+ 
+    ==> def IMGS = read_image "jurannessic_176x104.mpg" ()
+ 
+    ==> gallery IMGS [20,120,160,220,420,595,650,715,760,795] */
+ 
+ gallery IMGS SCENES
+ 
+ = ifelse (islist IMG) (map display IMG) (display IMG)
+ 
+   where IMGS = map (IMGS!) SCENES, LABELS = map (sprintf "#%d") SCENES,
+     _ = zipwith (flip set_image_attr "label") IMGS LABELS,
+     IMG = montage IMGS ("Gallery","5x4","120x120",(),10,true),
+     _ = zipwith (flip set_image_attr "label") IMGS (map (cst ()) LABELS);
+ 
+ /****************************************************************************/
+ 
+ /* slideshow IMGS SCENES: Show a slide show of the given images SCENES in the
+    given list of images IMGS, using morph to blend between the different
+    images. Example:
+ 
+    ==> def IMGS = read_image "jurannessic_176x104.mpg" ()
+ 
+    ==> slideshow IMGS [795,20,120,160,220,420,595,650,715,760] */
+ 
+ slideshow IMGS SCENES
+ 
+ = animate IMGS
+ 
+   where IMGS = map (IMGS!) SCENES, IMGS = morph (append IMGS (hd IMGS)) 50;
+ 
+ /****************************************************************************/
+ 
  /* Display driver. Assume DirectX on Windows, X11 everywhere else. */
  
 |