[C con Clase] Una Funcion en WinApi

Ringo aydabella en yahoo.com.ar
Lun Dic 11 12:45:33 CET 2006


Hola a todos,
  estuve navegando por las páginas alemanas y encontré la siguiente Función que teóricamente refleja una imagen de distintas formas. Intente utilizarla, pero no me resulta. Talvez alguien me pueda indicar cómo debo llamar a esa función en mi programa. Gracias por toda respuesta.
  Abel
   
  #include <windows.h>

#define BITMAP_FLIP_NONE            0
#define BITMAP_FLIP_HORIZONTAL      1
#define BITMAP_FLIP_VERTICAL        2
#define BITMAP_FLIP_BOTH            3

// Der erste Paramter ist optional; in den allermeistenn Faellen wird hier NULL uebergeben
// Der zweite Parameter ist das zu spiegelnde Bitmap.
// Der dritte Parameter bestimmt die Art der Spiegelung:
//  - 0: Es wird einfach eine Kopie des Bitmaps gezogen
//  - 1: Das Bitmap wird horizontal gespiegelt
//  - 2: Das Bitmap wird vertikal gespiegelt
//  - 3: Das Bitmap wird sowohl horizontal als auch vertikal gespiegelt
//
// Das zurueckgelieferte Bitmap muß mit DeleteObject wieder geloescht werden,
// wenn es nicht mehr benoetigt wird.
EXTERN_C HBITMAP FlipBitmap(HDC hdcRef, HBITMAP hBitmap, int nFlip)
{
    HBITMAP hbmpDst, hbmpSrc;
    BITMAP  bm;
    HDC     hdcSrc, hdcDst;

    static const int nMultiplier[4][4] =
    {
        {  0,  0,  1,  1  },
        {  1,  0, -1,  1  },
        {  0,  1,  1, -1  },
        {  1,  1, -1, -1  }
    };

    if(nFlip > BITMAP_FLIP_BOTH)
    {
        SetLastError(ERROR_INVALID_PARAMETER);
        return(NULL);
    }

    if(!GetObject(hBitmap, sizeof(BITMAP), &bm))
        return(NULL);

    hdcSrc  = CreateCompatibleDC(hdcRef);
    hdcDst  = CreateCompatibleDC(hdcRef);
    hbmpSrc = (HBITMAP)SelectObject(hdcSrc, (HGDIOBJ)hBitmap);
    hbmpDst = CreateCompatibleBitmap(hdcSrc, bm.bmWidth, bm.bmHeight);
    hbmpDst = (HBITMAP)SelectObject(hdcDst, (HGDIOBJ)hbmpDst);

    SetMapMode(hdcDst, MM_ANISOTROPIC);
    SetWindowOrgEx(hdcDst, 0, 0, NULL);
    SetWindowExtEx(hdcDst, bm.bmWidth, bm.bmHeight, NULL);
    SetViewportOrgEx(hdcDst, bm.bmWidth * nMultiplier[nFlip][0], bm.bmHeight * nMultiplier[nFlip][1], 
                     NULL);
    SetViewportExtEx(hdcDst, bm.bmWidth * nMultiplier[nFlip][2], bm.bmHeight * nMultiplier[nFlip][3], 
                     NULL);

    BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY);
    hbmpDst = (HBITMAP)SelectObject(hdcDst, (HGDIOBJ)hbmpSrc);
    SelectObject(hdcSrc, (HGDIOBJ)hbmpSrc);

    DeleteDC(hdcDst);
    DeleteDC(hdcSrc);

    return(hbmpDst);
}

 __________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.conclase.net/pipermail/cconclase_listas.conclase.net/attachments/20061211/2e583b2e/attachment.html>


Más información sobre la lista de distribución Cconclase