| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #include "Video.h"
- #include "stdio.h"
- Video::Video()
- : m_width( 0 ),
- m_height( 0 ),
- m_resX( 1.0 ),
- m_resY( 1.0 )
- {
- }
- Video::~Video()
- {
- Clear();
- }
- unsigned long Video::GetWidth()
- {
- return m_width;
- }
- unsigned long Video::GetHeight()
- {
- return m_height;
- }
- void Video::SetSize( unsigned long width, unsigned long height )
- {
- m_width = width;
- m_height = height;
- }
- void Video::SetResolution( double resX, double resY )
- {
- m_resX = resX;
- m_resY = resY;
- }
- ExtendedImage* Video::GetFrame( unsigned int i )
- {
- if ( i < m_frames.size() )
- {
- return m_frames[ i ];
- }
- return NULL;
- }
- char* Video::GetFrameBitmap( unsigned int i )
- {
- if ( i < m_frames.size() )
- {
- return m_frames[ i ]->GetBuffer();
- }
- return NULL;
- }
- unsigned int Video::GetFrameCount()
- {
- return (unsigned int)m_frames.size();
- }
- void Video::AddFrame( unsigned char* data, bool isMonochrome )
- {
- if ( data )
- {
- ExtendedImage* image = new ExtendedImage;
- if ( image )
- {
- if ( image->Create( m_width, m_height, 24 ) )
- {
- unsigned char* l = (unsigned char*)image->GetBuffer();
- int n = m_width * m_height;
-
- if ( isMonochrome )
- {
- while ( n-- )
- {
- *l++ = *data;
- *l++ = *data;
- *l++ = *data++;
- }
- }
- else
- {
- while ( n-- )
- {
- *l++ = *( data + 2 );
- *l++ = *( data + 1 );
- *l++ = *data;
- data += 3;
- }
- }
-
- m_frames.push_back( image );
- }
- }
- }
- }
- void Video::EraseFirstFrame()
- {
- m_frames.erase( m_frames.begin() );
- }
- bool Video::IsNull()
- {
- return ( m_frames.size() == 0 ) ? true : false;
- }
- void Video::Clear()
- {
- std::vector< ExtendedImage* >::iterator
- f = m_frames.begin(),
- fe = m_frames.end();
- while ( f != fe )
- {
- if ( !(*f)->IsNull() )
- {
- (*f)->Destroy();
- }
- delete *f;
- ++f;
- }
- m_frames.clear();
- }
|