0

Im newbie in MFC. Im trying to render a .jpg picture using OleLoadPicture in my Smart Device MFC project. But i got an error "unresolved external symbol OleLoadPicture" when compiling.

#include "OleCtl.h"

HGLOBAL hMem = NULL;
LPVOID lpData = NULL;
IStream *pstm = NULL;
IPicrure* pPicture;

FILE* f;
f = fopen("\\Flower.jpg","r");
char* c=new char[30720];
fread(c,1,30720,f);
size_t length = 30720;
fclose(f);

if ( ( hMem = GlobalAlloc( GMEM_MOVEABLE, length)) != NULL) 
    {
        if ( ( lpData = GlobalLock( hMem)) != NULL) 
            {
                memcpy (lpData,c,length);
                GlobalUnlock( hMem);
            }
    }

//

HRESULT hr = CreateStreamOnHGlobal( hMem, TRUE, &pstm);

CComQIPtr<IPicture> m_spIPicture;
if(m_spIPicture) m_spIPicture.Release();
HRESULT hr1= ::OleLoadPicture(pstm,length,FALSE,IID_IPicture,(void**)&m_spIPicture);
CDC *dc = AfxGetMainWnd()->GetDC();
CRect rc;   
LPRECT lprect;
AfxGetMainWnd()->GetWindowRect(lprect);
long hmWidth,hmHeight;
m_spIPicture->get_Width(&hmWidth);
m_spIPicture->get_Height(&hmHeight);
CSize sz = CSize(hmWidth,hmHeight);;
rc.right = sz.cx;
rc.bottom = sz.cy;
m_spIPicture->Render(*dc, rc.left, rc.top, rc.Width(), rc.Height(),
  0, hmHeight, hmWidth, -hmHeight, lprect);

What's wrong ?

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
Infated
  • 110
  • 1
  • 13
  • The requirements section in the [documentation](http://msdn.microsoft.com/en-us/library/windows/desktop/ms693724.aspx) says *[desktop apps only]*. I'm pretty sure that excludes smart devices / Windows CE. – Frédéric Hamidi Sep 15 '14 at 12:58
  • and there are other ways to solve? (without using GDI+) – Infated Sep 15 '14 at 13:00
  • Depends on the formats you want to support. Apparently, even for plain BMP files `LoadImage()` is also "desktop apps only", so you may want to delegate that work to a third-party library. – Frédéric Hamidi Sep 15 '14 at 13:04

0 Answers0