Thread: Problem with MinGW

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    6

    Problem with MinGW

    I am using MinGW special 20020817-1 and attempted to use the following line in my application...
    hResult = OleLoadPicture(ps, dwSize, FALSE, IID_IPicture, (LPVOID *)&pPicture); /* the rest in works fine */

    This is the only line causing problems so far.

    IID_IPicture does not appear to be defined in any of the libraries.

    I get the following [Link] Error 1
    C:/image.o(.text+0x12d):image.cpp: undefined reference to `IID_IPicture'

    in olectl.h the identifier of the interface IID_IPicture is... "EXTERN_C const IID IID_IPicture;"

    Where would IID_IPicture be defined? I experimented by linking each ole related library one at a time but that didn't work.

    I used the picture loading code from Microsofts website before with visual C++ and had no problems.

    The entire load picture example can be found here:
    http://support.microsoft.com/default...;en-us;Q218972
    It may have moved.

    Can anyone explain why this is not working in MinGW?

    Thank you

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Linking with -loleaut32 -luuid fixes that.

    If you don't have the latest mingw cvs olectl.h, get it because it declares OleLoadPicturePath which is a lot less tedious to use than OleLoadPicture:
    Code:
    LPPICTURE pPicture;
    WCHAR wszFile[]=L"name_of_file_to_load";
    HRESULT hr=OleLoadPicturePath(wszFile, 0, 0, 0, IID_IPicture, (void**)&pPicture);
    Hope that's of some use to you.

    edit: editing

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    6
    Thanks a lot, that was the library I was looking for. :-) Can you tell me how you knew which library to use so next time I will be able to find it myself?

    One drawback to using the OleLoadPicture() is that when the image is rendered it doesn't realize the palette on older systems that display only 256 colors. If you know of a way around this problem I would love to hear it.

    Thanks again.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>Can you tell me how you knew which library to use so next time I will be able to find it myself?<<

    Certainly. I used the world-famous algorithms known as 'guesswork' and 'luck'.

    >>One drawback to using the OleLoadPicture() is that when the image is rendered it doesn't realize the palette on older systems that display only 256 colors. <<

    It's been a long time since I fiddled around with this stuff. I think Petzold's book has a large section explaining it in some detail. From memory I think you would use a dibsection, create a palette corresponding to the image palette and select it into your dc. Some functions to take a look at:

    SelectPalette
    CreatePalette
    CreateHalftonePalette
    RealizePalette

    Sorry I can't be of more help to you in this regard. Perhaps someone else with more recent/thorough knowledge may be able to help out?

    Good luck anyway.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Problem with the exception class in MINGW
    By indigo0086 in forum C++ Programming
    Replies: 6
    Last Post: 01-20-2007, 01:12 PM
  3. MinGW - __cplusplus not being defined?
    By Mario F. in forum Tech Board
    Replies: 5
    Last Post: 12-04-2006, 07:17 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM