Q: VC++ 64 Bit SetDIBits does not work I recompiled existing VC++ code in VS2013 .Net 4 with Target Machine 64 bit. Compilation is fine but for some reason SetDIBits is not working. Images are coming up black. These are monochrome images. Same exact code works fine with VS2008 .Net 2.0 32-bit compilation. Any ideas will be helpful.
Sample code is below (This function gets the IntPtr handle which is then used for additional drawing):
IntPtr GetGraphics(Bitmap ^src, BitmapData ^pData, IntPtr ^phBitmapOldIntPtr) {

    HDC hdc;
    IntPtr scan0;
    BitmapData ^data;
    System::Drawing::Rectangle rectSrc = System::Drawing::Rectangle(0, 0, src->Width, src->Height);

    BYTE *pBits;
    IntPtr pixels, hBitmapIntPtr, hdcIntPtr;
    BITMAPINFO *pbmi;
    int iScanLines;
    int iCopied;
    HBITMAP hBitmapSrc, hBitmapOld;

    hdc = CreateCompatibleDC(NULL);

        hBitmapSrc = CreateCompatibleBitmap(hdc, src->Width, src->Height);
        data = src->LockBits(rectSrc, ImageLockMode::ReadWrite, src->PixelFormat);
        pixels = data->Scan0;
        pBits = (BYTE*)pixels.ToPointer();
        //ZeroMemory(&pbmi, sizeof(BITMAPINFO));
        pbmi = (BITMAPINFO*)GlobalAlloc(GMEM_FIXED, sizeof(BITMAPINFO) + 2 * sizeof(RGBQUAD));
        pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
        pbmi->bmiHeader.biBitCount = 1;
        pbmi->bmiHeader.biHeight = -src->Height;
        pbmi->bmiHeader.biWidth = src->Width;
        pbmi->bmiHeader.biPlanes = 1;
        pbmi->bmiHeader.biCompression = BI_RGB;
        pbmi->bmiHeader.biSizeImage = 0;
        pbmi->bmiHeader.biXPelsPerMeter = 300;
        pbmi->bmiHeader.biYPelsPerMeter = 300;
        pbmi->bmiHeader.biClrUsed = 0;
        pbmi->bmiHeader.biClrImportant = 0;
        pbmi->bmiColors[0].rgbBlue = 0;
        pbmi->bmiColors[0].rgbGreen = 0;
        pbmi->bmiColors[0].rgbRed = 0;
        pbmi->bmiColors[1].rgbBlue = 255;
        pbmi->bmiColors[1].rgbGreen = 255;
        pbmi->bmiColors[1].rgbRed = 255;
        iScanLines = src->Height;
        iCopied = SetDIBits(hdc, hBitmapSrc, 0, iScanLines, pBits, pbmi, DIB_RGB_COLORS);
        GlobalFree(pbmi);
        if (pData) pData = data;

    hBitmapOld = (HBITMAP)SelectObject(hdc, hBitmapSrc);
    phBitmapOldIntPtr = IntPtr(hBitmapOld);
    hdcIntPtr = IntPtr((void*)hdc); 
    return hdcIntPtr;
 }

Thanks in advance!

A: The whole function can be replaced with:


*

*src->Clone() to copy the bitmap to a compatible bitmap

*Graphics::FromImage() to make a Graphics compatible with the clone

*GetHdc() on the graphics, to get an HDC for your existing drawing functions

