//////////////////////////////////////////////////////////////////////////////// // // FUNCTION: InitAnimation // // DESCRIPTION: Prepare animated GIF // // RETURNS: // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // N T ALMOND 29012002 1.0 Origin // //////////////////////////////////////////////////////////////////////////////// bool ImageEx::InitAnimation(HWND hWnd/*, CRect rect*/) { m_hWnd = hWnd; //m_rect = rect; if (!m_bIsInitialized) { TRACE(_T("GIF not initialized\n")); return false; }; if (IsAnimatedGIF()) { if (m_hThread == NULL) { unsigned int nTID = 0; m_hThread = (HANDLE) _beginthreadex( NULL, 0, _ThreadAnimationProc, this, CREATE_SUSPENDED,&nTID); if (!m_hThread) { TRACE(_T("Couldn't start a GIF animation thread\n")); return true; } else ResumeThread(m_hThread); } } return false; }
//bool ImageEx::InitAnimation(HWND hWnd,int x,int y)// POINT &pt) bool ImageEx::InitAnimation(int x,int y) { m_pt.x=x; m_pt.y=y; if (IsAnimatedGIF()) { return true; } return false; }
/* Sizes the preview window based on the size of the embedded image. This is over-ridden from the main DocPreview so that GIF animations aren't scaled up, only down. This will allow the animation to be correctly centered. */ void CPicturePreview::SizeDocPreview(void) { if (IsAnimatedGIF()) { ErasePreview(); // Determine our current image animation. CSize sizeImage = m_pGIFAnimator->GetGIFScreenSize(); // Set some initial bounds for this object int nFullWidth = m_crFullPreview.Width() - 2; int nFullHeight = m_crFullPreview.Height() - 2; int nWidth, nHeight; if ( (sizeImage.cx > m_crFullPreview.Width()) || (sizeImage.cy > m_crFullPreview.Height()) ) { // Ensure we have legal x and y values (otherwise we can get division by zero errors below. if (sizeImage.cx == 0) { sizeImage.cx = 1; } if (sizeImage.cy == 0) { sizeImage.cy = 1; } // Scale to fit in the box nHeight = nFullHeight; if ((nWidth = scale_pcoord(nHeight, sizeImage.cx, sizeImage.cy)) > nFullWidth) { nWidth = nFullWidth; nHeight = scale_pcoord(nWidth, sizeImage.cy, sizeImage.cx); } } else { // Don't scale if we are smaller than the preview area. nWidth = sizeImage.cx; nHeight = sizeImage.cy; } // Size the preview window to the new dimensions. SizePreviewWindow(nWidth, nHeight); } else { // It isn't an animated GIF so call the parent doc sizing method. CDocumentPreview::SizeDocPreview(); } }
//////////////////////////////////////////////////////////////////////////////// // // FUNCTION: ImageEx::SetPause // // DESCRIPTION: Toggle Pause state of GIF // // RETURNS: // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // N T ALMOND 29012002 1.0 Origin // //////////////////////////////////////////////////////////////////////////////// void ImageEx::SetPause(bool bPause) { if (!IsAnimatedGIF()) return; if (bPause && !m_bPause) { ::ResetEvent(m_hPause); } else { if (m_bPause && !bPause) { ::SetEvent(m_hPause); } } m_bPause = bPause; }