Einfaches Bild darstellen



  • so jetzt gehts!
    aber wie bekomme ich den Hintergrund (weiß) transparent?

    {
    	HDC dc = GetDC(0);
    	HDC dcMem = CreateCompatibleDC(dc);
    
    	RECT rect;
    	GetClientRect(GetDesktopWindow(),&rect);
    
    	HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,
    										"crate.bmp",
    										IMAGE_BITMAP,
    										0, 0,
    										LR_LOADFROMFILE);
    
    	HBITMAP hBitmapOld = (HBITMAP)SelectObject(dcMem,hBitmap);
    
    	BITMAP bitmap;
    	GetObject(hBitmap,sizeof(bitmap),&bitmap);
    
    	DWORD start = GetTickCount();
    	DWORD now = start;
    	while ((now - start <= ms) && (now >= start))
    	{
    		BitBlt(dc, (rect.right-rect.left-bitmap.bmWidth)/2, (rect.bottom-rect.top-bitmap.bmHeight)/2,
    				bitmap.bmWidth, bitmap.bmHeight,
    				dcMem,
    				0, 0,
    				SRCCOPY);
    		Beep(880,1);
    		now = GetTickCount();
    	}
    
    	DeleteObject(dcMem);
    	DeleteObject(hBitmap);
    
    	InvalidateRect(0, NULL, TRUE);
    	UpdateWindow(GetDesktopWindow());
    	return 0;
    }
    




  • error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__TransparentBlt@44" in Funktion ""public: int __thiscall CAction::DisplayImage(int)" (?DisplayImage@CAction@@QAEHH@Z)".

    was ist da los??



  • sry code vergessen.

    {
    	HDC dc = GetDC(0);
    	HDC dcMem = CreateCompatibleDC(dc);
    
    	RECT rect;
    	GetClientRect(GetDesktopWindow(),&rect);
    
    	HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,
    										"crate.bmp",
    										IMAGE_BITMAP,
    										0, 0,
    										LR_LOADFROMFILE);
    
    	HBITMAP hBitmapOld = (HBITMAP)SelectObject(dcMem,hBitmap);
    
    	BITMAP bitmap;
    	GetObject(hBitmap,sizeof(bitmap),&bitmap);
    
    	DWORD start = GetTickCount();
    	DWORD now = start;
    	while ((now - start <= ms) && (now >= start))
    	{
    /*		BitBlt(dc, (rect.right-rect.left-bitmap.bmWidth)/2, (rect.bottom-rect.top-bitmap.bmHeight)/2,
    				bitmap.bmWidth, bitmap.bmHeight,
    				dcMem,
    				0, 0,
    				SRCCOPY);
    */		TransparentBlt(dc,
    					   (rect.right-rect.left-bitmap.bmWidth)/2,
    					   (rect.bottom-rect.top-bitmap.bmHeight)/2,
    						bitmap.bmWidth, bitmap.bmHeight,
    						dcMem,
    						0, 0,
    						bitmap.bmWidth, bitmap.bmHeight,
    						RGB(255,255,255));
    		Beep(880,1);
    		now = GetTickCount();
    	}
    
    	DeleteObject(dcMem);
    	DeleteObject(hBitmap);
    
    	InvalidateRect(0, NULL, TRUE);
    	UpdateWindow(GetDesktopWindow());
    	return 0;
    }
    


  • Probier mal "GdiTransparentBlt (...)".



  • wie geht nicht.
    "GdiTransparentBlt": Bezeichner wurde nicht gefunden.
    thx.



  • TransparentBlt

    Requirements
    Windows NT/2000/XP: Included in Windows 2000 and later.
    Windows 95/98/Me: Included in Windows 98 and later.
    Header: Declared in Wingdi.h; include Windows.h.
    Library: Use Msimg32.lib.

    Tipp: Schau dir den letzten Punkt der Anforderungen an.



  • na und ?
    was muss ich denn mit der Libery machen?
    danke.



  • Dem Linker bekanntmachen. Hast ja ein "error LNK2019". Eventuell so :

    #pragma comment(lib, "Msimg32.lib")
    

    Das ist allerdings kein WinAPI-Problem.
    😞



  • was soll ich tun?
    muss ich die libery hinzufügen?



  • thx thx mit dem #pragma!
    jetzt geht das suppi!


Anmelden zum Antworten