Esempio n. 1
0
BOOL CVideoDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		pSysMenu->AppendMenu(MF_STRING, IDM_ENABLECOMPRESS, "视频压缩(&C)");
		pSysMenu->AppendMenu(MF_STRING, IDM_SAVEAVI, "保存录像(&V)");
		pSysMenu->AppendMenu(MF_SEPARATOR);	
	
		CString str;
	
		str.Format("\\\\%s %d * %d", m_IPAddress, m_lpbmi->bmiHeader.biWidth, m_lpbmi->bmiHeader.biHeight);
	
		SetWindowText(str);


	
		InitMMI();

	
		m_hDD = DrawDibOpen();
	
		m_hDC = ::GetDC(m_hWnd);


		BYTE bToken = COMMAND_NEXT;
	
		m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
	}
	
		return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
Esempio n. 2
0
VideoComponent::VideoComponent(GameEntity* owner) : GameComponent(owner, "VideoComponent"), m_startTime(0), m_data(0x0), m_playing(false), 
	m_material(0), m_resize(false), m_bgraData(0x0), m_pgf(0x0), m_videoTexture(0), m_samplerIndex(-1), m_originalSampler(0), 
	m_autoStart(false), m_loop(false), m_startNextFrame(false), m_newData(false), m_hasAudio(false), m_camId(0)
{
	VideoManager::instance()->addComponent(this);
	// We need our own access to the com library for not disturbing others (like the SapiComponent)
	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	// Listen to cam changes
	owner->addListener(GameEvent::E_ACTIVE_CAM_CHANGE, this);
	// And get the current one
	// First the GameEngine id
	int camID = 0;
	GameEvent camEvent(GameEvent::E_GET_ACTIVE_CAM, &GameEventData(&camID), this);
	GameModules::gameWorld()->executeEvent(&camEvent);
	// Then the entity
	GameEntity* camEntity = GameModules::gameWorld()->entity(camID);
	if (camEntity)
	{
		// And finally the horde id, puh!
		GameEvent getHordeID(GameEvent::E_GET_SCENEGRAPH_ID, &m_camId, this);
		camEntity->executeEvent(&getHordeID);
	}

	m_hdd = DrawDibOpen();
	m_hdc = CreateCompatibleDC(0);
}
Esempio n. 3
0
File: AVI.cpp Progetto: DCubix/1.4.0
bool CAvi::Load( LPCWSTR szFile )
{
	m_data = NULL;
	m_hDC = CreateCompatibleDC(0);
	if( !m_hDC )
	{ 
		MessageBox( NULL, _T("Couldn't find the device context to play the CAvi file."), _T("VandaEngine Error"), MB_OK | MB_ICONERROR );
		return 0;
	}
	m_hdd = DrawDibOpen();
	if( !m_hdd )
	{
		MessageBox( NULL, _T("Couldn't find HDD to initialize CAvi file."), _T("VandaEngine Error"), MB_OK | MB_ICONERROR );
		return 0;
	}
    if( !OpenAVI( szFile ) ) 
		return 0;

	glGenTextures( 1, &m_textureId );
	glBindTexture( GL_TEXTURE_2D, m_textureId ); 

	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
	glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 1024, 512, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, m_data );
	m_loaded = true;
	return 1;
}
Esempio n. 4
0
// This basically allocates our "instance info" (that struct defined
// at the beginning of this file).
static LONG NEAR PASCAL AVIDrawOpen(ICOPEN FAR * icopen)
{
	PINSTINFO pinst;

	if (icopen->fccType != streamtypeVIDEO)
	{
		return 0;
	}
	if (icopen->dwFlags == ICMODE_COMPRESS)
	{
		return 0;
	}
	if (icopen->dwFlags == ICMODE_DECOMPRESS)
	{
		return 0;
	}
	pinst = (PINSTINFO)GlobalAllocPtr(GHND, sizeof(INSTINFO));
	if (!pinst)
	{
		icopen->dwError = ICERR_MEMORY;
		return NULL;
	}
	pinst->hdd = DrawDibOpen();
	pinst->hddb = NULL;
	icopen->dwError = ICERR_OK;
	return (LONG) pinst;
}
Esempio n. 5
0
bool AVI :: Load(std :: string fname,bool loopflag,Texture *tex)				// Opens An AVI File
{
	// copy over looping flag
	loop=loopflag;

	// do we have a texture manager?
	if(!tex)
		return false;
	// copy it over
	tman=tex;

	hdc=CreateCompatibleDC(0);									// Get a compatible DC
	hdd = DrawDibOpen();										// Grab A Device Context For Our Dib


	AVIFileInit();												// Opens The AVIFile Library

	// Opens The AVI Stream
	if (AVIStreamOpenFromFile(&pavi, fname.c_str(), streamtypeVIDEO, 0, OF_READ, NULL) !=0)
		return false;

	AVIStreamInfo(pavi, &psi, sizeof(psi));						// Reads Information About The Stream Into psi
	width=psi.rcFrame.right-psi.rcFrame.left;					// Width Is Right Side Of Frame Minus Left
	height=psi.rcFrame.bottom-psi.rcFrame.top;					// Height Is Bottom Of Frame Minus Top

	lastframe=AVIStreamLength(pavi);							// The Last Frame Of The Stream

	mpf=AVIStreamSampleToTime(pavi,lastframe)/lastframe;		// Calculate Rough Milliseconds Per Frame

	bmih.biSize = sizeof (BITMAPINFOHEADER);					// Size Of The BitmapInfoHeader
	bmih.biPlanes = 1;											// Bitplanes	
	bmih.biBitCount = 24;										// Bits Format We Want (24 Bit, 3 Bytes)
	bmih.biWidth = 256;											// Width We Want (256 Pixels)
	bmih.biHeight = 256;										// Height We Want (256 Pixels)
	bmih.biCompression = BI_RGB;								// Requested Mode = RGB

	hBitmap = CreateDIBSection (hdc, (BITMAPINFO*)(&bmih), DIB_RGB_COLORS, (void**)(&data), NULL, NULL);
	SelectObject (hdc, hBitmap);								// Select hBitmap Into Our Device Context (hdc)

	pgf=AVIStreamGetFrameOpen(pavi, NULL);						// Create The PGETFRAME	Using Our Request Mode
	if (pgf==NULL)
		return false;

	// create the texture
	Image img;
	img.Create(256,256,false);									// set dimensions of texture
	img.SetImage(data);											// set the texture information
	texid=tman->Create(&img);									// create the texture

	// clear the time position 
	pos=0;

	// success
	return true;
}
Esempio n. 6
0
HWND AVIOBJ::create_AVI_Window(int left,int right, int top, int bottom,HGLRC * GLRC)
{
    HWND Wnd;
    char temp[50];
    HDC hDC;
    HGLRC m_hRC;
    PIXELFORMATDESCRIPTOR pfd;
    int nPixelFormat;

    wsprintf(temp, "Avi - Movie");
    if (!(Wnd= CreateWindow( "AVIClass", temp, WS_CLIPSIBLINGS| WS_CHILD | WS_CAPTION | WS_THICKFRAME | WS_VISIBLE , left, top,right-left,bottom-top, ghWndMain, NULL, hInst, NULL)))
    {   report_error("Can't Create AVI Window");
        return(0);
    }

    memset(&pfd, 0, sizeof(pfd));
    pfd.nSize      = sizeof(pfd);
    pfd.nVersion   = 1;
    pfd.dwFlags    = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 24;
    pfd.cDepthBits = 16;
    pfd.iLayerType = PFD_MAIN_PLANE;


    // Set pixel format

    hDC = GetDC(Wnd);
    nPixelFormat = ChoosePixelFormat(hDC, &pfd);
    SetPixelFormat(hDC, nPixelFormat, &pfd);

    m_hRC = wglCreateContext(hDC);
    wglMakeCurrent(hDC, m_hRC);
    hdc = hDC;
    hdd = DrawDibOpen();										// Grab A Device Context For Our Dib
    glClearColor (0.0f, 0.0f, 0.0f, 0.5f);						// Black Background
    // Select Smooth Shading
    glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			// Set Perspective Calculations To Most Accurate


    glViewport (0, 0, (GLsizei)(width), (GLsizei)(height));				// Reset The Current Viewport
    glMatrixMode (GL_PROJECTION);										// Select The Projection Matrix
    glLoadIdentity ();													// Reset The Projection Matrix
    gluPerspective (45.0f, (GLfloat)(width)/(GLfloat)(height),			// Calculate The Aspect Ratio Of The Window
                    1.0f, 100.0f);
    glMatrixMode (GL_MODELVIEW);										// Select The Modelview Matrix
    *GLRC=m_hRC;

    ReleaseDC(Wnd, hDC);

    ShowWindow(Wnd,1);
    UpdateWindow(Wnd);
    InvalidateRect(Wnd,NULL,TRUE);
    return(Wnd);
}
Esempio n. 7
0
CLiveCameraDlg::CLiveCameraDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLiveCameraDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLiveCameraDlg)
		// NOTE: the ClassWizard will add member initialization here
	pImage = NULL;
	m_drawdib = DrawDibOpen ();
	//}}AFX_DATA_INIT
	
	ACE_ASSERT (m_drawdib != NULL);
}
Esempio n. 8
0
BExtractorDoc::BExtractorDoc()
{
	m_pImage = NULL;
	m_picLoaded = false;

	m_hdd = DrawDibOpen();

	SetupEPSGDatums();

	m_proj.SetWellKnownGeogCS( "WGS84" );
	m_proj.SetUTMZone(1);
}
Esempio n. 9
0
/*
---------------------------------------------------------------------------------------
- load function
---------------------------------------------------------------------------------------
*/
void AviVideoRenderer::Load(const std::string & filename)
{
	CloseAVI();

	_AVR_hdd = DrawDibOpen();


	// Open The AVI File
	_video_opened = OpenAVI(filename.c_str());

	_lastFrame = -1;
	_firstTime = true;
}
////////////////////////////////////////////////////////////////
// Draw DIB on caller's DC. Does stretching from source to destination
// rectangles. Generally, you can let the following default to zero/NULL:
//
//		bUseDrawDib = whether to use use DrawDib, default TRUE
//		pPal	      = palette, default=NULL, (use DIB's palette)
//		bForeground = realize in foreground (default FALSE)
//
// If you are handling palette messages, you should use bForeground=FALSE,
// since you will realize the foreground palette in WM_QUERYNEWPALETTE.
//
BOOL CDib::Draw(CDC& dc, const CRect* rcDst, const CRect* rcSrc,
	BOOL bUseDrawDib, CPalette* pPal, BOOL bForeground)
{
	if (!m_hObject)
		return FALSE;

	// Select, realize palette
	if (pPal==NULL)				// no palette specified:
		pPal = GetPalette();		// use default
	CPalette* pOldPal = dc.SelectPalette(pPal, !bForeground);
	dc.RealizePalette();

	BOOL bRet = FALSE;
	if (bUseDrawDib) {
		// Compute rectangles where NULL specified
		//
		CRect rc(0,0,-1,-1);	// default for DrawDibDraw
		if (!rcSrc)
			rcSrc = &rc;
		if (!rcDst)
			rcDst=rcSrc;
		if (!m_hdd)
			VERIFY(m_hdd = DrawDibOpen());

		// Get BITMAPINFOHEADER/color table. I copy into stack object each time.
		// This doesn't seem to slow things down visibly.
		//
		DIBSECTION ds;
		VERIFY(GetObject(sizeof(ds), &ds)==sizeof(ds));
		char buf[sizeof(BITMAPINFOHEADER) + MAXPALCOLORS*sizeof(RGBQUAD)];
		BITMAPINFOHEADER& bmih = *(BITMAPINFOHEADER*)buf;
		RGBQUAD* colors = (RGBQUAD*)(&bmih+1);
		memcpy(&bmih, &ds.dsBmih, sizeof(bmih));
		GetColorTable(colors, MAXPALCOLORS);

		// Let DrawDib do the work!
		bRet = DrawDibDraw(m_hdd, dc,
			rcDst->left, rcDst->top, rcDst->Width(), rcDst->Height(),
			&bmih,			// ptr to BITMAPINFOHEADER + colors
			m_bm.bmBits,	// bits in memory
			rcSrc->left, rcSrc->top, rcSrc->Width(), rcSrc->Height(),
			bForeground ? 0 : DDF_BACKGROUNDPAL);

	} else {
		// use normal draw function
		bRet = PLDrawBitmap(dc, this, rcDst, rcSrc);
	}
	if (pOldPal)
		dc.SelectPalette(pOldPal, TRUE);
	return bRet;
}
Esempio n. 11
0
static void	__fastcall Repaint(HWND	hWnd,RECT & updata,RECT& upbmp,HDC hdc)
{
	PAINTSTRUCT ps={0};
	HDRAWDIB	hdd;
	HBITMAP		hbmp;
	BITMAPINFOHEADER	bi={sizeof(bi)};
	void*		bits=LocalAlloc(LPTR,4096*4096*5);
	
	POINTS	bmprc;
	*((DWORD*)(&bmprc))= GetWindowLong(hWnd,FIELD_OFFSET(ShowPicClass,bmRC));

	hdd=DrawDibOpen();

	if(!hdc)
		hdc =BeginPaint(hWnd,&ps);

	hbmp=(HBITMAP)GetWindowLong(hWnd,FIELD_OFFSET(ShowPicClass,hbmp));
	
	BITMAP	bm;

	GetObject(hbmp,sizeof(bm),&bm);
	bi.biBitCount=32;
	bi.biWidth = bm.bmWidth;
	bi.biPlanes = 1;
	bi.biHeight = bm.bmHeight ;
	
	ExcludeClipRect(hdc,updata.left,updata.top,updata.right,updata.bottom);

	FillRect(hdc,&ps.rcPaint,(HBRUSH)1);
	
	SelectClipRgn(hdc,NULL);

	GetDIBits(hdc,hbmp,0,bi.biHeight,bits,(LPBITMAPINFO)&bi,DIB_RGB_COLORS);

	DrawDibDraw(hdd,hdc,updata.left,updata.top,updata.right-updata.left,updata.bottom-updata.top,
		&bi,bits,upbmp.left,upbmp.top,upbmp.right-upbmp.left,upbmp.bottom-upbmp.top,0);
	
	LocalFree(bits);

	DrawDibClose(hdd);
	
	if(ps.hdc)
		EndPaint(hWnd,&ps);
	
}
Esempio n. 12
0
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPGDIDrawDevice::SetTargetWindow(HWND wnd, bool is_main)
{
	TVPInitGDIOptions();
	if( wnd ) {
		// 描画用 DC を取得する
		TargetDC = ::GetDC(wnd);
	} else {
		// 描画用 DC を開放する
		if(TargetDC) ::ReleaseDC(TargetWindow, TargetDC), TargetDC = NULL;
	}

	if(DrawDibHandle) ::DrawDibClose(DrawDibHandle), DrawDibHandle = NULL;
	TargetWindow = wnd;
	IsMainWindow = is_main;
	DrawDibHandle = DrawDibOpen();

	CreateBitmap();
}
Esempio n. 13
0
// This basically allocates our "instance info" (that struct defined above)
//***************************************************************************
static long AVIDrawOpen(ICOPEN FAR * icopen)
//***************************************************************************
{
	PINSTINFO pinst;

	if (!icopen)
	   return 1;
	if (icopen->fccType != streamtypeVIDEO)
		return NULL;
	if (icopen->dwFlags == ICMODE_COMPRESS || icopen->dwFlags == ICMODE_DECOMPRESS)
		return NULL;
	if ( !(pinst = (PINSTINFO)AllocX(sizeof(INSTINFO), GMEM_ZEROINIT)) )
	{
		icopen->dwError = ICERR_MEMORY;
		return NULL;
	}
	pinst->hdd = DrawDibOpen();
	icopen->dwError = ICERR_OK;
	return (LONG) pinst;
}
Esempio n. 14
0
void MemoryMapView_InitBitmap()
{
    m_hMemoryMapDrawDib = DrawDibOpen();
    HDC hdc = GetDC( g_hwnd );

    m_bmpinfoMemoryMap.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
    m_bmpinfoMemoryMap.bmiHeader.biWidth = 256;
    m_bmpinfoMemoryMap.bmiHeader.biHeight = 256;
    m_bmpinfoMemoryMap.bmiHeader.biPlanes = 1;
    m_bmpinfoMemoryMap.bmiHeader.biBitCount = 32;
    m_bmpinfoMemoryMap.bmiHeader.biCompression = BI_RGB;
    m_bmpinfoMemoryMap.bmiHeader.biSizeImage = 0;
    m_bmpinfoMemoryMap.bmiHeader.biXPelsPerMeter = 0;
    m_bmpinfoMemoryMap.bmiHeader.biYPelsPerMeter = 0;
    m_bmpinfoMemoryMap.bmiHeader.biClrUsed = 0;
    m_bmpinfoMemoryMap.bmiHeader.biClrImportant = 0;

    m_hMemoryMapBitmap = CreateDIBSection( hdc, &m_bmpinfoMemoryMap, DIB_RGB_COLORS, (void **) &m_pMemoryMap_bits, NULL, 0 );

    ReleaseDC( g_hwnd, hdc );
}
Esempio n. 15
0
void CTimeEv::OnBnClickedButtonVidDlgOpen()
{
	// TODO: Add your control notification handler code here
	m_oAVIR.Close(); //close before re-opening

	static char BASED_CODE szFilter[] = "AVI video files (*.avi)|*.avi|All Files (*.*)|*.*||";
	CFileDialog dlg(TRUE, "avi", "*.avi", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
	if(dlg.DoModal()!=IDOK)
		return;

	CString cstrAVIPath=dlg.GetPathName();
	CString strMsg;

	if(!m_oAVIR.Open(cstrAVIPath))
	{	strMsg.Format("Couldn't open %s",cstrAVIPath);
		MessageBox(strMsg);
	}
	else
	{
		float fMilliSeconds = GetTimeMS();
		m_iFrameOffset = fMilliSeconds / m_oAVIR.MSPerFrame() ;
		
		strMsg.Format("Opened %s w=%d h=%d firstf=%d lastf=%d",
			cstrAVIPath,
			m_oAVIR.Width(),
			m_oAVIR.Height(),
			m_oAVIR.FirstFrame(),
			m_oAVIR.LastFrame());
		Write2Log(strMsg);

		Write2Log("timeWindow=%d, time=%.2f, m_iFrameOffset=%d",timeWindow,fMilliSeconds,m_iFrameOffset);

		InvalidateRect(NULL,FALSE);

		if(!m_hdd)
			m_hdd=DrawDibOpen();
	}
}
Esempio n. 16
0
BOOL CWebCamDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	SetTimer(1, 200, NULL);

	CString str;
	str.Format("\\\\%s %d * %d", m_IPAddress, m_bmih.biWidth, m_bmih.biHeight);
	SetWindowText(str);
	// 初始化窗口大小结构
	InitMMI();
	SendNext();

	m_hDD = DrawDibOpen();
	m_hDC = GetDC()->m_hDC;

	SendNext();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 17
0
/***********************************************************************
 *		DrawDibOpen		[MSVIDEO.102]
 */
HDRAWDIB16 VFWAPI DrawDibOpen16(void)
{
    return HDRAWDIB_16(DrawDibOpen());
}
Esempio n. 18
0
//////////////////////////////////////////////////////////////////////
// Draw DIB on caller's DC. Does stretching from source to destination
// rectangles. Generally, you can let the following default to zero/NULL:
//
//    nStretchMode= 0 means 'use DrawDib'; any other value must be
//                  a valid stretch-mode and will force GDI usage		
//    hPal        = palette, default=NULL, (use DIB's palette)
//    bForeground = realize in foreground (default true)
//
// If you are handling palette messages, you should use bForeground=false,
// since you will realize the foreground palette in WM_QUERYNEWPALETTE.
//
BOOL PLWinBmpEx::DrawEx( HDC dc, const RECT* rcDst, const RECT* rcSrc,
		        HPALETTE hPal, bool bForeground,
			int nStretchMode, DWORD ropcode )
{
    // Select, realize palette
    if (hPal==NULL)        // no palette specified:
        hPal = GetLogPalette();    // use default
    HPALETTE hOldPal = ::SelectPalette(dc, hPal, !bForeground);
    ::RealizePalette(dc);

    // Compute rectangles where NULL specified
    RECT rc;
    if (!rcSrc)
    {  // if no source rect, use whole bitmap
        rc.left = rc.top = 0;
        rc.right    = GetWidth();
        rc.bottom   = GetHeight();
        rcSrc = &rc;
    }
    if (!rcDst) // if no destination rect, use source
        rcDst = rcSrc;

    BOOL bRet = false;

#ifndef _WITHOUT_VFW_
    bool bUseDrawDib = nStretchMode < 0;
    if (bUseDrawDib)
    {
        if (!m_hdd)  VERIFY(m_hdd = DrawDibOpen());

        // Let DrawDib do the work!
        bRet = ::DrawDibDraw( m_hdd, dc,
                              rcDst->left,
                              rcDst->top,
                              rcDst->right  - rcDst->left,
                              rcDst->bottom - rcDst->top,
                              GetBMI(),
                              GetBits(),
                              rcSrc->left,
                              rcSrc->top,
                              rcSrc->right  - rcSrc->left,
                              rcSrc->bottom - rcSrc->top,
                              bForeground ? 0 : DDF_BACKGROUNDPAL);
    }
    else      // use normal draw function
#endif
    {
	// If user wanted DrawDib but vfw support is not linked in,
	// then try to use best looking GDI mode
	if (nStretchMode < 0) nStretchMode = HALFTONE;
	int osm = 0;
	if (nStretchMode > 0) osm = ::SetStretchBltMode( dc, nStretchMode );
#if 0	// way too slooooooooooooooooooow!        
	bRet = GDI_ERROR != ::StretchDIBits(
	                dc,
                        rcDst->left,
                        rcDst->top,
                        rcDst->right  - rcDst->left,
                        rcDst->bottom - rcDst->top,
                        rcSrc->left,
                        rcSrc->top,
                        rcSrc->right  - rcSrc->left,
                        rcSrc->bottom - rcSrc->top,
                        GetBits(),       // Pointer to bits
                        (BITMAPINFO*) GetBMI(),        // BITMAPINFO
                        DIB_RGB_COLORS,  // Options
                        ropcode);        // Raster operator code
#else
	HDC hSrcDC;
	hSrcDC = CreateCompatibleDC (dc);
	HGDIOBJ hOldBmp = ::SelectObject (hSrcDC, GetHandle());
	if (m_pClrTab)	// uses associated colormap
	    (void) ::SetDIBColorTable (hSrcDC, 0, 256, (RGBQUAD *)m_pClrTab);

	bRet = ::StretchBlt (	dc,
				rcDst->left,
				rcDst->top,
				rcDst->right  - rcDst->left,
				rcDst->bottom - rcDst->top,
				hSrcDC,
				rcSrc->left,
				rcSrc->top,
				rcSrc->right  - rcSrc->left,
				rcSrc->bottom - rcSrc->top,
				ropcode );

	::SelectObject (hSrcDC, hOldBmp);
	::DeleteDC(hSrcDC);

	// restore GDI stretch-mode
	if (osm) 
	    (void) ::SetStretchBltMode( dc, osm );
    }
#endif	// _WITHOUT_VFW_

    // restore DC palette
    if (hOldPal)
        ::SelectPalette(dc, hOldPal, true);

    return bRet;
}
Esempio n. 19
0
VideoDlg::VideoDlg(CWnd* pParent /*=NULL*/)
	: cdxCSizingDialog(VideoDlg::IDD, pParent)
{
	m_hdd=DrawDibOpen();
}
Esempio n. 20
0
//构造函数
CUserFaceRes::CUserFaceRes(void)
{
	//加载资源
	HINSTANCE hInstancle=GetModuleHandle(GAMECLIENTLOBBY_EXPORTS_NAME);
	
	//设置变量
	m_NormalSize.SetSize(NOR_FACE_WIDTH,NOR_FACE_HEIGHT);
	m_SmallSize.SetSize(LIT_FACE_WIDTH,LIT_FACE_HEIGHT);
	ImgFileList.clear();
	TempFileList.clear();

	CString DATFile=TEXT("FaceImage.DAT");

	CFileFind	finder;
	BOOL	FF;
	BOOL    bHaveBmp=FALSE;

	FF=finder.FindFile(DATFile);
	if(!FF){
		return;
	}

	CFile pFile;
	pFile.Open(DATFile,CFile::modeRead);

	char FileNum[10];
	pFile.Read(FileNum,9);
	long NUM = atol(FileNum);

	for(long j=0;j<NUM;j++){	

		BITMAPFILEHEADER bmfh;

		// 步骤1 读取文件头
		char filename[128];
		pFile.Read(filename,127);

		int nCount = pFile.Read((LPVOID) &bmfh, sizeof(BITMAPFILEHEADER));

		// 判断是否是BMP格式的位图
		if(bmfh.bfType != BMP_HEADER_MARKER) 
		{
			continue;
		}

		// 计算信息头加上调色板的大小并分内存
		int nSize = bmfh.bfOffBits - sizeof(BITMAPFILEHEADER);
		LPBITMAPINFOHEADER m_pBMIH = (LPBITMAPINFOHEADER) new BYTE[nSize];

		// 步骤2 读取信息头和调色板
		nCount = pFile.Read(m_pBMIH, nSize); 

		// 步骤3 读取图象数据
		LPBYTE	m_pBits = (LPBYTE) new BYTE[m_pBMIH->biSizeImage];
		nCount = pFile.Read(m_pBits, m_pBMIH->biSizeImage); 

		ImgFileList.push_back(filename);
		delete m_pBits;
		delete m_pBMIH;
	}
	pFile.Close();
	m_hDrawDib  = DrawDibOpen();
	return;
}
Esempio n. 21
0
static FIMULTIBITMAP* ReadFromAvi(const char* filename) {
	int err=0;
	AVIFileInit();
	
	PAVISTREAM pavi; // Handle To An Open Stream
	if( AVIStreamOpenFromFile(&pavi, filename, streamtypeVIDEO, 0, OF_READ, NULL) != 0) {
		AVIFileExit();
		return NULL;
	}



	AVISTREAMINFO		psi;				// Pointer To A Structure Containing Stream Info
	AVIStreamInfo(pavi, &psi, sizeof(psi));				// Reads Information About The Stream Into psi
	int width  = psi.rcFrame.right-psi.rcFrame.left;			// Width Is Right Side Of Frame Minus Left
	int height = psi.rcFrame.bottom-psi.rcFrame.top;			// Height Is Bottom Of Frame Minus Top
	int frameCount = AVIStreamLength(pavi);							// The Last Frame Of The Stream

	double mpf = AVIStreamSampleToTime(pavi, frameCount) / (double)frameCount;		// Calculate Rough Milliseconds Per Frame

	PGETFRAME pgf = AVIStreamGetFrameOpen(pavi, NULL);				// Create The PGETFRAME Using Our Request Mode
	if (pgf==NULL)
	{
		// An Error Occurred Opening The Frame
		error("Failed To Open frame from AVI");
	}

	//HDC hdc = GetDC(0);

	HDRAWDIB hdd = DrawDibOpen();													// Handle For Our Dib

	BITMAPINFOHEADER bmih;										// Header Information For DrawDibDraw Decoding
	bmih.biSize = sizeof (BITMAPINFOHEADER);					// Size Of The BitmapInfoHeader
	bmih.biPlanes = 1;											// Bitplanes	
	bmih.biBitCount = 24;										// Bits Format We Want (24 Bit, 3 Bytes)
	bmih.biWidth = width;										// Width We Want (256 Pixels)
	bmih.biHeight = height;										// Height We Want (256 Pixels)
	bmih.biCompression = BI_RGB;								// Requested Mode = RGB

	char		*data;						// Pointer To Texture Data
	HBITMAP hBitmap = CreateDIBSection(hdc, (BITMAPINFO*)(&bmih), DIB_RGB_COLORS, (void**)(&data), NULL, NULL);
	SelectObject(hdc, hBitmap);								// Select hBitmap Into Our Device Context (hdc)

	// create a new freeimage anim
	someError=false;
	FIMULTIBITMAP* ret = FreeImage_OpenMultiBitmap(FIF_TIFF, "temp.tiff", TRUE, FALSE);
	if (!ret || someError) {
		error("Couldnt create multibitmap");
	}

	for (int frame=0; frame<frameCount; frame++) {
		fprintf(stderr, "Loading frame %i\n", frame);
		// Grab Data From The AVI Stream
		LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);	
		// Pointer To Data Returned By AVIStreamGetFrame
		// (Skip The Header Info To Get To The Data)
		char* pdata = (char *)lpbi + lpbi->biSize + lpbi->biClrUsed * sizeof(RGBQUAD);	
		
		// Convert Data To Requested Bitmap Format
		DrawDibDraw(hdd, hdc, 0, 0, width, height, lpbi, pdata, 0, 0, width, height, 0);

		// copy into the freeimage thing
		FIBITMAP* fiBitmap = FreeImage_ConvertFromRawBits((BYTE*)data, width, height, width*3, 24, 0xFF0000, 0x00FF00, 0x0000FF);
/*		BYTE* src = (BYTE*)data;
		for (int y=0; y<height; y++) {
			BYTE* dst = FreeImage_GetScanLine(fiBitmap, y);
			for (int x=0; x<width; x++) {
				//src++;
				*dst++ = *src++;
				*dst++ = *src++;
				*dst++ = *src++;
			}
		}
*/
		FIBITMAP* grayBitmap = FreeImage_ConvertToGreyscale(fiBitmap);
		FreeImage_Unload(fiBitmap);

		FreeImage_AppendPage(ret, grayBitmap);
	}
	FreeImage_CloseMultiBitmap(ret);
	ret = FreeImage_OpenMultiBitmap(FIF_TIFF, "temp.tiff", FALSE, TRUE);

	DeleteObject(hBitmap);										// Delete The Device Dependant Bitmap Object
	DrawDibClose(hdd);											// Closes The DrawDib Device Context
	AVIStreamGetFrameClose(pgf);								// Deallocates The GetFrame Resources
	AVIStreamRelease(pavi);										// Release The Stream
	AVIFileExit();												// Release The File

	return ret;
}
bool Movie::reload(const io::stringc &Filename, const s32 Resolution)
{
    if (DataPointer_)
        close();
    
    /* Information message */
    io::Log::message("Load movie: \"" + Filename + "\"");
    io::Log::upperTab();
    
    /* General settings */
    SMovieSequencePacket* MovieData = new SMovieSequencePacket;
    
    DataPointer_                = MovieData;
    
    MovieData->Next             = MovieData->Frame      = 0;
    MovieData->State            = MOVIESTATE_STOPED;
    MovieData->Time             = MovieData->LastTime   = 0;
    MovieData->RawData          = 0;
    MovieData->Resolution       = Resolution;
    
    MovieData->hDeviceContext   = CreateCompatibleDC(0);
    MovieData->hDrawDIB         = DrawDibOpen();
    
    AVIFileInit();
    
    /* Open video stream */
    if (AVIStreamOpenFromFile(&MovieData->pVideoStream, Filename.c_str(), streamtypeVIDEO, 0, OF_READ, 0) != 0)
        return exitWithError("Could not open video stream");
    if (AVIStreamInfo(MovieData->pVideoStream, &MovieData->VideoStreamInfo, sizeof(MovieData->VideoStreamInfo)) != 0)
        return exitWithError("Video stream information process failed");
    
    MovieData->VideoLastFrame = AVIStreamLength(MovieData->pVideoStream);
    
    if (MovieData->VideoLastFrame == -1)
        return exitWithError("Video stream length is invalid");
    
    MovieData->VideoMPF = AVIStreamSampleToTime(MovieData->pVideoStream, MovieData->VideoLastFrame) / MovieData->VideoLastFrame;
    
    if (MovieData->VideoMPF == -1)
        return exitWithError("Video stream sample is invalid");
    
    #if 0
    
    /* Open audio stream */
    if (AVIStreamOpenFromFile(&MovieData->pAudioStream, Filename.c_str(), streamtypeAUDIO, 0, OF_READ, 0))
        return exitWithError("Could not open audio stream");
    if (AVIStreamInfo(MovieData->pAudioStream, &MovieData->AudioStreamInfo, sizeof(MovieData->AudioStreamInfo)))
        return exitWithError("Audio stream information process failed");
    
    MovieData->AudioLastFrame = AVIStreamLength(MovieData->pAudioStream);
    
    if (MovieData->AudioLastFrame == -1)
        return exitWithError("Audio stream length is invalid");
    
    MovieData->AudioMPF = AVIStreamSampleToTime(MovieData->pAudioStream, MovieData->AudioLastFrame) / MovieData->AudioLastFrame;
    
    if (MovieData->AudioMPF == -1)
        return exitWithError("Audio stream sample is invalid");
    
    #endif
    
    /* Start configuration process */
    MovieData->Size.Width   = MovieData->VideoStreamInfo.rcFrame.right  - MovieData->VideoStreamInfo.rcFrame.left;
    MovieData->Size.Height  = MovieData->VideoStreamInfo.rcFrame.bottom - MovieData->VideoStreamInfo.rcFrame.top;
    
    MovieData->BitmapInfoHeader.biSize          = sizeof(BITMAPINFOHEADER);
    MovieData->BitmapInfoHeader.biPlanes        = 1;
    MovieData->BitmapInfoHeader.biBitCount      = 24;
    MovieData->BitmapInfoHeader.biWidth         = MovieData->Resolution;
    MovieData->BitmapInfoHeader.biHeight        = MovieData->Resolution;
    MovieData->BitmapInfoHeader.biCompression   = BI_RGB;
    
    /* Create the movie bitmap context */
    MovieData->hBitmap = CreateDIBSection(
        MovieData->hDeviceContext,
        (BITMAPINFO*)(&MovieData->BitmapInfoHeader),
        DIB_RGB_COLORS,
        (void**)(&MovieData->RawData),
        0, 0
    );

    if (!MovieData->hBitmap)
        return exitWithError("Could not create device independent bitmap (DIB) for video stream");
    
    SelectObject(MovieData->hDeviceContext, MovieData->hBitmap);
    
    MovieData->BitmapInfoHeader.biWidth         = MovieData->Size.Width;
    MovieData->BitmapInfoHeader.biHeight        = MovieData->Size.Height;
    MovieData->BitmapInfoHeader.biSizeImage     = 0;
    MovieData->BitmapInfoHeader.biClrUsed       = 0;
    MovieData->BitmapInfoHeader.biClrImportant  = 0;
    
    /* Get first video frame */
    MovieData->pGetFrame = AVIStreamGetFrameOpen(MovieData->pVideoStream, &MovieData->BitmapInfoHeader);
    
    if (!MovieData->pGetFrame)
        return exitWithError("Could not open first video stream");
    
    io::Log::lowerTab();
    
    return true;
}