如题

解决方案 »

  1.   

    创建需要大小的内存位图和内存DC,将内存位图选入内存DC,把你的位图(根据大小)BitBlt到内存DC上,将内存位图选出。
      

  2.   

    HBITMAP hbmp1, hbmp2;
    BITMAP bm;
    GetObject(hBmp1, sizeof(BITMAP), &bm);
    int bufsize = bm.bmWidth * bm.bmHeight * bm.bmBitsPixel/8;
    UCHAR* Bits = (UCHAR*) malloc(bufsize);
    GetBitmapBits(hBmp1, bufsize, Bits);
    //假定要拷贝的图像为cx * cy 
    int bufsize2 = cx * cy * bm.bmBitsPixel/8;
    UCHAR* Bits2 = (UCHAR*) malloc(bufsize2);
    for (int i = 0; i < cy; i++)
    {
    memcpy(Bits2+i*cx*bm.bmBitsPixel/8, Bits1+(起始行*bm.bmWidth+起始列)*bm.bmBitsPixel/8);
    } SetBitmapBits(hBmp2, bufsize, Bits2);
    free(Bits );
    free(Bits2 );
      

  3.   

    应是
    SetBitmapBits(hBmp2,   bufsize2,   Bits2);