-
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
-
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
-
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.
-
>>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. :)