Index   Commented   Search   About

Stretching an Image

The following example stretches the images of a video clip. It increases the dimensions of the destination rectangle by using the MCIWndPutDest macro. The size of the playback area remains unchanged, so the result is a distorted, magnified image. The examples uses the MCIWndPutDest function to reposition the destination rectangle with respect to the playback area, providing a way to view different portions of the stretched image.

extern RECT rCurrent, rDest;

case WM_COMMAND:

switch (wParam)

{

case IDM_CREATEMCIWND:

g_hwndMCIWnd = MCIWndCreate(hwnd,

g_hinst,

WS_CHILD | WS_VISIBLE,

"sample.avi");

break;

case IDM_STRETCHIMAGE: // stretch destination RECT 3:2,

MCIWndGetDest(g_hwndMCIWnd, &rCurrent); // destination RECT

rDest.top = rCurrent.top; // new boundaries

rDest.right = rCurrent.right;

rDest.left = rCurrent.left +

((rCurrent.left - rCurrent.right) * 3);

rDest.bottom = rCurrent.top +

((rCurrent.bottom - rCurrent.top) * 2);

MCIWndPutDest(g_hwndMCIWnd, &rDest); // new destination

break;

case IDM_MOVEDOWN: // move toward bottom of image

MCIWndGetDest(g_hwndMCIWnd, &rCurrent); // destination RECT

rCurrent.top -= 100; // new boundaries

rCurrent.bottom -= 100;

MCIWndPutDest(g_hwndMCIWnd, &rCurrent); // new destination

break;

case IDM_MOVEUP: // move toward top of image

MCIWndGetDest(g_hwndMCIWnd, &rCurrent); // destination RECT

rCurrent.top += 100; // new boundaries

rCurrent.bottom += 100;

MCIWndPutDest(g_hwndMCIWnd, &rCurrent); // new destination

break;

case IDM_MOVELEFT: // move toward left edge of image

MCIWndGetDest(g_hwndMCIWnd, &rCurrent); // destination RECT

rCurrent.right += 100; // new boundaries

rCurrent.left += 100;

MCIWndPutDest(g_hwndMCIWnd, &rCurrent); // new destination

break;

case IDM_MOVERIGHT: // move toward right edge of image

MCIWndGetDest(g_hwndMCIWnd, &rCurrent); // destination RECT

rCurrent.right -= 100; // new boundaries

rCurrent.left -= 100;

MCIWndPutDest(g_hwndMCIWnd, &rCurrent); // new destination

break;

}

break;

// Handle other messages here.

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference (win32.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun