Bild einfügen



  • Hallo!

    Kann mir bitte jemand sagen, wie ich ein Bild aus einer Datei (unkomprimierte .bmp-Datei) auf eine bestimmte Position einfügen kann?
    (In einer Win32-Anwendung)

    MfG
    Juko



  • Hi...

    Ist zwar eine ziemlich primitive & eigentlich auch schlechte Methode, aber hier hab ich was für dich ...

    const char* szBitmap = "C:\\TeSt.bmp"; 
    
    int main() 
    { 
        Sleep(1000); 
        int breite = 0; 
        int hoehe  = 0; 
    
        int PosX = 0; // X-Position
        int PosY = 0; // Y-Position
    
       HWND hConsoleWindow = FindWindow("ConsoleWindowClass",NULL); 
    
        if (!hConsoleWindow) 
           return 1; 
    
        HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,szBitmap,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); 
    
       if (!hBitmap) 
           return 1; 
    
        BITMAP bitmap; 
        GetObject(hBitmap,sizeof(bitmap),&bitmap); 
       hoehe   = bitmap.bmHeight; 
       breite   = bitmap.bmWidth; 
    
        HDC hDC = GetDC(hConsoleWindow); 
    
        if (!hDC) 
           return 1; 
    
          HDC hBitmapDC = CreateCompatibleDC(hDC); 
    
        if (!hBitmapDC) 
           return 1; 
    
          SelectObject(hBitmapDC,hBitmap); 
    
        BitBlt(hDC,PosX,PosY,breite,hoehe,hBitmapDC,0,0,SRCCOPY); 
    
        DeleteObject(hBitmap); 
        ReleaseDC(hConsoleWindow,hBitmapDC); 
        ReleaseDC(hConsoleWindow,hDC); 
    
      return 0; 
    }
    

    Falls Probleme gibt, meld dich...

    Cia
    þя!ncë


Anmelden zum Antworten