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

Linux Cross Reference
Tina4/src/tools/sequence/seq_get_seq.c

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

  1 /*
  2   seq_get_seq.c
  3 
  4   Functions for reading in a sequnce of images into tina and initialising 
  5   everything
  6 
  7   author: a.lacey
  8   date  : 8-2-93; 25-1-94 version 1.0
  9           4.12.95         version 2.0
 10 
 11   
 12 */
 13 
 14 #include <stdio.h>
 15 #include <fcntl.h>
 16 #include <tina/sys.h>
 17 #include <tina/sysfuncs.h>
 18 #include <tina/math.h>
 19 #include <tina/mathfuncs.h>
 20 #include <tina/vision.h>
 21 #include <tina/visionfuncs.h>
 22 #include <tina/tv.h>
 23 #include <tina/file.h>
 24 #include <tina/filefuncs.h>
 25 #include <tina/image.h>
 26 #include <tina/seqdefs.h>
 27 #include <tina/seqoral.h>
 28 #include <tina/seqpro.h>
 29 
 30 
 31 static char     filename[512];
 32 static char     temp[512];
 33 
 34 
 35 
 36 int        read_seq(Sequence *seq)
 37 {
 38 
 39   Imrect  *im;
 40   int      i;
 41 
 42   strcpy(filename, "");
 43   strcpy(temp,"");
 44 
 45   for(i = (seq->number - 1); i >= 0; i--)
 46     {
 47       sprintf(filename,"%s%s", seq->filename, "_");
 48       if (i < 10)
 49         sprintf(temp, "%s%s%d", filename, "00", i );      
 50       else
 51         if (i < 100)
 52           sprintf(temp, "%s%s%d", filename, "", i);
 53         else
 54           sprintf(temp, "%s%d", filename, i);
 55 
 56       sprintf(filename, "%s%s", temp, ".aiff");
 57 
 58       if ((im = (Imrect *)aiff_read_image(filename)) == NULL)
 59         return (-1);
 60 
 61       set_frame_no(im, i);
 62       frame_insert(im, seq);
 63     }
 64 
 65   return (0);
 66 }
 67 
 68 
 69 
 70 void      write_seq(Sequence *params)
 71 {
 72 
 73   List   *store = get_start_el();
 74   int       i;
 75 
 76   if (store == NULL)
 77     {
 78       sprintf(temp, " nothing to save in %s", params->filename);
 79       error(temp, warning);
 80       return;
 81     }
 82 
 83   for(i = 0; i < params->number; i++)
 84     {
 85       sprintf(filename,"%s%s", params->filename, "_");
 86       if (i < 10)
 87         sprintf(temp, "%s%s%d", filename, "00", i );      
 88       else
 89         if (i < 100)
 90           sprintf(temp, "%s%s%d", filename, "", i);
 91         else
 92           sprintf(temp, "%s%d", filename, i);
 93 
 94       sprintf(filename, "%s%s", temp, ".aiff");
 95 
 96       if ((store == NULL) || (store->to == NULL))
 97         {
 98           sprintf(temp, " no data for %s, aborting", filename);
 99           error(temp, warning);
100           return;
101         }
102                 
103       aiff_write_image(store->to, filename);
104       store = store->next;
105     }
106 
107   return;               
108 }
109 
110 
111 
112 int       check_files_exist(Sequence *data)
113 {
114 
115   FILE   *fp;
116   int     i, prob = 0;
117 
118   for (i = 0; i < data->number; i++)
119     {
120       strcpy(filename, "");
121       strcpy(temp, "");
122 
123       sprintf(filename,"%s%s", data->filename, "_");
124       if (i < 10)
125         sprintf(temp, "%s%s%d", filename, "00", i );      
126       else
127         {
128           if (i < 100)
129             sprintf(temp, "%s%s%d", filename, "", i);
130           else
131             sprintf(temp, "%s%d", filename, i);
132         }
133 
134       sprintf(filename, "%s%s", temp, ".aiff");
135 
136 
137       if ((fp = fopen(filename, "r")) == NULL)
138         {
139                         
140           if ( i == 0)
141             {
142               sprintf(temp, " %s sequence doesn't exist", data->filename);
143               error(temp, warning);
144               error(" nothing loaded", warning);
145               return (-1);
146             }
147                         
148           else
149             {
150               sprintf(temp, " %s element %d missing", data->filename, i);
151               error(temp, warning);
152               prob = 1;
153             }
154         }
155         
156       fclose (fp);
157     }
158 
159   if (prob)
160     {
161       error(" nothing loaded", warning);
162       return (-1);
163     }
164 
165   return (0);
166 }
167 
168 
169 
170 
171 void      get_image_seq(Sequence *data)
172 {
173 
174   List  *lptr = get_start_el();
175 
176   data->type = SEQ;
177 
178   if (check_files_exist(data) == -1)
179     return;
180 
181   if (lptr != NULL)
182     dd_list_rm(lptr, im_free);
183 
184   set_current_el(NULL);
185   set_start_el(NULL);
186   set_end_el(NULL);
187         
188   if (read_seq(data) == -1)
189     return;
190 
191   return;
192 }
193 
194 

~ [ 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.