TransparentBlt not working

Started by
3 comments, last by chowe6685 18 years, 5 months ago
Hiya I have bought a bokk called "Sam Teach Yourself Game Programming in 24 hours". I have been trying to make a simple game that moves a sprite around the screen, so far I have managed to make the sprite and background appear, modifying the game Henway from the book. The first time I tried to run I had loads of linking problesms with the objects, I sorted this out by removing all the lines that involved joystick functions, and a few involving bitmap drawing. Now I can run the program but unfortunatly it still shows any magenta (rgb(255,0,255)) parts I have put in the pictures even though they shouldn't be drawn. I have traced this to the function: void Bitmap::Draw(HDC hDC, int x, int y, BOOL bTrans, COLORREF crTransColor) { if (m_hBitmap != NULL) { // Create a memory device context for the bitmap HDC hMemDC = CreateCompatibleDC(hDC); // Select the bitmap into the device context HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, m_hBitmap); // Draw the bitmap to the destination device context // if (bTrans) // TransparentBlt(hDC, x, y, GetWidth(), GetHeight(), hMemDC, 0, 0, // GetWidth(), GetHeight(), crTransColor); // else BitBlt(hDC, x, y, GetWidth(), GetHeight(), hMemDC, 0, 0, SRCCOPY); // Restore and delete the memory device context SelectObject(hMemDC, hOldBitmap); DeleteDC(hMemDC); } } I cannot run the program without commenting out the lines otherwise it will come up with: Bitmap.obj : error LNK2001: unresolved external symbol __imp__TransparentBlt@44 Debug/Movement Feature.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. I am currently using MS Visual C++ 6, can someone please tell me how to make this work?
Whether you think you can or think you can’t, you’re probably right – Henry Ford
Advertisement
Try linking the msimg32.lib and winmm.lib libraries to your project.
Thanks alot, its works perfectly now.
Whether you think you can or think you can’t, you’re probably right – Henry Ford
I don't really know much about libruaries, although I know how to link to them, is there a way to tell which libruary you need to link to to make a certain function work?
Whether you think you can or think you can’t, you’re probably right – Henry Ford
Look it up on MSDN - it should tell you which libraries contian the function you need there.

This topic is closed to new replies.

Advertisement