这个函数其中的两个参数就是指定装载的位图的高度和宽度,但我发现随着数值的不同,装载出来的效果也不同,我认为是装载的时候强制改变了改位图的象素,所以看上去效果和原来的不一样了,我想得到和原来图片一样的效果,有没什么方法获得该图片的高和宽再传入函数中?(总不能我一个一个数字慢慢试吧??)

解决方案 »

  1.   

    BITMAP bitmap;
              hBitmapImag = LoadBitmap (hInstance, MAKEINTRESOURCE(IDB_BITMAP));
              GetObject (hBitmapImag, sizeof (BITMAP), &bitmap) ;
              cxBitmap = bitmap.bmWidth ;
              cyBitmap = bitmap.bmHeight ;
      

  2.   

    直接读文件,先读出BITMAPFILEHEADER结构,
    The BITMAPFILEHEADER structure contains information about the type, size, and layout of a file that contains a DIB. typedef struct tagBITMAPFILEHEADER { 
      WORD    bfType; 
      DWORD   bfSize; 
      WORD    bfReserved1; 
      WORD    bfReserved2; 
      DWORD   bfOffBits; 
    } BITMAPFILEHEADER, *PBITMAPFILEHEADER; 
    Members
    bfType 
    Specifies the file type, must be BM. 
    bfSize 
    Specifies the size, in bytes, of the bitmap file. 
    bfReserved1 
    Reserved; must be zero. 
    bfReserved2 
    Reserved; must be zero. 
    bfOffBits 
    Specifies the offset, in bytes, from the BITMAPFILEHEADER structure to the bitmap bits. 然后再读出BITMAPINFO结构,里面就有高度和宽度了。
    A BITMAPINFO or BITMAPCOREINFO structure immediately follows the BITMAPFILEHEADER structure in the DIB file.
      

  3.   

    hbmp = (HBITMAP)::LoadImage( AfxGetInstanceHandle(), 
         "bitmap1.bmp",IMAGE_BITMAP,0,0, 
         LR_LOADFROMFILE);
      

  4.   

    2楼的太高深~~看不懂了`~
    楼上的很直接啊,直接可以得到我想要的结果~~
    另外我想问句,加上“(HBITMAP)”有什么意义吗?我试着不加这个,也能运行啊~~