~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/fgrabber/fileio.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2 FILE_IO:fileio.c
  3 
  4 File I/O stuff
  5 
  6 Author: A.J.Lacey
  7 Date: 25-1-93; version 1.0
  8       15.1.96; version 2.0
  9 
 10 */
 11 
 12 #include <stdio.h>
 13 #include <tina/sys.h>
 14 #include <tina/file.h>
 15 #include <tina/sysfuncs.h>
 16 #include <tina/grabdefs.h>
 17 #include <tina/grabsrv.h>
 18 
 19 
 20 
 21 void            aiff_fdump(Imrect *ptr, char *fname)
 22 {
 23     aiff_write_image(ptr,fname);        
 24 }   
 25 
 26 
 27 
 28 int             file_dump(Grabber *info, char *fname)
 29 {
 30         FILE    *fp;
 31         int      im_size, j;
 32 
 33         im_size = info->width * info->length;
 34  
 35         if ((fp = fopen(fname, "w")) == NULL)
 36                 return (-1);
 37 
 38         fprintf(fp, info->header);
 39         for(j = 0; j < im_size; j++)
 40         {
 41                 if (info->format == MAGIK)
 42                 {
 43                         fputc(info->im_buffer[j], fp);
 44                         fputc(info->im_buffer[j], fp);
 45                 }
 46 
 47                 fputc(info->im_buffer[j], fp);
 48         }
 49 
 50         fclose(fp);
 51         return (0);
 52 }
 53 
 54 
 55 
 56 
 57 
 58 int             file_format(Grabber *params, Imrect *imptr, int current, int n)
 59 {
 60 
 61         FILE    *fp;
 62         int      i, ferr = 0;
 63         char     name[512];
 64         char     temp[512]; 
 65 
 66         if (params->st_pair == MONO_GRAB)
 67         {
 68                 if (params->number > 1 )
 69                 {
 70                         sprintf(temp,"%s%s", params->filename, "_");
 71                         if (current < 10)
 72                                 sprintf(name, "%s%s%d", temp, "00", current);   
 73                         else
 74                         if (current < 100)
 75                                 sprintf(name, "%s%s%d", temp, "", current);
 76                         else
 77                                 sprintf(name, "%s%d", temp, current);
 78                 }
 79 
 80                 else
 81                         sprintf(name, "%s", params->filename);
 82         }
 83 
 84         if (params->st_pair == STEREO_GRAB)
 85         {
 86                 if (n == LEFT_IM)
 87                         sprintf(name, "%s.l", params->filename);
 88 
 89                 if (n == RIGHT_IM) 
 90                         sprintf(name, "%s.r", params->filename);
 91 
 92         }
 93 
 94 
 95         switch(params->format)
 96         {
 97                 case AIFF:
 98                         sprintf(temp, "%s%s", name, ".aiff");
 99                         aiff_fdump(imptr, temp);
100                         break;
101 
102                 case PGM:
103                         sprintf(temp, "%s%s", name, ".pgm");
104                         sprintf(params->header,"P5\n%d %d\n255\n",params->width, params->length);
105                         ferr = file_dump(params, temp);
106                         break;
107 
108                 case MAGIK:
109                         sprintf(temp, "%s%s", name, ".mgk");
110                         sprintf(params->header,"id=ImageMagick\nclass=DirectClass\ncolumns=%d\nrows=%d\nscene=%d\n:",
111                                         params->width, (params->length - 1), (current + 1));
112                         ferr = file_dump(params, temp);
113                         break;
114 
115                 case RAW:
116                         sprintf(temp, "%s%s", name, ".raw");
117                         sprintf(params->header, "");
118                         ferr = file_dump(params, temp);
119                         break;
120 
121                 default:
122                         file_dump(params, name);
123                         break;
124            }
125 
126         return (ferr);
127 
128 }
129 
130 
131 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.