Debian Codegraph @

dynfilt/dt2.c

raw
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 i_img_dim 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 %p,fname %s)\n",im,fname);
25
26 printf("image info:\n size ("i_DFp ")\n channels (%d)\n",
27 i_DFcp(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 */