File: dt2.c

package info (click to toggle)
libimager-perl 1.012%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,376 kB
  • sloc: perl: 31,562; ansic: 27,846; makefile: 53; cpp: 4
file content (54 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "pluginst.h"
#include <stdio.h>

char evalstr[]="Plugin for creating html tables from images";

/* input parameters
   fname - file to add the html to.

*/



void
html_art(void *INP) {
  i_img *im;
  i_color rcolor;
  i_img_dim x,y;
  FILE *fp;
  char *fname;

  if ( !getSTR("fname",&fname) ) { fprintf(stderr,"Error: filename is missing\n"); return; } 
  if ( !getOBJ("image","Imager::ImgRaw",&im) ) { fprintf(stderr,"Error: image is missing\n"); return; }
  
  printf("parameters: (im %p,fname %s)\n",im,fname); 

  printf("image info:\n size ("i_DFp ")\n channels (%d)\n",
	 i_DFcp(im->xsize, im->ysize), im->channels); 

  fp=fopen(fname,"ab+");
  fprintf(fp,"<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">");
  for(y=0;y<im->ysize;y+=2) {
    fprintf(fp,"<TR>");
     for(x=0;x<im->xsize;x++) {
      i_gpix(im,x,y,&rcolor);
      fprintf(fp,"<TD BGCOLOR=\"#%02X%02X%02X\">&nbsp;&nbsp;</TD>",rcolor.rgb.r,rcolor.rgb.g,rcolor.rgb.b);
    }
    fprintf(fp,"</TR>"); 
  }
  fprintf(fp,"</TABLE>");
  fclose(fp);
}

func_ptr function_list[]={
  {
    "html_art",
    html_art,
    "callseq => ['image','fname'], \
    callsub => sub { my %hsh=@_; DSO_call($DSO_handle,0,\\%hsh); } \
    "
  },
  {NULL,NULL,NULL}};


/* Remember to double backslash backslashes within Double quotes in C */