]> git.imager.perl.org - imager.git/blob - dynfilt/dt2.c
the PERL_INITIALIZE_IMAGER_PERL_CALLBACKS was checking the wrong version number
[imager.git] / dynfilt / dt2.c
1 #include "pluginst.h"
2 #include <stdio.h>
3
4 char evalstr[]="Plugin for creating html tables from images";
5
6 /* input parameters
7    fname - file to add the html to.
8
9 */
10
11
12
13 void
14 html_art(void *INP) {
15   i_img *im;
16   i_color rcolor;
17   int x,y;
18   FILE *fp;
19   char *fname;
20
21   if ( !getSTR("fname",&fname) ) { fprintf(stderr,"Error: filename is missing\n"); return; } 
22   if ( !getOBJ("image","Imager::ImgRaw",&im) ) { fprintf(stderr,"Error: image is missing\n"); return; }
23   
24   printf("parameters: (im 0x%p,fname %s)\n",im,fname); 
25
26   printf("image info:\n size (%d,%d)\n channels (%d)\n",
27          im->xsize,im->ysize,im->channels); 
28
29   fp=fopen(fname,"ab+");
30   fprintf(fp,"<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">");
31   for(y=0;y<im->ysize;y+=2) {
32     fprintf(fp,"<TR>");
33      for(x=0;x<im->xsize;x++) {
34       i_gpix(im,x,y,&rcolor);
35       fprintf(fp,"<TD BGCOLOR=\"#%02X%02X%02X\">&nbsp;&nbsp;</TD>",rcolor.rgb.r,rcolor.rgb.g,rcolor.rgb.b);
36     }
37     fprintf(fp,"</TR>"); 
38   }
39   fprintf(fp,"</TABLE>");
40   fclose(fp);
41 }
42
43 func_ptr function_list[]={
44   {
45     "html_art",
46     html_art,
47     "callseq => ['image','fname'], \
48     callsub => sub { my %hsh=@_; DSO_call($DSO_handle,0,\\%hsh); } \
49     "
50   },
51   {NULL,NULL,NULL}};
52
53
54 /* Remember to double backslash backslashes within Double quotes in C */