Esto se puede lograr con la función StretchBlt. El código de referencia es el siguiente: void?CImgWnd::OnPaint()
{
CPaintDC?dc(. this);?/ /?device?context?for?painting
//Obtener tamaño de ventana
CRect?r;
GetClientRect(amp;r) ;
//Rellena el fondo
HBRUSH?brush?=?(HBRUSH)::GetStockObject(GRAY_BRUSH);
::FillRect(dc.m_hDC ,amp;r,brush );
dc.SetStretchBltMode(HALFTONE);
//Seleccione el mapa de bits en la escena del dispositivo
CDC?memdc;
memdc.CreateCompatibleDC(?amp;dc?);
CBitmap*?pOldBmp=?memdc.SelectObject(amp;m_bmpImage);
//Obtener mapa de bits parámetros
BITMAP?bmp;
m_bmpImage.GetBitmap(amp;bmp);
//Iniciar escalado
switch(m_nStrechType)
{
caso?STRECH_1_1://1:1
dc.BitBlt(r.izquierda, r.top, r.Width(), r .Height() , amp; memdc, 0, 0, SRCCOPY);
romper
case?STRECH_FULL_X: //Por ancho
dc.StretchBlt (r.left, r.top, r.Width(), bmp.bmHeight, amp; memdc, 0, 0,
bmp.bmWidth, bmp.bmHeight, SRCCOPY
<); p>break;case?STRECH_FULL_Y: //Por altura
dc.StretchBlt(r.left, r.top, bmp.bmWidth, r.Height(), amp; memdc, 0, 0,
bmp.bmWidth, bmp.bmHeight, SRCCOPY
break;
case?STRECH_FULL: //Ventana completa
p>
dc.StretchBlt(r.left, r.top, r.Width(), r.Height(), & memdc, 0, 0,
bmp.bmWidth, bmp.bmHeight , SRCCOPY) ;
break;
case?STRECH_CENTER: //Visualización centrada, el tamaño es la mitad de la ventana
dc.StretchBlt(r.Width( )/4, r.Altura()/4, r.Ancho()/2, r.Altura()/2, amp; , SRCCOPY);
romper;
}
//Restaurar
memdc.Se
lectObject(pOldBmp);
}