Changeset 6644 for trunk/src/comctl32/animate.c
- Timestamp:
- Sep 5, 2001, 2:05:03 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/animate.c
r5630 r6644 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: animate.c,v 1.14 2001-09-05 12:04:56 bird Exp $ */ 2 3 /* 3 4 * Animation control 4 5 * 5 6 * Copyright 1998, 1999 Eric Kohl 6 * 7 * 1999 Eric Pouech 7 8 * 8 9 * NOTES … … 33 34 #endif 34 35 /* reference to input stream (file or resource) */ 35 HGLOBAL 36 HMMIO hMMio;/* handle to mmio stream */37 HWND 36 HGLOBAL hRes; 37 HMMIO hMMio; /* handle to mmio stream */ 38 HWND hWnd; 38 39 /* information on the loaded AVI file */ 39 MainAVIHeader 40 AVIStreamHeader 41 LPBITMAPINFOHEADER 42 LPDWORD 40 MainAVIHeader mah; 41 AVIStreamHeader ash; 42 LPBITMAPINFOHEADER inbih; 43 LPDWORD lpIndex; 43 44 /* data for the decompressor */ 44 HIC 45 LPBITMAPINFOHEADER 46 LPVOID 47 LPVOID 45 HIC hic; 46 LPBITMAPINFOHEADER outbih; 47 LPVOID indata; 48 LPVOID outdata; 48 49 /* data for the background mechanism */ 49 CRITICAL_SECTION 50 HANDLE 51 UINT 50 CRITICAL_SECTION cs; 51 HANDLE hThread; 52 UINT uTimer; 52 53 /* data for playing the file */ 53 int 54 int 55 int 56 int 54 int nFromFrame; 55 int nToFrame; 56 int nLoop; 57 int currFrame; 57 58 /* tranparency info*/ 58 COLORREF transparentColor;59 HBRUSH 60 HBITMAP 59 COLORREF transparentColor; 60 HBRUSH hbrushBG; 61 HBITMAP hbmPrevFrame; 61 62 } ANIMATE_INFO; 62 63 63 64 #define ANIMATE_GetInfoPtr(hWnd) ((ANIMATE_INFO *)GetWindowLongA(hWnd, 0)) 64 #define ANIMATE_COLOR_NONE 65 #define ANIMATE_COLOR_NONE 0xffffffff 65 66 66 67 static void ANIMATE_Notify(ANIMATE_INFO* infoPtr, UINT notif) 67 68 { 68 SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 69 MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif), 70 69 SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 70 MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif), 71 (LPARAM)infoPtr->hWnd); 71 72 } 72 73 … … 77 78 #endif 78 79 { 79 HRSRC 80 MMIOINFO 81 LPVOID 82 80 HRSRC hrsrc; 81 MMIOINFO mminfo; 82 LPVOID lpAvi; 83 83 84 #ifdef __WIN32OS2__ 84 85 if (unicode) … … 90 91 #endif 91 92 if (!hrsrc) 92 93 93 return FALSE; 94 94 95 infoPtr->hRes = LoadResource(hInst, hrsrc); 95 96 if (!infoPtr->hRes) 96 97 97 return FALSE; 98 98 99 lpAvi = LockResource(infoPtr->hRes); 99 100 if (!lpAvi) 100 101 101 return FALSE; 102 102 103 memset(&mminfo, 0, sizeof(mminfo)); 103 104 mminfo.fccIOProc = FOURCC_MEM; … … 106 107 infoPtr->hMMio = mmioOpenA(NULL, &mminfo, MMIO_READ); 107 108 if (!infoPtr->hMMio) { 108 109 109 GlobalFree((HGLOBAL)lpAvi); 110 return FALSE; 110 111 } 111 112 … … 127 128 #else 128 129 infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL, 129 130 MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 130 131 #endif 131 132 if (!infoPtr->hMMio) 132 133 133 return FALSE; 134 134 135 return TRUE; 135 136 } … … 141 142 142 143 /* should stop playing */ 143 if (infoPtr->hThread) 144 if (infoPtr->hThread) 144 145 { 145 146 if (!TerminateThread(infoPtr->hThread,0)) 146 147 WARN("could not destroy animation thread!\n"); 147 148 infoPtr->hThread = 0; 148 149 } 149 150 if (infoPtr->uTimer) { 150 151 151 KillTimer(infoPtr->hWnd, infoPtr->uTimer); 152 infoPtr->uTimer = 0; 152 153 } 153 154 … … 163 164 { 164 165 if (infoPtr->hMMio) { 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 166 ANIMATE_DoStop(infoPtr); 167 mmioClose(infoPtr->hMMio, 0); 168 if (infoPtr->hRes) { 169 FreeResource(infoPtr->hRes); 170 infoPtr->hRes = 0; 171 } 172 if (infoPtr->lpIndex) { 173 HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex); 174 infoPtr->lpIndex = NULL; 175 } 176 if (infoPtr->hic) { 177 ICClose(infoPtr->hic); 178 infoPtr->hic = 0; 179 } 180 if (infoPtr->inbih) { 181 HeapFree(GetProcessHeap(), 0, infoPtr->inbih); 182 infoPtr->inbih = NULL; 183 } 184 if (infoPtr->outbih) { 185 HeapFree(GetProcessHeap(), 0, infoPtr->outbih); 186 infoPtr->outbih = NULL; 187 } 187 188 if( infoPtr->indata ) 188 189 { 189 190 HeapFree(GetProcessHeap(), 0, infoPtr->indata); 190 191 infoPtr->indata = NULL; 191 192 } 192 193 if( infoPtr->outdata ) 193 194 { 194 195 HeapFree(GetProcessHeap(), 0, infoPtr->outdata); 195 196 infoPtr->outdata = NULL; 196 197 } 197 198 if( infoPtr->hbmPrevFrame ) 198 199 { 199 200 DeleteObject(infoPtr->hbmPrevFrame); 200 201 infoPtr->hbmPrevFrame = 0; 201 202 } 202 203 204 205 206 207 208 209 } 210 infoPtr->transparentColor = ANIMATE_COLOR_NONE; 203 infoPtr->indata = infoPtr->outdata = NULL; 204 infoPtr->hWnd = 0; 205 infoPtr->hMMio = 0; 206 207 memset(&infoPtr->mah, 0, sizeof(infoPtr->mah)); 208 memset(&infoPtr->ash, 0, sizeof(infoPtr->ash)); 209 infoPtr->nFromFrame = infoPtr->nToFrame = infoPtr->nLoop = infoPtr->currFrame = 0; 210 } 211 infoPtr->transparentColor = ANIMATE_COLOR_NONE; 211 212 } 212 213 213 214 static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSource) 214 { 215 { 215 216 HDC hdcMask; 216 217 HBITMAP hbmMask; 217 HBITMAP hbmOld; 218 218 HBITMAP hbmOld; 219 219 220 /* create a transparency mask */ 220 221 hdcMask = CreateCompatibleDC(hdcDest); 221 hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL); 222 hbmOld = SelectObject(hdcMask, hbmMask); 222 hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL); 223 hbmOld = SelectObject(hdcMask, hbmMask); 223 224 224 225 SetBkColor(hdcSource,infoPtr->transparentColor); 225 226 BitBlt(hdcMask,0,0,infoPtr->inbih->biWidth, infoPtr->inbih->biHeight,hdcSource,0,0,SRCCOPY); 226 227 227 228 /* mask the source bitmap */ 228 SetBkColor(hdcSource, RGB(0,0,0)); 229 SetTextColor(hdcSource, RGB(255,255,255)); 229 SetBkColor(hdcSource, RGB(0,0,0)); 230 SetTextColor(hdcSource, RGB(255,255,255)); 230 231 BitBlt(hdcSource, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND); 231 232 232 233 /* mask the destination bitmap */ 233 SetBkColor(hdcDest, RGB(255,255,255)); 234 SetTextColor(hdcDest, RGB(0,0,0)); 234 SetBkColor(hdcDest, RGB(255,255,255)); 235 SetTextColor(hdcDest, RGB(0,0,0)); 235 236 BitBlt(hdcDest, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND); 236 237 … … 258 259 259 260 if (!hDC || !infoPtr->inbih) 260 261 return TRUE; 261 262 262 263 if (infoPtr->hic ) … … 266 267 267 268 nWidth = infoPtr->outbih->biWidth; 268 nHeight = infoPtr->outbih->biHeight; 269 nHeight = infoPtr->outbih->biHeight; 269 270 } else 270 { 271 { 271 272 pBitmapData = infoPtr->indata; 272 273 pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih; 273 274 274 275 nWidth = infoPtr->inbih->biWidth; 275 nHeight = infoPtr->inbih->biHeight; 276 } 276 nHeight = infoPtr->inbih->biHeight; 277 } 277 278 278 279 if(!infoPtr->hbmPrevFrame) … … 281 282 } 282 283 283 SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS); 284 284 SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS); 285 285 286 hdcMem = CreateCompatibleDC(hDC); 286 287 hbmOld = SelectObject(hdcMem, infoPtr->hbmPrevFrame); 287 288 288 /* 289 * we need to get the transparent color even without ACS_TRANSPARENT, 289 /* 290 * we need to get the transparent color even without ACS_TRANSPARENT, 290 291 * because the style can be changed later on and the color should always 291 * be obtained in the first frame 292 * be obtained in the first frame 292 293 */ 293 294 if(infoPtr->transparentColor == ANIMATE_COLOR_NONE) 294 295 { 295 296 infoPtr->transparentColor = GetPixel(hdcMem,0,0); 296 } 297 298 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 299 { 297 } 298 299 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 300 { 300 301 HDC hdcFinal = CreateCompatibleDC(hDC); 301 302 HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight); 302 303 HBITMAP hbmOld2 = SelectObject(hdcFinal, hbmFinal); 303 304 RECT rect; 304 305 305 306 rect.left = 0; 306 307 rect.top = 0; 307 308 rect.right = nWidth; 308 309 rect.bottom = nHeight; 309 310 310 311 if(!infoPtr->hbrushBG) 311 312 infoPtr->hbrushBG = GetCurrentObject(hDC, OBJ_BRUSH); … … 320 321 infoPtr->hbmPrevFrame = hbmFinal; 321 322 } 322 323 if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER) 324 { 325 RECT rect; 323 324 if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER) 325 { 326 RECT rect; 326 327 327 328 GetWindowRect(infoPtr->hWnd, &rect); 328 nOffsetX = ((rect.right - rect.left) - nWidth)/2; 329 nOffsetY = ((rect.bottom - rect.top) - nHeight)/2; 330 } 331 BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY); 329 nOffsetX = ((rect.right - rect.left) - nWidth)/2; 330 nOffsetY = ((rect.bottom - rect.top) - nHeight)/2; 331 } 332 BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY); 332 333 333 334 SelectObject(hdcMem, hbmOld); … … 338 339 static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr) 339 340 { 340 HDC 341 HDC hDC; 341 342 342 343 TRACE("Drawing frame %d (loop %d)\n", infoPtr->currFrame, infoPtr->nLoop); … … 346 347 mmioSeek(infoPtr->hMMio, infoPtr->lpIndex[infoPtr->currFrame], SEEK_SET); 347 348 mmioRead(infoPtr->hMMio, infoPtr->indata, infoPtr->ash.dwSuggestedBufferSize); 348 349 349 350 if (infoPtr->hic && 350 ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata, 351 352 353 354 351 ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata, 352 infoPtr->outbih, infoPtr->outdata) != ICERR_OK) { 353 LeaveCriticalSection(&infoPtr->cs); 354 WARN("Decompression error\n"); 355 return FALSE; 355 356 } 356 357 357 358 if ((hDC = GetDC(infoPtr->hWnd)) != 0) { 358 359 359 ANIMATE_PaintFrame(infoPtr, hDC); 360 ReleaseDC(infoPtr->hWnd, hDC); 360 361 } 361 362 362 363 if (infoPtr->currFrame++ >= infoPtr->nToFrame) { 363 364 365 366 367 368 364 infoPtr->currFrame = infoPtr->nFromFrame; 365 if (infoPtr->nLoop != -1) { 366 if (--infoPtr->nLoop == 0) { 367 ANIMATE_DoStop(infoPtr); 368 } 369 } 369 370 } 370 371 LeaveCriticalSection(&infoPtr->cs); … … 375 376 static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) 376 377 { 377 ANIMATE_INFO* 378 ANIMATE_INFO* infoPtr = (ANIMATE_INFO*)ptr_; 378 379 HDC hDC; 379 380 380 381 if(!infoPtr) 381 382 { … … 385 386 386 387 while(1) 387 { 388 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 388 { 389 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 389 390 { 390 391 hDC = GetDC(infoPtr->hWnd); 391 392 392 /* sometimes the animation window will be destroyed in between 393 * by the main program, so a ReleaseDC() error msg is possible */ 393 394 infoPtr->hbrushBG = SendMessageA(GetParent(infoPtr->hWnd),WM_CTLCOLORSTATIC,hDC, infoPtr->hWnd); 394 395 ReleaseDC(infoPtr->hWnd,hDC); 395 396 } 396 397 397 398 EnterCriticalSection(&infoPtr->cs); 398 399 ANIMATE_DrawFrame(infoPtr); 399 400 LeaveCriticalSection(&infoPtr->cs); 400 401 401 402 /* time is in microseconds, we should convert it to milliseconds */ 402 403 Sleep((infoPtr->mah.dwMicroSecPerFrame+500)/1000); … … 411 412 /* nothing opened */ 412 413 if (!infoPtr->hMMio) 413 414 return FALSE; 414 415 415 416 if (infoPtr->hThread || infoPtr->uTimer) { 416 417 417 FIXME("Already playing ? what should I do ??\n"); 418 ANIMATE_DoStop(infoPtr); 418 419 } 419 420 … … 423 424 424 425 if (infoPtr->nToFrame == 0xFFFF) 425 426 427 TRACE("(repeat=%d from=%d to=%d);\n", 428 426 infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1; 427 428 TRACE("(repeat=%d from=%d to=%d);\n", 429 infoPtr->nLoop, infoPtr->nFromFrame, infoPtr->nToFrame); 429 430 430 431 if (infoPtr->nFromFrame >= infoPtr->nToFrame || 431 432 432 infoPtr->nToFrame >= infoPtr->mah.dwTotalFrames) 433 return FALSE; 433 434 434 435 infoPtr->currFrame = infoPtr->nFromFrame; 435 436 436 437 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TIMER) { 437 438 439 438 TRACE("Using a timer\n"); 439 /* create a timer to display AVI */ 440 infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL); 440 441 } else { 441 442 DWORD threadID; 442 443 443 444 TRACE("Using an animation thread\n"); 444 445 infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr,0,0 &threadID); 445 446 if(!infoPtr->hThread) … … 448 449 return FALSE; 449 450 } 450 451 } 452 451 452 } 453 453 454 ANIMATE_Notify(infoPtr, ACN_START); 454 455 … … 459 460 static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr) 460 461 { 461 MMCKINFO 462 MMCKINFO 463 MMCKINFO 464 MMCKINFO 465 DWORD 466 DWORD 462 MMCKINFO ckMainRIFF; 463 MMCKINFO mmckHead; 464 MMCKINFO mmckList; 465 MMCKINFO mmckInfo; 466 DWORD numFrame; 467 DWORD insize; 467 468 468 469 if (mmioDescend(infoPtr->hMMio, &ckMainRIFF, NULL, 0) != 0) { 469 470 470 WARN("Can't find 'RIFF' chunk\n"); 471 return FALSE; 471 472 } 472 473 473 474 if ((ckMainRIFF.ckid != FOURCC_RIFF) || 474 475 476 475 (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) { 476 WARN("Can't find 'AVI ' chunk\n"); 477 return FALSE; 477 478 } 478 479 479 480 mmckHead.fccType = mmioFOURCC('h', 'd', 'r', 'l'); 480 481 if (mmioDescend(infoPtr->hMMio, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) { 481 482 482 WARN("Can't find 'hdrl' list\n"); 483 return FALSE; 483 484 } 484 485 485 486 mmckInfo.ckid = mmioFOURCC('a', 'v', 'i', 'h'); 486 487 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) { 487 488 488 WARN("Can't find 'avih' chunk\n"); 489 return FALSE; 489 490 } 490 491 491 492 mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->mah, sizeof(infoPtr->mah)); 492 493 493 TRACE("mah.dwMicroSecPerFrame=%ld\n", 494 TRACE("mah.dwMaxBytesPerSec=%ld\n", 495 TRACE("mah.dwPaddingGranularity=%ld\n", 496 TRACE("mah.dwFlags=%ld\n", 497 TRACE("mah.dwTotalFrames=%ld\n", 498 TRACE("mah.dwInitialFrames=%ld\n", 499 TRACE("mah.dwStreams=%ld\n", 500 TRACE("mah.dwSuggestedBufferSize=%ld\n", 501 TRACE("mah.dwWidth=%ld\n", 502 TRACE("mah.dwHeight=%ld\n", 494 TRACE("mah.dwMicroSecPerFrame=%ld\n", infoPtr->mah.dwMicroSecPerFrame); 495 TRACE("mah.dwMaxBytesPerSec=%ld\n", infoPtr->mah.dwMaxBytesPerSec); 496 TRACE("mah.dwPaddingGranularity=%ld\n", infoPtr->mah.dwPaddingGranularity); 497 TRACE("mah.dwFlags=%ld\n", infoPtr->mah.dwFlags); 498 TRACE("mah.dwTotalFrames=%ld\n", infoPtr->mah.dwTotalFrames); 499 TRACE("mah.dwInitialFrames=%ld\n", infoPtr->mah.dwInitialFrames); 500 TRACE("mah.dwStreams=%ld\n", infoPtr->mah.dwStreams); 501 TRACE("mah.dwSuggestedBufferSize=%ld\n", infoPtr->mah.dwSuggestedBufferSize); 502 TRACE("mah.dwWidth=%ld\n", infoPtr->mah.dwWidth); 503 TRACE("mah.dwHeight=%ld\n", infoPtr->mah.dwHeight); 503 504 504 505 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); … … 506 507 mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); 507 508 if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) != 0) { 508 509 509 WARN("Can't find 'strl' list\n"); 510 return FALSE; 510 511 } 511 512 512 513 mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'h'); 513 514 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { 514 515 515 WARN("Can't find 'strh' chunk\n"); 516 return FALSE; 516 517 } 517 518 518 519 mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->ash, sizeof(infoPtr->ash)); 519 520 520 TRACE("ash.fccType='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccType)),521 HIBYTE(LOWORD(infoPtr->ash.fccType)), 522 LOBYTE(HIWORD(infoPtr->ash.fccType)), 523 524 TRACE("ash.fccHandler='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccHandler)),525 HIBYTE(LOWORD(infoPtr->ash.fccHandler)), 526 LOBYTE(HIWORD(infoPtr->ash.fccHandler)), 527 528 TRACE("ash.dwFlags=%ld\n", 529 TRACE("ash.wPriority=%d\n", 530 TRACE("ash.wLanguage=%d\n", 531 TRACE("ash.dwInitialFrames=%ld\n", 532 TRACE("ash.dwScale=%ld\n", 533 TRACE("ash.dwRate=%ld\n", 534 TRACE("ash.dwStart=%ld\n", 535 TRACE("ash.dwLength=%ld\n", 536 TRACE("ash.dwSuggestedBufferSize=%ld\n", 537 TRACE("ash.dwQuality=%ld\n", 538 TRACE("ash.dwSampleSize=%ld\n", 539 TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left,540 521 TRACE("ash.fccType='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccType)), 522 HIBYTE(LOWORD(infoPtr->ash.fccType)), 523 LOBYTE(HIWORD(infoPtr->ash.fccType)), 524 HIBYTE(HIWORD(infoPtr->ash.fccType))); 525 TRACE("ash.fccHandler='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccHandler)), 526 HIBYTE(LOWORD(infoPtr->ash.fccHandler)), 527 LOBYTE(HIWORD(infoPtr->ash.fccHandler)), 528 HIBYTE(HIWORD(infoPtr->ash.fccHandler))); 529 TRACE("ash.dwFlags=%ld\n", infoPtr->ash.dwFlags); 530 TRACE("ash.wPriority=%d\n", infoPtr->ash.wPriority); 531 TRACE("ash.wLanguage=%d\n", infoPtr->ash.wLanguage); 532 TRACE("ash.dwInitialFrames=%ld\n", infoPtr->ash.dwInitialFrames); 533 TRACE("ash.dwScale=%ld\n", infoPtr->ash.dwScale); 534 TRACE("ash.dwRate=%ld\n", infoPtr->ash.dwRate); 535 TRACE("ash.dwStart=%ld\n", infoPtr->ash.dwStart); 536 TRACE("ash.dwLength=%ld\n", infoPtr->ash.dwLength); 537 TRACE("ash.dwSuggestedBufferSize=%ld\n", infoPtr->ash.dwSuggestedBufferSize); 538 TRACE("ash.dwQuality=%ld\n", infoPtr->ash.dwQuality); 539 TRACE("ash.dwSampleSize=%ld\n", infoPtr->ash.dwSampleSize); 540 TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left, 541 infoPtr->ash.rcFrame.bottom, infoPtr->ash.rcFrame.right); 541 542 542 543 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); … … 544 545 mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'f'); 545 546 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { 546 547 547 WARN("Can't find 'strh' chunk\n"); 548 return FALSE; 548 549 } 549 550 550 551 infoPtr->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); 551 552 if (!infoPtr->inbih) { 552 553 553 WARN("Can't alloc input BIH\n"); 554 return FALSE; 554 555 } 555 556 556 557 mmioRead(infoPtr->hMMio, (LPSTR)infoPtr->inbih, mmckInfo.cksize); 557 558 558 TRACE("bih.biSize=%ld\n", 559 TRACE("bih.biWidth=%ld\n", 560 TRACE("bih.biHeight=%ld\n", 561 TRACE("bih.biPlanes=%d\n", 562 TRACE("bih.biBitCount=%d\n", 563 TRACE("bih.biCompression=%ld\n", 564 TRACE("bih.biSizeImage=%ld\n", 565 TRACE("bih.biXPelsPerMeter=%ld\n", 566 TRACE("bih.biYPelsPerMeter=%ld\n", 567 TRACE("bih.biClrUsed=%ld\n", 568 TRACE("bih.biClrImportant=%ld\n", 559 TRACE("bih.biSize=%ld\n", infoPtr->inbih->biSize); 560 TRACE("bih.biWidth=%ld\n", infoPtr->inbih->biWidth); 561 TRACE("bih.biHeight=%ld\n", infoPtr->inbih->biHeight); 562 TRACE("bih.biPlanes=%d\n", infoPtr->inbih->biPlanes); 563 TRACE("bih.biBitCount=%d\n", infoPtr->inbih->biBitCount); 564 TRACE("bih.biCompression=%ld\n", infoPtr->inbih->biCompression); 565 TRACE("bih.biSizeImage=%ld\n", infoPtr->inbih->biSizeImage); 566 TRACE("bih.biXPelsPerMeter=%ld\n", infoPtr->inbih->biXPelsPerMeter); 567 TRACE("bih.biYPelsPerMeter=%ld\n", infoPtr->inbih->biYPelsPerMeter); 568 TRACE("bih.biClrUsed=%ld\n", infoPtr->inbih->biClrUsed); 569 TRACE("bih.biClrImportant=%ld\n", infoPtr->inbih->biClrImportant); 569 570 570 571 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); 571 572 572 573 mmioAscend(infoPtr->hMMio, &mmckList, 0); 573 574 574 575 #if 0 575 576 /* an AVI has 0 or 1 video stream, and to be animated should not contain 576 * an audio stream, so only one strl is allowed 577 * an audio stream, so only one strl is allowed 577 578 */ 578 579 mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); 579 580 if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) == 0) { 580 581 581 WARN("There should be a single 'strl' list\n"); 582 return FALSE; 582 583 } 583 584 #endif … … 589 590 mmckList.fccType = mmioFOURCC('m', 'o', 'v', 'i'); 590 591 if (mmioDescend(infoPtr->hMMio, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) { 591 592 592 WARN("Can't find 'movi' list\n"); 593 return FALSE; 593 594 } 594 595 595 596 /* FIXME: should handle the 'rec ' LIST when present */ 596 597 597 infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 598 598 infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 599 infoPtr->mah.dwTotalFrames * sizeof(DWORD)); 599 600 if (!infoPtr->lpIndex) { 600 601 601 WARN("Can't alloc index array\n"); 602 return FALSE; 602 603 } 603 604 604 605 numFrame = insize = 0; 605 while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && 606 607 608 609 610 611 606 while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && 607 numFrame < infoPtr->mah.dwTotalFrames) { 608 infoPtr->lpIndex[numFrame] = mmckInfo.dwDataOffset; 609 if (insize < mmckInfo.cksize) 610 insize = mmckInfo.cksize; 611 numFrame++; 612 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); 612 613 } 613 614 if (numFrame != infoPtr->mah.dwTotalFrames) { 614 615 615 WARN("Found %ld frames (/%ld)\n", numFrame, infoPtr->mah.dwTotalFrames); 616 return FALSE; 616 617 } 617 618 if (insize > infoPtr->ash.dwSuggestedBufferSize) { 618 619 619 WARN("insize=%ld suggestedSize=%ld\n", insize, infoPtr->ash.dwSuggestedBufferSize); 620 infoPtr->ash.dwSuggestedBufferSize = insize; 620 621 } 621 622 622 623 infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize); 623 624 if (!infoPtr->indata) { 624 625 625 WARN("Can't alloc input buffer\n"); 626 return FALSE; 626 627 } 627 628 … … 632 633 static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr) 633 634 { 634 DWORD 635 DWORD outSize; 635 636 636 637 /* check uncompressed AVI */ … … 638 639 (infoPtr->ash.fccHandler == mmioFOURCC('R', 'L', 'E', ' '))) 639 640 { 640 infoPtr->hic = 0; 641 641 infoPtr->hic = 0; 642 return TRUE; 642 643 } 643 644 … … 645 646 infoPtr->hic = ICOpen(ICTYPE_VIDEO, infoPtr->ash.fccHandler, ICMODE_DECOMPRESS); 646 647 if (!infoPtr->hic) { 647 648 649 } 650 651 outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 652 648 WARN("Can't load codec for the file\n"); 649 return FALSE; 650 } 651 652 outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 653 (DWORD)infoPtr->inbih, 0L); 653 654 654 655 infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize); 655 656 if (!infoPtr->outbih) { 656 657 658 } 659 660 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 661 662 663 657 WARN("Can't alloc output BIH\n"); 658 return FALSE; 659 } 660 661 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 662 (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { 663 WARN("Can't get output BIH\n"); 664 return FALSE; 664 665 } 665 666 666 667 infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage); 667 668 if (!infoPtr->outdata) { 668 669 670 } 671 672 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, 673 674 675 669 WARN("Can't alloc output buffer\n"); 670 return FALSE; 671 } 672 673 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, 674 (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { 675 WARN("Can't begin decompression\n"); 676 return FALSE; 676 677 } 677 678 … … 691 692 692 693 if (!lParam) { 693 694 695 } 696 694 TRACE("Closing avi!\n"); 695 return TRUE; 696 } 697 697 698 if (!hInstance) 698 699 hInstance = GetWindowLongA(hWnd, GWL_HINSTANCE); … … 719 720 #else 720 721 if (HIWORD(lParam)) { 721 722 723 724 725 726 727 728 729 722 TRACE("(\"%s\");\n", (LPSTR)lParam); 723 724 if (!ANIMATE_LoadResA(infoPtr, hInstance, (LPSTR)lParam)) { 725 TRACE("No AVI resource found!\n"); 726 if (!ANIMATE_LoadFileA(infoPtr, (LPSTR)lParam)) { 727 WARN("No AVI file found!\n"); 728 return FALSE; 729 } 730 } 730 731 } else { 731 732 733 734 735 736 737 732 TRACE("(%u);\n", (WORD)LOWORD(lParam)); 733 734 if (!ANIMATE_LoadResA(infoPtr, hInstance, 735 MAKEINTRESOURCEA((INT)lParam))) { 736 WARN("No AVI resource found!\n"); 737 return FALSE; 738 } 738 739 } 739 740 #endif 740 741 if (!ANIMATE_GetAviInfo(infoPtr)) { 741 742 743 742 WARN("Can't get AVI information\n"); 743 ANIMATE_Free(infoPtr); 744 return FALSE; 744 745 } 745 746 746 747 if (!ANIMATE_GetAviCodec(infoPtr)) { 747 748 749 748 WARN("Can't get AVI Codec\n"); 749 ANIMATE_Free(infoPtr); 750 return FALSE; 750 751 } 751 752 752 753 if (!GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { 753 754 754 SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight, 755 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); 755 756 } 756 757 757 758 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_AUTOPLAY) { 758 759 return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1)); 759 760 } 760 761 … … 771 772 /* nothing opened */ 772 773 if (!infoPtr->hMMio) 773 774 return FALSE; 774 775 775 776 ANIMATE_DoStop(infoPtr); … … 780 781 static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam) 781 782 { 782 ANIMATE_INFO* 783 ANIMATE_INFO* infoPtr; 783 784 784 785 /* allocate memory for info structure */ … … 789 790 #endif 790 791 if (!infoPtr) { 791 792 792 ERR("could not allocate info memory!\n"); 793 return 0; 793 794 } 794 795 … … 802 803 803 804 InitializeCriticalSection(&infoPtr->cs); 804 805 805 806 return 0; 806 807 } … … 826 827 { 827 828 RECT rect; 828 HBRUSH hBrush = 0; 829 830 if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 831 { 832 hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd); 829 HBRUSH hBrush = 0; 830 831 if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 832 { 833 hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd); 833 834 } 834 835 … … 842 843 { 843 844 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { 844 845 InvalidateRect(hWnd, NULL, TRUE); 845 846 } 846 847 return TRUE; … … 851 852 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam); 852 853 if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE)) 853 854 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 854 855 switch (uMsg) 855 856 { … … 862 863 #else 863 864 case ACM_OPENA: 864 865 866 /*case ACM_OPEN32W: FIXME!! */867 /*return ANIMATE_Open32W(hWnd, wParam, lParam); */868 #endif 869 865 return ANIMATE_OpenA(hWnd, wParam, lParam); 866 867 /* case ACM_OPEN32W: FIXME!! */ 868 /* return ANIMATE_Open32W(hWnd, wParam, lParam); */ 869 #endif 870 870 871 case ACM_PLAY: 871 872 872 return ANIMATE_Play(hWnd, wParam, lParam); 873 873 874 case ACM_STOP: 874 875 875 return ANIMATE_Stop(hWnd, wParam, lParam); 876 876 877 case WM_NCCREATE: 877 878 879 878 ANIMATE_Create(hWnd, wParam, lParam); 879 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 880 880 881 case WM_NCHITTEST: 881 882 return HTTRANSPARENT; 882 883 883 884 case WM_DESTROY: 884 885 886 885 ANIMATE_Destroy(hWnd, wParam, lParam); 886 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 887 887 888 case WM_ERASEBKGND: 888 889 890 891 /* 889 ANIMATE_EraseBackground(hWnd, wParam, lParam); 890 break; 891 892 /* case WM_STYLECHANGED: FIXME shall we do something ?? */ 892 893 893 894 case WM_TIMER: 894 895 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 895 896 { 896 897 ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); 897 898 infoPtr->hbrushBG = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd); 898 899 } 899 900 900 return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd)); 901 901 902 case WM_CLOSE: 902 903 903 ANIMATE_Free(ANIMATE_GetInfoPtr(hWnd)); 904 return TRUE; 904 905 905 906 case WM_PAINT: 906 907 { 907 908 ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); 908 909 909 910 /* the animation isn't playing, don't paint */ 910 911 912 913 911 if(!infoPtr->uTimer && !infoPtr->hThread) 912 /* default paint handling */ 913 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 914 914 915 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 915 916 infoPtr->hbrushBG = SendMessageA(GetParent(hWnd), WM_CTLCOLORSTATIC, 916 917 917 (HDC)wParam, hWnd); 918 918 919 if (wParam) 919 920 { … … 924 925 else 925 926 { 926 927 927 PAINTSTRUCT ps; 928 HDC hDC = BeginPaint(hWnd, &ps); 928 929 929 930 EnterCriticalSection(&infoPtr->cs); 930 931 ANIMATE_PaintFrame(infoPtr, hDC); 931 932 LeaveCriticalSection(&infoPtr->cs); 932 933 934 935 } 936 933 934 EndPaint(hWnd, &ps); 935 } 936 } 937 break; 937 938 938 939 case WM_SIZE: 939 940 940 ANIMATE_Size(hWnd, wParam, lParam); 941 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 941 942 942 943 default: 943 944 945 944 if (uMsg >= WM_USER) 945 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); 946 946 947 #ifdef __WIN32OS2__ 947 948 return defComCtl32ProcA (hWnd, uMsg, wParam, lParam); 948 949 #else 949 950 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 950 951 #endif 951 952 } … … 966 967 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); 967 968 wndClass.lpszClassName = ANIMATE_CLASSA; 968 969 969 970 RegisterClassA(&wndClass); 970 971 }
Note:
See TracChangeset
for help on using the changeset viewer.