把HBITMAP对象转换成CBitmap以后用CBitmap::GetBitmap()可以获得,但是如果只用API编程该用什么函数?查了半天MSDN无果,如果有人知道请不吝赐教!

解决方案 »

  1.   

    SIZE s;
    GetBitmapDimensionEx( hBitmap, &s );
      

  2.   

    GetBitmapDimensionEx只有在用SetBitmapDimensionEx设置了属性只有才有效,否则返回的是0,0。再说GetBitmapDimensionEx返回的不一定是图像的真实大小,SetBitmapDimensionEx设置多少就返回多少。没有其他的办法了吗?
      

  3.   

    HDC hMemDC=CreateCompatibleDC( ... );
    HBITMAP hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBitmap);
    int iWidth = GetDeviceCaps( hMemDC, HORZSIZE );
    int iHeight = GetDeviceCaps( hMemDC, VERTSIZE );
    ...
      

  4.   

    HBITMAP   bm;
    //CBitmap   bitmap.LoadBitmap(ID_BITMAP);
     bitmap.GetObject(sizeof(bm),&bm);
      

  5.   

    一定要那么麻烦吗?微软的那些笨蛋都是怎么想的,这些基本信息都不能直接获得,还封装得那么厉害只丢一个句柄给你,哎,微软一天不倒闭程序员永无出头只日,现在的VC已经不像是编译器而像是一个工具软件了,和flash差不多了。幸亏在公司是在UNIX下编程
      

  6.   

    int GetDIBits(
      HDC hdc,           // handle to DC
      HBITMAP hbmp,      // handle to bitmap
      UINT uStartScan,   // first scan line to set
      UINT cScanLines,   // number of scan lines to copy
      LPVOID lpvBits,    // array for bitmap bits
      LPBITMAPINFO lpbi, // bitmap data buffer
      UINT uUsage        // RGB or palette index
    );
      

  7.   

    BITMAP bmp; 
     
        // Retrieve the bitmap's color format, width, and height. 
        if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp)) 
                    error!!!
      
    BITMAP 是一个系统结构
    typedef struct tagBITMAP {  /* bm */
        int     bmType;
        int     bmWidth;
        int     bmHeight;
        int     bmWidthBytes;
        BYTE    bmPlanes;
        BYTE    bmBitsPixel;
        LPVOID  bmBits;
    } BITMAP;包含了HBITMAP的基本信息
      

  8.   

    原来是它,找得好辛苦,MSDN也写得太烂了吧,找了半天都没提过这个