The Movie Player can provide your application a handle to the movie palette. This can be useful if, for example, you need to paint a movie frame into a bitmap and copy the bitmap to the Clipboard. Use the mmpGetPaletteHandle function to obtain a handle to the movie palette. This function has the following syntax:
HPALETTE mmpGetPaletteHandle(idMovie)
Pass the movie ID of the Movie Player instance in idMovie. This function returns a handle to the palette of the currently loaded movie.
The following function creates a copy of the movie palette. It then creates a bitmap, draws the current movie frame into the bitmap device context, and copies the bitmap and palette to the Clipboard.
void CopyFrame(HWND hWnd)
{
HPALETTE hPalette, hClipPalette;
HDC hDC, hMemoryDC;
HBITMAP hBitmap;
MMPMOVIEINFO mmpInfo;
int nX, nY;
hPalette = mmpGetPaletteHandle(idMovie);
if((hClipPalette = CopyPalette(hPalette)) == NULL)
{
MessageBox(hWnd, "Could not copy palette.", szAppName, MB_OK);
return;
}
hDC = GetDC(hWnd);
hMemoryDC = CreateCompatibleDC(hDC);
if(bFullScreen)
mmpInfo.dwMovieExtentX = mmpInfo.dwMovieExtentY = 0;
else
mmpGetMovieInfo(idMovie, &mmpInfo);
/* Create bitmap, sized to match the movie frame area
*/
nX = (int)(mmpInfo.dwMovieExtentX ? mmpInfo.dwMovieExtentX :
GetSystemMetrics (SM_CXSCREEN));
nY = (int)(mmpInfo.dwMovieExtentY ? mmpInfo.dwMovieExtentY :
GetSystemMetrics (SM_CYSCREEN));
hBitmap = CreateCompatibleBitmap(hDC, nX, nY);
/* Select the bitmap in the memory DC and draw the
* movie frame into the bitmap
*/
SelectObject(hMemoryDC, hBitmap);
mmpUpdate(idMovie, hMemoryDC, NULL);
/* Place the bitmap and logical palette on the Clipboard
*/
if(OpenClipboard(hWnd))
{
EmptyClipboard();
SetClipboardData(CF_BITMAP, hBitmap);
SetClipboardData(CF_PALETTE, hClipPalette);
CloseClipboard();
}
else
MessageBox(hWnd, "Could not open Clipboard.", szAppName, MB_OK);
DeleteDC(hMemoryDC);
ReleaseDC(hWnd, hDC);
}