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