以下是我在OnDraw函数中的代码,请问一下高手哪里有问题,为什么显示不了图片?
Graphics graphics(pDC->m_hDC);
Image image(L"巴布豆.bmp");
(或者用此语句从磁盘打开一个图片 
Image image((WCHAR*)(strOpenFileName.GetBuffer(strOpenFileName.GetLength())));)graphics.DrawImage(&image,50,50);

解决方案 »

  1.   

    可我想在MDI视图中显示,怎么能添加图片控件呢?
      

  2.   

    先配置好GdiPlus的环境  
    方法如下:  
    1  到  
    http://www.bypro.net/PostAttachment.aspx?PostID=21280&AttachmentID=1787  
    下载GdiPlus开发包,释放到VC的相应Include、lib文件夹中,把dll放到windows文件夹中  
     
    2  到VC的Tools-Directories中分别添加一项Include和lib,指向你刚才释放的文件夹。  
    比如我添加一项IncludeFiles为:C:\PROGRAM  FILES\MICROSOFT  VISUAL  STUDIO\VC98\INCLUDE\GDIPLUS  
    添加一项LibraryFiles为:C:\PROGRAM  FILES\MICROSOFT  VISUAL  STUDIO\VC98\LIB\GDIPLUS  
     
    然后,开始正式的编码工作。  
     
    在C**App类的h文件中添加如下:  
    ////////////////////////////////////////  
    //必要的宏  以及头文件  
    #define  UNICODE  
    #ifndef  ULONG_PTR  
    #define  ULONG_PTR  unsigned  long*  
    #endif  
     
     
    #include  <gdiplus.h>    
    using  namespace  Gdiplus;      
    #pragma  comment(lib,  "gdiplus.lib")  //link  gdiplus.lib  
     
    ////////////////////////////////////////  
       
    然后在C**App类中添加如下成员变量!  
    (不可作为全局变量,否则link时出错,重复定义)  
    GdiplusStartupInput  gdiplusStartupInput;  
    ULONG_PTR                      gdiplusToken;  
     
    然后到InitInstance中:  
    GdiplusStartup(&gdiplusToken,  &gdiplusStartupInput,  NULL);  
    到ExitInstance中:  
    Gdiplus::GdiplusShutdown(m_gdiplusToken);  
     
     然后即可到OnDraw中:  
    //CDC  *pDC=GetDC();  
    Graphics  graphics(  pDC->m_hDC  );  
    Image  image(L"f:\\1.png");  
    graphics.TranslateTransform(230,10);  //  将原点移动到(230,10)  
    graphics.RotateTransform(20);  //  顺时针旋转30度  
    graphics.DrawImage(&image,  0,0);  
      

  3.   

    晕,都没看见CBITMAP,HBITMAP bitblt()……
    ……
    ……
      

  4.   

    楼上的,没看见人家用Image吗?