Results 1 to 18 of 18

Thread: AlphaBlend will not compile

  1. #1

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    AlphaBlend will not compile

    Code:
    ::AlphaBlend(a::hdc, xOffset, yOffset,
            drawLocation->right-drawLocation->left, drawLocation->bottom-drawLocation->top,
            invalDC, 0, 0,
            drawLocation->right-drawLocation->left, drawLocation->bottom-drawLocation->top, bf);
    error message:
    [Linker Error] Unresolved external 'AlphaBlend' referenced from D:\MY DOCUMENTS\C++ PROJECTS\GAME\MAIN.OBJ

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What OS?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Win XP Pro

  4. #4
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    may need to link to msimg32.lib.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  5. #5

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Borland says that it is in wingdi.h and finds the declaration.

    Do you still think I need to link to msimg32.lib?

    If so, how do I do that, and is it going to be compatable with other systems?

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You still need the lib. Headers and libraries have different purposes.

    As for other systems: you need at least Win98 or Win2k for AlphaBlend in any case, because that's where msimg32.dll is available. I don't think it would work even if you would install it on older systems though.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I guess now the question is, how do I tell the compiler to get AlphaBlend from the other library instead of the one it is apparently trying to pull from?

  8. #8
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Originally posted by aewarnick
    I guess now the question is, how do I tell the compiler to get AlphaBlend from the other library instead of the one it is apparently trying to pull from?
    If you are using vc 6, I think you need to download and install the platform sdk, and put the sdk's header and library paths before vc's paths in the vc's setting.

    vc 6 's is built for win95, no kidding, even though vc6 and win98 are released at about the same time (1998). I had vc6 sp5 and win98 fe. I tried to use LoadCursor() with IDC_HAND but failed because of the outdated header that came originally with vc, does not define IDC_HAND. (IDC_HAND is only available on Win98/Me and Win2000/XP, according to msdn)

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Originally posted by aewarnick
    I guess now the question is, how do I tell the compiler to get AlphaBlend from the other library instead of the one it is apparently trying to pull from?
    Currently it isn't finding it. Just add the library to the import libraries (I think it's the /l switch, but you can look that up by typing
    bcc32 /?
    ) and it should work.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Well, I would like to stay as compatable with win95 as I can and sinse AlphaBlend is not included I think I should find some kind of work around.

    That is probably what most programmers do anyway. Would you happen to know of any work arounds to imitate AlphaBlend?

    It would probably be faster anyway.

  11. #11
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    One solution is to write your own AlphaBlend code.

    I have done that once for my screen saver. I wrote that because I didn't know that is called AlphaBlend and there is a windows api for it. After several attempts, it was unsuccessful but the msdn documented the formula used for alphablend api. I used that and I succeeded.

    Anyway, the alphablend api leaks horribly in win 9x OSes.

    Attached is my screensaver. Have a look. No need to install. To un-install, just delete the file and its clrblind.dat.
    Attached Files Attached Files

  12. #12

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I was not afraid you were going to give me a virus. I was having problems even on win98 getting alphablend to work right anyway.

    I hoped for the source code but it was not included. Neat screen saver though. Thank you.
    Last edited by aewarnick; Jul 9th, 2003 at 11:16 AM.

  13. #13
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Originally posted by aewarnick
    I was not afraid you were going to give me a virus.
    By making this statement, shows that you had apprehension in the first place.

    Originally posted by aewarnick
    I hoped for the source code but it was not included. Neat screen saver though. Thank you.
    I can't give you the source code for the screen saver but I can give you the code for its alphablend. It does not offer so many options as the windows api. I'll give you on the next day because the code is enmeshed in the rendering code of the screen saver; I have to take it out and put it into a function for you. Now is night time over here.

  14. #14

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Thank you. That is all I was after. Although one other thing I would like to learn to do is compile a screen saver file.

  15. #15
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It's just a normal exe file renamed to .scr. It must handle some command line options, but that's all.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  16. #16
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Hi aewarnick,

    There are several functions you must use to accomplish this.

    First function you use, is to convert DDB to DIB

    pBGR MyGetDibBits(HDC hdc, HBITMAP hBmp, int nWidth, int nHeight);

    In the first call, you pass the hdc and hBmp of the source bmp and its dimension. it will return a pointer of sBGR type(pBGR).

    In the second call, you pass the hdc and hBmp of the destination bmp and its dimension. it will return a pointer of sBGR type(pBGR).

    The dimensions used in both calls must be the same.

    Next you use the AlphaBlend function.

    void MyAlphaBlend(pBGR pDest, int nWidth, int nHeight, pBGR pSrc, BYTE Alpha);

    Then you use the last function to convert the DIB to DDB,

    int MySetDibBits(HDC hdc, HBITMAP hBmp, int nWidth, int nHeight, pBGR buf);

    The hdc and hBmp parameters are the ones you will be using to bitblt.

    buf is the pDest parameter you feed to MyAlphaBlend()

    The return value is the number of scan lines copied.

    Now you can bitblt.

    Before the program ends, remember to free the 2 pBGR pointers received from the 2 MyGetDibBits()

    ======================================================
    To know more about DIB, you can read 'Windows Programmng' by Charles Petzold. To know more about GetDibBits() and SetDibBits(), you can consult msdn docs.

    Here's the attached source, remove the stdafx header if you are not using MFC.
    Attached Files Attached Files

  17. #17
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Originally posted by CornedBee
    It's just a normal exe file renamed to .scr. It must handle some command line options, but that's all.
    It must handle the sys-command, SC_SCREENSAVE as well.

  18. #18

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Thanks. I am going to try to implement this in both C# and C++.

    Would you say that your code is as fast as AlphaBlend is or faster?
    Last edited by aewarnick; Jul 16th, 2003 at 09:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width