]> git.imager.perl.org - imager.git/blob - dynfilt/dt2.c
d25de40dbbc1d7e73a1298268055ae2d514567dc
[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 channel mask (%d)\n bytes (%d)\n",im->xsize,im->ysize,im->channels,im->ch_mask,im->bytes); 
27
28   fp=fopen(fname,"ab+");
29   fprintf(fp,"<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">");
30   for(y=0;y<im->ysize;y+=2) {
31     fprintf(fp,"<TR>");
32      for(x=0;x<im->xsize;x++) {
33       i_gpix(im,x,y,&rcolor);
34       fprintf(fp,"<TD BGCOLOR=\"#%02X%02X%02X\">&nbsp;&nbsp;</TD>",rcolor.rgb.r,rcolor.rgb.g,rcolor.rgb.b);
35     }
36     fprintf(fp,"</TR>"); 
37   }
38   fprintf(fp,"</TABLE>");
39   fclose(fp);
40 }
41
42 func_ptr function_list[]={
43   {
44     "html_art",
45     html_art,
46     "callseq => ['image','fname'], \
47     callsub => sub { my %hsh=@_; DSO_call($DSO_handle,0,\\%hsh); } \
48     "
49   },
50   {NULL,NULL,NULL}};
51
52
53 /* Remember to double backslash backslashes within Double quotes in C */