estirable
Utilizar para escalar: StretchBlt Voltear imagen en cualquier ángulo: HBITMAP CBarDemoView:: GetRotatedBitmapNT(HBITMAP hBitmap, float radianes, COLORREF clrBack)
{
// Cree un DC de memoria compatible con la pantalla
CDC sourceDC, destDC;
sourceDC.CreateCompatibleDC( NULL
destDC.CreateCompatibleDC( NULL ); Obtener coordenadas lógicas
BITMAP bm;
:: GetObject(hBitmap, sizeof(bm), amp;bm); float coseno = (float)cos(radianes/180 * PI) ;
float seno = (float)sin(radianes/180 * PI); int x1 = (int)(bm.bmHeight * seno); (bm .bmHeight * coseno);
int x2 = (int)(bm.bmWidth * coseno bm.bmHeight * seno);
int y2 = (int)(bm. bmHeight * coseno - bm.bmWidth * seno);
int x3 = (int)(bm.bmWidth * coseno);
int y3 = (int)(-bm.bmWidth); * seno ); int minx = min(0, min(x1, min(x2, x3)))
int miny = min(0, min(y1, min(y2, y3))) ;
int maxx = max(0, max(x1, max(x2, x3)))
int maxy = max(0, max(y1, max(y2, y3)) )); int w = maxx - minx;
int h = maxy - miny; // Crea un mapa de bits para contener el resultado
HBITMAP hbmResult = ::CreateCompatibleBitmap( CClientDC(NULL ), w, h); HBITMAP hbmOldSource = (HBITMAP)::SelectObject(sourceDC.m_hDC, hBitmap);
HBITMAP hbmOldDest = (HBITMAP)::SelectObject(destDC.m_hDC, hbmResult) ; // Dibuja el color de fondo antes de cambiar el modo de mapeo
HBRUSH hbrBack = CreateSolidBru
sh( clrBack );
HBRUSH hbrOld = (HBRUSH)::SelectObject( destDC.m_hDC, hbrBack
destDC.PatBlt( 0, 0, w, h, PATCOPY ) ;
::DeleteObject( ::SelectObject(destDC.m_hDC, hbrOld) ); // Usaremos la transformación mundial para rotar el mapa de bits
SetGraphicsMode(destDC.m_hDC, GM_ADVANCED) ;
XFORM xform;
xform.eM11 = coseno;
xform.eM12 = -seno;
;
xform.eM22 = coseno;
xform.eDx = (flotante)-minx;
xform.eDy = (flotante)-miny; SetWorldTransform( destDC.m_hDC, amp ; , 0, SRCCOPY); nWidth[m_count] = bm.bmWidth;
nHeight[m_count] = bm.bmHeight; // Restaurar DCs
::SelectObject( sourceDC.m_hDC , hbmOldSource );
::SelectObject(destDC.m_hDC, hbmOldDest return hbmResult;
}