Fooo
May 5th, 1999, 06:26 PM
Hi! I'm constructing a bitmap that I want to print. I have anything from 400-600DPI black and white or 300-400 greyscale images I need to print.I'm trying to print these bitmaps and I've found some funky stuff. I'm using the general print framework, but there's 2 problems I've run into:
1. I can only print black and white, not grayscale or color or anything
2. I have to do something different for Win98/WinNT
Here's a snippet of my code. I'm looking for some general direction or a good website to follow for
some detailed help. I've checked MS but only saw a small example and it's not doing anything
different than I am.
The code is from my onPrint function. This works now for black and white on both platforms. I figure there has to be an easier way to get all this to work.
Thanks for any help you guys can offer!
---CODE---
CBitmap* tbits = (CBitmap*)bitmap->Memdc->SelectObject(bitmap->cbits);
int nheight = pDC->GetDeviceCaps(VERTRES);
int nwidth = pDC->GetDeviceCaps(HORZRES);
int clip = pDC->GetDeviceCaps(CLIPCAPS);
int pResX = pDC->GetDeviceCaps(LOGPIXELSX);
int pResY = pDC->GetDeviceCaps(LOGPIXELSY);
int outwidth = ((float)nwidth/pResX)*resolution;
int outheight = ((float)nheight/pResY)*resolution;
CDC *memDC = new CDC;
CBitmap *wholething = new CBitmap;
wholething->CreateBitmap( outwidth, outheight,
bitmap->ReturnBmapInfo()->bmiHeader.biPlanes,
bitmap->ReturnBmapInfo()->bmiHeader.biBitCount, NULL);
// I DONT KNOW WHATS UP. But the first works in NT< the other in Win98
if (_winminor == 0)
memDC->CreateCompatibleDC(bitmap->Memdc);
else
memDC->CreateCompatibleDC(pDC);
CBitmap *oldfoo = memDC->SelectObject(wholething);
memDC->BitBlt(0,0, outwidth, outheight, NULL, 0,0,WHITENESS);
memDC->BitBlt(0,0, outwidth, outheight, bitmap->Memdc, 0,0,SRCCOPY);
bitmap->Memdc->SelectObject(tbits);
delete bitmap;
pDC->StretchBlt(0,0,nwidth-1,nheight-1,memDC,0,0,outwidth,outheight,SRCCOPY);
memDC->SelectObject(oldfoo);
delete memDC;
delete wholething;
1. I can only print black and white, not grayscale or color or anything
2. I have to do something different for Win98/WinNT
Here's a snippet of my code. I'm looking for some general direction or a good website to follow for
some detailed help. I've checked MS but only saw a small example and it's not doing anything
different than I am.
The code is from my onPrint function. This works now for black and white on both platforms. I figure there has to be an easier way to get all this to work.
Thanks for any help you guys can offer!
---CODE---
CBitmap* tbits = (CBitmap*)bitmap->Memdc->SelectObject(bitmap->cbits);
int nheight = pDC->GetDeviceCaps(VERTRES);
int nwidth = pDC->GetDeviceCaps(HORZRES);
int clip = pDC->GetDeviceCaps(CLIPCAPS);
int pResX = pDC->GetDeviceCaps(LOGPIXELSX);
int pResY = pDC->GetDeviceCaps(LOGPIXELSY);
int outwidth = ((float)nwidth/pResX)*resolution;
int outheight = ((float)nheight/pResY)*resolution;
CDC *memDC = new CDC;
CBitmap *wholething = new CBitmap;
wholething->CreateBitmap( outwidth, outheight,
bitmap->ReturnBmapInfo()->bmiHeader.biPlanes,
bitmap->ReturnBmapInfo()->bmiHeader.biBitCount, NULL);
// I DONT KNOW WHATS UP. But the first works in NT< the other in Win98
if (_winminor == 0)
memDC->CreateCompatibleDC(bitmap->Memdc);
else
memDC->CreateCompatibleDC(pDC);
CBitmap *oldfoo = memDC->SelectObject(wholething);
memDC->BitBlt(0,0, outwidth, outheight, NULL, 0,0,WHITENESS);
memDC->BitBlt(0,0, outwidth, outheight, bitmap->Memdc, 0,0,SRCCOPY);
bitmap->Memdc->SelectObject(tbits);
delete bitmap;
pDC->StretchBlt(0,0,nwidth-1,nheight-1,memDC,0,0,outwidth,outheight,SRCCOPY);
memDC->SelectObject(oldfoo);
delete memDC;
delete wholething;