home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / Background.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  2.4 KB  |  106 lines

  1. /* 
  2.  *  Background.cpp 
  3.  *
  4.  *    Copyright (C) Alberto Vigata - January 2000 - ultraflask@yahoo.com
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24.  
  25. #include "Background.h"
  26. #include "Filter.h"
  27. #include <math.h>
  28.  
  29. #define M_PI 3.141592
  30.  
  31.  
  32.  
  33. void CBackground::Start( CVideoRenderer *pVideoRenderer, CFrame *pImage )
  34. {
  35.   if( !pVideoRenderer|| !pImage )
  36.     return;
  37.  
  38.   m_pVideoRenderer = pVideoRenderer;
  39.   m_frDest = m_frImage = *pImage;
  40.  
  41.   Create();
  42. }
  43.  
  44. void CBackground::Stop()
  45. {
  46.   m_pVideoRenderer->StopPlaying();
  47.   Exit();
  48. }
  49.  
  50. DWORD CBackground::ThreadProc()
  51. {
  52.  
  53.   ui64 nCommandResult=0;
  54.   TCommand sCommand;
  55.   ui8 nSaturation = 0;
  56.   double nPhase = 0;
  57.  
  58.   // If no video renderer assigned
  59.   // end thread
  60.   if( !m_pVideoRenderer )
  61.     return 0;
  62.  
  63.   m_pVideoRenderer->StartPlaying();
  64.   
  65.  
  66.   // Adapt destination format to the one of the renderer
  67.   int w = m_frDest.GetWidth();
  68.   int h = m_frDest.GetHeight();
  69.   int format = m_pVideoRenderer->GetFormat();
  70.   //m_frDest.Set( w, h, format, format == FRAME_RGB ? 32 : 0, 0);
  71.   //m_frDest.SetFrame( &m_frImage );
  72.  
  73.  
  74.   while( 1 )
  75.   {
  76.     if(GetCommand(&sCommand))
  77.     {
  78.       switch( sCommand.nCommand )
  79.       {
  80.       case noCommand:
  81.         break;
  82.       case exit:
  83.         ReplyCommand(&sCommand, nCommandResult);
  84.         return 0;
  85.         break;
  86.       }
  87.       ReplyCommand(&sCommand, nCommandResult);
  88.     }
  89.     
  90.     nPhase += M_PI / 256.0;
  91.     nSaturation = 200*((1 + cos(nPhase))/2.0);
  92.     // Processing loop
  93.     AdjustSaturation( &m_frImage, &m_frDest, nSaturation );
  94.     
  95.     if(nSaturation!=1)
  96.       nSaturation -= 2;
  97.  
  98.  
  99.     // Draw
  100.     m_pVideoRenderer->Draw(&m_frDest);
  101.  
  102.     Sleep(20);
  103.   }
  104.  
  105.   return 0;
  106. }