Mike Dennis
October 25th, 1999, 05:09 PM
I am trying to create an off screen DIB from a printer DC and then
drawing directly to that DIB and then blitting the offscreen DIB back
onto the printer DC. I am having problems with the Microsoft HP HP-GL/2
driver under Windows NT 4 Service Pack 5. I get a Blue Screen when
attempting to draw text that is outside the DIB's range (that should be
clipped). I suspect there is a problem with the print driver but I just
want to verify that my logic is correct. Here is the procedure I follow
for doing which is how I interpreted it should be done from the SDK docs
:
NOTE:
hdc - is the handle of the Device context of the printer selected from the print dialog
info - is a bitmap info section defining the DIB info
pBits - is a pointer to a buffer to hold the bits from the DIB
w - is the width of the DIB
h - is the height of the DIB
// Select the DIB into the Print DC
dib = CreateDIBSection(hdc, info, DIB_RGB_COLORS, (void**)&pBits, NULL,0);
SelectObject(hdc, dib);
// Create a Memory DC of the Print DC
ghdc = CreateCompatibleDC(hdc);
// Create and select a bitmap into that DC (should copy the DIB infoaccording to the API)
hbmap = CreateCompatibleBitmap(ghdc, w, h);
SelectObject(ghdc, hbmap);
// Retreive and update where the bits for the DIB are stored (after the memory Bitmap has been created)
GetObject(hbmap, sizeof(dibSect), &dibSect);
pMemBits = dibSect.dsBm.bmBits;
pBits = pMemBits;
// Now we should be able to delete the original DIB selected into the original DC
// and just work with the bits from the memory DC
DeleteObject(dib);
-------------------
After this if I try to send text that needs to be clipped to the DIB I
get a blue screen. For example :
TextOut(ghdc, LONG_MAX/2, LONG_MAX/2, "I: 123", 6); // this causes the
blue screen
-------------------
I have also tried a similar thing by first creating the compatibleDC
and then selecting the DIB directly into it with the same results.
Am I missing something here? The procedure seems to work fine for
Screen DC's or if I draw directly onto the Print DC without first
creating the Memory DC then the same Text commands works fine as well?
Is there another way of accomplishing what I want to do?
Thanks,
Mike
drawing directly to that DIB and then blitting the offscreen DIB back
onto the printer DC. I am having problems with the Microsoft HP HP-GL/2
driver under Windows NT 4 Service Pack 5. I get a Blue Screen when
attempting to draw text that is outside the DIB's range (that should be
clipped). I suspect there is a problem with the print driver but I just
want to verify that my logic is correct. Here is the procedure I follow
for doing which is how I interpreted it should be done from the SDK docs
:
NOTE:
hdc - is the handle of the Device context of the printer selected from the print dialog
info - is a bitmap info section defining the DIB info
pBits - is a pointer to a buffer to hold the bits from the DIB
w - is the width of the DIB
h - is the height of the DIB
// Select the DIB into the Print DC
dib = CreateDIBSection(hdc, info, DIB_RGB_COLORS, (void**)&pBits, NULL,0);
SelectObject(hdc, dib);
// Create a Memory DC of the Print DC
ghdc = CreateCompatibleDC(hdc);
// Create and select a bitmap into that DC (should copy the DIB infoaccording to the API)
hbmap = CreateCompatibleBitmap(ghdc, w, h);
SelectObject(ghdc, hbmap);
// Retreive and update where the bits for the DIB are stored (after the memory Bitmap has been created)
GetObject(hbmap, sizeof(dibSect), &dibSect);
pMemBits = dibSect.dsBm.bmBits;
pBits = pMemBits;
// Now we should be able to delete the original DIB selected into the original DC
// and just work with the bits from the memory DC
DeleteObject(dib);
-------------------
After this if I try to send text that needs to be clipped to the DIB I
get a blue screen. For example :
TextOut(ghdc, LONG_MAX/2, LONG_MAX/2, "I: 123", 6); // this causes the
blue screen
-------------------
I have also tried a similar thing by first creating the compatibleDC
and then selecting the DIB directly into it with the same results.
Am I missing something here? The procedure seems to work fine for
Screen DC's or if I draw directly onto the Print DC without first
creating the Memory DC then the same Text commands works fine as well?
Is there another way of accomplishing what I want to do?
Thanks,
Mike