示例#1
0
文件: LibUnix.c 项目: scygan/EmuTI
int ShowVideo(void)
{
  Image *Output;
  int SX,SY;

  /* Must have active video image, X11 display */
  if(!VideoImg||!VideoImg->Data) return(0);

  /* Allocate image buffer if none */
  //if(!OutImg.Data&&!NewImage(&OutImg,XSize,YSize)) return(0);

  /* If not scaling or post-processing image, avoid extra work */
  if(!(Effects&(EFF_SOFTEN|EFF_SCALE|EFF_TVLINES)))
  {
	FlipImage(VideoImg);
    return(1);
  }

  /* By default, we will be showing OutImg */
  Output  = &OutImg;
  SX      = 0;
  SY      = 0;

  if(Effects&EFF_SOFTEN)
  {
    /* Apply softening */
    SoftenImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH);
    /* Apply TV scanlines, if needed */
    if(Effects&EFF_TVLINES)
      TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H);
  }
  else if(Effects&EFF_TVLINES)
  {
    if(Effects&EFF_SCALE)
    {
      /* Scale VideoImg into OutImg */
      ScaleImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH);
      /* Apply TV scanlines */
      TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H);
    }
    else
    {
      /* Center VideoImg in OutImg */
      IMGCopy(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoImg,VideoX,VideoY,VideoW,VideoH,-1);
      /* Apply TV scanlines */
      TelevizeImage(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoW,VideoH);
    }
  }
  else if((OutImg.W==VideoW)&&(OutImg.H==VideoH))
示例#2
0
int ShowVideo(void)
{
  Image *Output;
  int SX,SY;

  /* Must have active video image, X11 display */
  if(!VideoImg||!VideoImg->Data) return(0);

  /* Allocate image buffer if none */
  if(!OutImg.Data&&!NewImage(&OutImg,XSize,YSize)) return(0);

  /* Count framerate */
  if((Effects&EFF_SHOWFPS)&&(++FrameCount>=120))
  {
    struct timeval NewTS;
    int Time;

    gettimeofday(&NewTS,0);
    Time       = (NewTS.tv_sec-TimeStamp.tv_sec)*1000
               + (NewTS.tv_usec-TimeStamp.tv_usec)/1000;
    FrameRate  = 1000*FrameCount/(Time>0? Time:1);
    TimeStamp  = NewTS;
    FrameCount = 0;
    FrameRate  = FrameRate>999? 999:FrameRate;
  }

  /* If not scaling or post-processing image, avoid extra work */
  if(!(Effects&(EFF_SOFTEN|EFF_SCALE|EFF_TVLINES)))
  {
		/* Show framerate if requested */
		if((Effects&EFF_SHOWFPS)&&(FrameRate>0))
		{
			char S[8];
			sprintf(S,"%02dfps",FrameRate);
			PrintXY(VideoImg,S,
					8,8,
					FPS_COLOR,PIXEL(255,255,255)
					);
		}
		screen_buffer_t screen_buf[1];
		screen_get_window_property_pv(window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)screen_buf);

		int bg[] = { SCREEN_BLIT_END };
		screen_blit(ctxt, screen_buf[0], VideoImg->pbuf, bg);
		screen_post_window(window, screen_buf[0], 1, rect, 0);
		return 1;
  }

  /* By default, we will be showing OutImg */
  Output  = &OutImg;
  SX      = 0;
  SY      = 0;

  if(Effects&EFF_SOFTEN)
  {
    /* Apply softening */
    SoftenImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH);
    /* Apply TV scanlines, if needed */
    if(Effects&EFF_TVLINES)
      TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H);
  }
  else if(Effects&EFF_TVLINES)
  {
    if(Effects&EFF_SCALE)
    {
      /* Scale VideoImg into OutImg */
      ScaleImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH);
      /* Apply TV scanlines */
      TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H);
    }
    else
    {
      /* Center VideoImg in OutImg */
      IMGCopy(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoImg,VideoX,VideoY,VideoW,VideoH,-1);
      /* Apply TV scanlines */
      TelevizeImage(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoW,VideoH);
    }
  }
  else if((OutImg.W==VideoW)&&(OutImg.H==VideoH))