Cropping an Image

The following example creates an MCIWnd window and loads an AVI file. The window includes a crop command in the menu, which crops one-quarter of the height or width from each of the four sides of the frame. The example retrieves the current (initial) dimensions of the source rectangle by using the MCIWndGetSource macro. The modified source rectangle is half the original height and width and is centered in the original frame. The call to the MCIWndPutSource macro redefines the coordinates of the source rectangle.

// extern RECT rSource, rDest; 
    switch (wParam) 
        case IDM_CREATEMCIWND: 
            g_hwndMCIWnd = MCIWndCreate( hwnd, 
                WS_CHILD | WS_VISIBLE, 
                "sample.avi" ); 
        case IDM_CROPIMAGE:                          // crops image 
            MCIWndGetSource(g_hwndMCIWnd, &rSource); // source rectangle
            rDest.left = rSource.left +              // new boundaries
                ((rSource.right - rSource.left) / 4); 
            rDest.right = rSource.right - 
                ((rSource.right - rSource.left) / 4); 
   = + 
                ((rSource.bottom - / 4); 
            rDest.bottom = rSource.bottom - 
                ((rSource.bottom - / 4); 
            MCIWndPutSource(g_hwndMCIWnd, &rDest);   // new source rectangle 

    // Handle other messages here.