Esempio n. 1
0
void next_frame(void *data)
/* Jump to next frame of temp file, wrapping back to 1st frame if go past
   end... */
{
	int oix;
	int undoix;
	(void)data;

	if (flix.xf == NULL)
		return;

	flx_clear_olays();
	oix = vs.frame_ix;
	undoix = scrub_cur_frame()-1;
	++vs.frame_ix;
	check_loop();
	if(undoix != vs.frame_ix)
	{
		if (unfli(vb.pencel,vs.frame_ix,1) < 0)
			vs.frame_ix = oix;
		zoom_it();
		save_undo();
	}
	else
	{
		zoom_unundo(); /* undo has next frame left in it by sub_cur_frame() */
	}
	flx_draw_olays();
}
Esempio n. 2
0
static Errcode do_gotlast_ringit(void *cbuf)
{
Errcode err;

	/* last frame in pencel put first in undo */
	if((err = unfli(undof, 0, 0)) < Success)
		return(err);
	err = write_ring_flxframe(NULL,&flix,cbuf,vb.pencel,undof);
	return err;
}
Esempio n. 3
0
void first_frame(void *data)
/* Jump to first frame of temp file */
{
	(void)data;

	if (flix.xf == NULL)
		return;

	flx_clear_olays();
	scrub_cur_frame();
	if(unfli(undof,0,1) >= 0)
		vs.frame_ix = 0;
	zoom_unundo();
	flx_draw_olays();
}
Esempio n. 4
0
static Errcode load_fli(char *title)
/* Convert a FLI file into an indexed frame (FLX) file - into our 
   main temp file in fact.  Make first frame visible.  On failure
   generate an empty FLX file */
{
Errcode err;

	vs.frame_ix = 0;
	if((err = make_tempflx(title,1)) < 0)
		goto OUT;
	if((err = unfli(vb.pencel,0,1)) < 0)
		goto OUT;
	save_undo();
OUT:
	if(err < 0)
		kill_seq();
	zoom_it();
	return(err);
}
Esempio n. 5
0
static Errcode vp_playit(LONG frames)
/* Ya, go play dem frames.  Replay temp file */
{
	Errcode err;
	ULONG clock;

	flx_clear_olays(); /* undraw cels cursors etc */
	if (flix.xf != NULL) {
		clock = pj_clock_1000();
		hide_mouse();
		for (;;)
		{
			if (frames == 0)
				{
				err = Success;
				break;
				}
			--frames;
			clock += flix.hdr.speed;
			if ((err = wait_til(clock)) != Err_timeout)
				break;
			if (clock > pj_clock_1000()) /* wrap */
				clock = pj_clock_1000();
			vs.frame_ix++;
			if (vs.frame_ix > flix.hdr.frame_count)
				vs.frame_ix = 1;
			if((err = unfli(vb.pencel,vs.frame_ix,1)) < 0)
				break;
			zoom_it();
		}
		show_mouse();
	}
	check_loop();	/* to go frame frame_count to 0 sometimes... */
	flx_draw_olays(); /* undraw cels cursors etc */
return(err);
}
Esempio n. 6
0
int main (int argc, char *argv[])
{
  FILE *fopen(), *fpin;
  char *infile, *outbase, *outext, *filter;
  char *ppa, *ppb;
  char **pending_name;
  int *pending_number;
  int i, r;
  int verbose_flag;
  int begin_frame,max_frames;
  int pp_flag;
  int outtype;

  infile = NULL;
  outbase = NULL;
  outext = NULL;
  verbose_flag = 0;
  filter = NULL;
  begin_frame=1;
  max_frames=-1;
  outtype = PPM_RAW;

  /* scan arguments */

  pp_flag = 0;
  pending_number = NULL;
  pending_name = NULL;
  ppa = ppb = NULL;

  if (argc == 1)
    { print_usage(); exit(1); }

  for (i=1; i < argc; i++)
    {
      ppa=argv[i];
      if (pp_flag == 1)
        { SCANINT(ppa, pending_number); pp_flag = 0; }
      else if (pp_flag == 2)
        { *pending_name = ppa; pp_flag = 0; }
      else if (*ppa == '-')
	{
	  ppb = (ppa++);
	  switch (*ppa)
	    {
	    case 'b':   GETNUMBER(begin_frame); break;
	    case 'n':   GETNUMBER(max_frames); break;
	    case 'a':   outtype = PPM_ASCII; break;
	    case 'm':   outtype = FBM_MAPPED; break;
	    case 'f':   GETNAME(filter); break;
	    case 'v':   verbose_flag = 1; break;
	    case 'h':   print_usage(); print_help(); exit(1);
	    default:
	      fprintf(stderr,"Illegal option '%c' in argument %d\n",
		      *ppa,i);
	      print_hint();
	      exit(1);
	    }
	}
      else  if (infile == NULL)
	{
	  infile=argv[i];
	}
      else if (outbase == NULL)
	{
	  outbase=argv[i];
	}
      else if (outext == NULL)
	{
	  outext=argv[i];
	}
      else
	{
	  fprintf(stderr,"Too many parameters specified\n");
	  print_hint();
	  exit(1);
	}
    }

  if (pp_flag == 1)
    {
      fprintf(stderr,"Missing number behind option '%c'\n",*ppb);
      print_hint();
      exit(1);
    }

  if (outbase == NULL)
    {
      print_usage();
      exit(1);
    }

  /* fprintf(stderr,"Open Input File\n"); */
  if ((fpin = fopen(infile, "rb")) == NULL)
    {
      fprintf(stderr,"Error opening input file '%s'\n",infile);
      exit(1);
    }

  r = unfli(fpin,outbase,outext,outtype,
	    begin_frame,max_frames,verbose_flag,filter);

  if (r == 0)
    fprintf(stderr,"Stop\n");
  else if (r == 1)
    fprintf(stderr,"Ready\n");
  else if (r == -1)
    fprintf(stderr,"Read error\n");
  else if (r == -2)
    fprintf(stderr,"Error allocating memory\n");
  else
    fprintf(stderr,"Unknown error\n");

  fclose(fpin);

  return(0);
}
Esempio n. 7
0
Errcode resize_load_fli(char *flicname)
/* Make sure that a file-name refers to an existing FLI file 
 * or a valid pic format.
 * attempt reset of current fli window environment to 
 * the new image size. and attempt to load the images.
 * if a failure in resizing or loading you will end up with an
 * empty fli and an error reported */
{
Errcode err;
Anim_info ainfo;
char pdr_name[PATH_SIZE];

	hide_mp();

	if((err = find_pdr_loader(flicname, TRUE, &ainfo, 
							  pdr_name,vb.pencel)) < Success)
	{
		goto reshow_out; 
	}

	unzoom();
	push_most();
	close_tflx();

	if((err = set_penwndo_size(ainfo.width,ainfo.height)) < Success)
	{
		err = flisize_error(err,ainfo.width,ainfo.height);
		empty_tempflx(1);
		goto error;
	}
	else
	{
		if(is_fli_pdr_name(pdr_name))
		{
			err = load_fli(flicname);
			goto done;
		}

		if(ainfo.num_frames == 1)
		{
			empty_tempflx(1);
			if((err = pdr_load_picture(pdr_name,flicname,vb.pencel)) < Success)
			{
				goto error;
			}
			dirties();
			goto done;
		}
		/* try to load animation file using pdr */

		if(!soft_yes_no_box("!%d%s", "fliload_slow",
						    ainfo.num_frames, flicname ))
		{
			err = Err_abort;
			goto error;
		}

		vs.frame_ix = 0;
		if((err = make_pdr_tempflx(pdr_name,flicname,&ainfo)) >= Success
		     || err == Err_abort)
		{
			if((err = unfli(vb.pencel,0,1)) >= Success)
			{
				goto done;
			}
		}
		kill_seq();
		goto error;	
	}

done:
error:
	pop_most();
	rezoom();
reshow_out:
	show_mp();
	vs.bframe_ix = 0; /* back frame buffer no good now */
	return(softerr(err,"!%s", "fli_load", flicname));
}
Esempio n. 8
0
static int load_fli_overlay(char *title, int how)

/* returns ecode if can't do. This reports errors.*/
{
Errcode err;
Rcel *loadcel = NULL;
Cmap *cmap = NULL;
int usr_fit = 0; /* start off not knowing how to fit colors */
Flifile flif;
int i = 0;
int fit_option;
int fcount;
Vabortdat vd;
Boolean overlay_fit;

	clear_struct(&flif);

	vd.totframes = &flif.hdr.frame_count;
	vd.frame = &i;
	set_abort_verify(olay_abort_verify,&vd);

	if((err = save_pic(screen_name, vb.pencel,0,TRUE)) < 0)
		goto error;

	if((err = pj_fli_open(title,&flif,JREADONLY)) < 0)
		goto error;

	/* allocate fli size cel to hold fli frame(s) */
	if((err = valloc_ramcel(&loadcel,flif.hdr.width,flif.hdr.height)) < 0)
		goto error;
	if((err = pj_cmap_alloc(&cmap,COLORS)) < Success)
		goto error;
	if((err = pj_fli_seek_first(&flif)) < 0)
		goto error;

	for (i=0; i<flif.hdr.frame_count; i++)
	{
		if (i != 0 && vs.frame_ix == 0)
		{
			if (soft_qchoice(NULL, "comp_past") != 0)
				goto aborted;
		}
		if ((err = pj_fli_read_next(title,&flif,loadcel,0)) < 0)
			goto error;
		if (!cmaps_same(loadcel->cmap, vb.pencel->cmap))
		{
			if (!usr_fit)
			{
				if((usr_fit = 1 + soft_qchoice(NULL, "comp_cmap")) <= 0)
					goto aborted;
			}
			fit_option = usr_fit;
		}
		else
			fit_option = 0;

		/* switch to get the color map into cmap */
		switch (fit_option)
		{
			case 0:	/* both are same.  yea! */
			case 2:	/* keep current */
			case 4:	/* No Fit */
				pj_cmap_copy(vb.pencel->cmap,cmap);
				break;
			case 3: /*use overlay cmap */
				pj_cmap_copy(loadcel->cmap, cmap);
				goto do_screen_cfit;
			case 1: /* compromise cmap */
				compromise_cmap(vb.pencel->cmap, loadcel->cmap, cmap);
			do_screen_cfit:
				cfit_rcel(vb.pencel,cmap);
				pj_cmap_copy(cmap,vb.pencel->cmap);
				see_cmap();
				break;
		}

		if (i == 0)  /* let user position first frame */
		{
			save_undo();
			switch (fit_option)	/* figure out whether to fit cel to display
								 * for user to position. */
				{
				case 0:	/* both are same.  yea! */
				case 3: /*use overlay cmap */
				case 4:	/* No Fit */
					overlay_fit = FALSE;
					break;
				case 1: /* compromise cmap */
				case 2:	/* keep current */
					overlay_fit = TRUE;
					break;
				}
			move_rcel(loadcel,overlay_fit,FALSE);

			if(!soft_yes_no_box("olay_start"))
			{
				load_pic(screen_name, vb.pencel, 0, TRUE);
				goto aborted;
			}
			/* we're committed now */
			pj_delete(screen_name);
			dirties();
		}
		switch (how)
		{
			case 0:	 /* over/under */
				if(i != 0)
					save_undo();
				if((err = may_cfit_blit_cel(loadcel, fit_option)) < 0)
					goto error;
				break;
			case  2: /* crossfade */
				if ((fcount = flif.hdr.frame_count-1) == 0)
					fcount = 1;
				pj_rcel_copy(vb.pencel, undof);
				if((err = transpblit(loadcel, 0, FALSE, 
					(i*(long)100+flif.hdr.frame_count/2)/fcount)) < Success)
				{
					goto error;
				}
				break;
		}
		if((err = sub_cur_frame()) < Success)
			goto error;
		if(poll_abort() < Success)
			goto aborted;
		vs.frame_ix++;
		check_loop();
		if((err = unfli(vb.pencel,vs.frame_ix,1)) < 0)
			goto error;
	}
	err = 0;
	goto OUT;

aborted:
	err = Err_abort;
error:
	err = softerr(err,"!%s", "comp_load", title);
OUT:
	pj_cmap_free(cmap);
	pj_rcel_free(loadcel);
	pj_fli_close(&flif);
	set_abort_verify(NULL);
	return(err);
}