 |
|
 |
Because a DDB that's been created by a specific device is stored in a format known only to that device, you can use blitting functions--such as BitBlt and StretchBlt--to render a DDB only to the device with which the DDB is compatible.
This limitation is documented by Microsoft in the following Knowledge Base article: Q195830-INFO: Blitting Between DCs for Different Devices Is Unsupported.
See http://support.microsoft.com/kb/133275/en-us.
|
|
|
|
 |
|
 |
Is the page routed to the physical priner, as soon as I do a StartPage?
I would like to be able to create the entire spool, but before sending the EndDoc, prompting the User for confirmation.
If they decline, I would like to flush the printer.
I thought I could flush the entire print report by issuing an AbortDoc.
Perhaps I am mistaken?
.......Cameron
|
|
|
|
 |
|
 |
hello
I am using automation to open existing microsoft office document (MS word ,MS excel,MS powerpoint) in document view application.
I want to print this document to a file instead of a real printer so that i can further read and process the file .
I might have to use virtul printer , how can i code virtual
printer .Can i find source code fro virtual printer..?
Does any one have any ideas regarding it.
Thank you
Anup
|
|
|
|
 |
|
 |
My image size is bigger then the selected page size. I want to print in tile pages means some part in one page other part in other pages. Please suggest me some idea.
s.k. Patel
|
|
|
|
 |
|
 |
I found that this source have printing bug for total pages.
I modified this section.
==>
/********************************************************************************/
int total_row_pages = (bmpHeight * ratio_y + paper_height -1 ) / paper_height;
/*********************************************************************************/
int i = 0;
int j = 0;
for(j = 0; j < total_row_pages; j ++)
{
for(i = 0; i < total_pages; i++)
{
prtDC.StartPage();
strPageNumber.Format("Page:%d of %d", ++printed_pages, total_pages * total_row_pages);
if ( i == (total_pages - 1) && total_pages > 1 ) //last page
{
int last_bmpWidth = bmpWidth - paper_width / ratio_x * i;
prtDC.StretchBlt(0, 0, last_bmpWidth * ratio_x, bmpHeight* ratio_y, &memDC,
paper_width * i / ratio_x, (j * paper_height / ratio_y) <-- this, last_bmpWidth, bmpHeight, SRCCOPY);
}
else
prtDC.StretchBlt(0, 0, paper_width, bmpHeight* ratio_y, &memDC,
paper_width * i / ratio_x,(j * paper_height / ratio_y) <-- this, paper_width / ratio_x , bmpHeight, SRCCOPY);
prtDC.TextOut(page_info_rect.left, page_info_rect.top, strPageNumber );
prtDC.EndPage();
}
i = 0;
}
|
|
|
|
 |
|
 |
If im trying to print a BMP larger than the page size could sme one tell me the exact scaling method so that
1-the BMP is scaled to fit into a single page
2-The BMP is scaled without any distortion.
Im using stretchBlt without much sucess in proper scaling presently
please advise
fordge
|
|
|
|
 |
|
 |
I have made an application using Dialog Boxes. I want to add a printing feature
to print the whole Dialog Box.
Can u help me in this?
my email x.i.peng@163.com
|
|
|
|
 |
|
 |
After having problems printing to HP printers with my software, i though i'd try a clean project with your code.
So I tried this code out on several printers in my office.
Xerox Inkjet
Epson Inket
Brother Laser
HP 940c
They all work 100% apart from the HP
The HP does print the correct number of pages, BUT where the elipse data should be, it's all garbled, like it's just printing out a load of rubbish. very very strange.
heres a picture of what it looks like in the print preview (same on the printer itself):
http://www.duncanweir.co.uk/win_me.jpg[^]
and here is what happens with XP ... which is fine :
http://www.duncanweir.co.uk/win_xp.jpg[^]
If you want to alter/debug the project here is the code:
http://www.duncanweir.co.uk/testprintingbitmaps.zip[^]
Other tests reveal, that the 940 works if i print from XP and NT, but it doesn't if I print from 98, 98SE and ME (i've not tried 95).
So at least i know it's not just my software that has a problem
Now if you want to try this out, download the HP940c driver, and turn on the HP print preview, because it shows exactly the problem, before the data is sent on to the printer.
We have the same problem printing to other HP printers at our customers, including a 950 and a Laserjet 5000.
Anyone else come across this problem with HP printers ? and what can i do to resolve it ?
ScorpioMidget
|
|
|
|
 |
|
 |
Found the problem
I wasn't clearing the memdc before drawing to it
just needed a bitblt with Whiteness
ScorpioMidget
|
|
|
|
 |
|
 |
I also had the same problem. The solution is to fill the Printer's DC with white. (Use GetdeviceCaps() to get width & height)
Its work for me in any project.
Hope its helped.
|
|
|
|
 |
|
 |
Well, i understood your way to troubleshoot this big problem but i don't get same result as you.
I develop and maintain a geotechnic software but the parallel (and USB port) printing routine is not supported on windows 9.x OS. I obtain many windows crashes when i try to print,localizing problems with HP3120.DRV(Printer Driver for HP 1200 Laserjet). I tried many odd-technical tips (from this site)without succeeding.
Can i obtain some guidelines from you, about "The solution is to fill the Printer's DC with white"?
What did you exactly wrote? and where(On PrepareDC,OnBeginPrinting or OnDraw)
pDC->BitBLt(?,...,WHITENESS);
Thanks for advance,Oliver.
Le Grand Manitou
|
|
|
|
 |
|
 |
I got bitmap printing working in a MFC Dialog
BUT only when Dynamic Linked
ie if "use MFC in a Static Library" then the Print function
charges ahead with no errors and prints nothing...
Doubtless I will fix this with some obscure switch, but really... why should I have to wade thru this...
(I have only recently started MFC C++, if I had started in the early 90's I might have paid for a house by now, but then I might be on major tranks in a jacket with those really long arms...)
FLASH! Roundup the Usual Suspects: Disable Compiler Optimisations and Uncheck "Generate Browse Info" (Used by passing GNUs?) and Static Link Prints OK
(Here In Australia we are already in 02/02/02)
Full Details at
http://www.codeguru.com/mfc/comments/2507.shtml?0.1829833984375
cts
|
|
|
|
 |
|
 |
I've pretty much lifted this code and it works great in my project when printing to 3 of 4 color printers. I'm trying to print a bitmap stored in my resource file and on one of my test printers, the image prints out in black & white. If I print the same bitmap to that same printer using Adobe Photoshop, the image prints in color. Any ideas on what Photoshop could be doing differently to get the bitmap to print in color on this particular printer (the printer is a Persona C11, a card printer)?
|
|
|
|
 |
|
 |
I'm about to pull my hair out.
I used your code, and I got it to print an ellipse (like in the source), but I have a bitmap file that I need to print to the printer.
I have the printing part down, I just need to get the Bitmap loaded into the CBitmap Object.
When I do:
background->LoadBitmap(IDB_GIFTCERT);
CBitmap * pOldBitmap = (CBitmap *) memDC.SelectObject( background );
instead of
background->CreateCompatibleBitmap(&dc, bmpWidth, bmpHeight);
CBitmap * pOldBitmap = (CBitmap *) memDC.SelectObject( background );
then pOldBitmap ends up being NULL every time.
Help?
|
|
|
|
 |
|
 |
give all details about priting a bitmap from file.
ramki
|
|
|
|
 |
|
 |
I find it not work properly too. but if you adust the bitmap's scale,(such as bmpWidth=1200,bmpHeigh=600)then you select your bitmap into DC,you will find the printer work now.but if you adust bmpWidth=800,bmpHeigh=600,you will find it won't work. and if you print a photo,the print effect is very bad,but the same if use acdsee or photoshop the effect is very good. it's very confused.
and use this method i don't know how to control dpi. could anyone help me?
|
|
|
|
 |
|
 |
Instead of using :
background->LoadBitmap(IDB_GIFTCERT);
Try using :
background->LoadBitmap((MAKEINTRESOURCE)IDB_GIFTCERT);
NOTE: The bitmap resource should be part of ur resource file (*.res) and included in ur project..
Hope it helps...
|
|
|
|
 |
|
 |
Hi,
you've got the same problem as I had.
But I found a solution.
CBitmap bitmapResource;
bitmapResource.LoadBitmap(IDB_BITMAP_MEYERMOTOREN_DRUCK);
BITMAP bmResource;
bitmapResource.GetBitmap(&bmResource);
CClientDC dc(m_pParent);
CDC memClientDC;
memClientDC.CreateCompatibleDC(&dc);
CBitmap *pOldBitmapResource = (CBitmap *)memClientDC.SelectObject(bitmapResource);
if (pOldBitmapResource == NULL)
{
memClientDC.DeleteDC();
return ;
}
CDC memPrinterDC;
memPrinterDC.CreateCompatibleDC(&m_dc);
CBitmap bitmapPrinter;
bitmapPrinter.CreateCompatibleBitmap(&memPrinterDC, bmResource.bmWidth, bmResource.bmHeight);
CBitmap *pOldBitmapPrinter = (CBitmap *) memPrinterDC.SelectObject(bitmapPrinter);
if (pOldBitmapPrinter == NULL)
{
memClientDC.DeleteDC();
memPrinterDC.DeleteDC();
return ;
}
memPrinterDC.BitBlt(0,0,bmResource.bmWidth, bmResource.bmHeight, &memClientDC, 0,0, SRCCOPY);
m_dc.StretchBlt(*left, *top, bmResource.bmWidth, bmResource.bmHeight, &memPrinterDC, 0, 0, bmResource.bmWidth, bmResource.bmHeight, SRCCOPY);
|
|
|
|
 |
|
 |
Hi there!
The only way I could correctly print a BMP in an application that doesn't support Doc/View was to convert the BMP into a DIB, and after that it was possible to copy it on any Device Context (including the printer's DC). If you don't do this, you can at most obtaint a very small copy of the bitmap on the paper (due to the higher resolution of the printer).
Here is how I did it after 2 days of research...
CBitmap bmp;
bmp.LoadBitmap(IDB_LOGO_BMP); // resource bitmap
BITMAP bm;
bmp.GetBitmap(&bm);
// taken from a Microsoft tehnical article
BITMAPINFOHEADER bmi;
bmi.biSize = sizeof(BITMAPINFOHEADER);
bmi.biWidth = bm.bmWidth;
bmi.biHeight = bm.bmHeight;
bmi.biPlanes = 1;
bmi.biBitCount = bm.bmPlanes * bm.bmBitsPixel;
if (bmi.biBitCount <= 1)
bmi.biBitCount = 1;
else if (bmi.biBitCount <= 4)
bmi.biBitCount = 4;
else if (bmi.biBitCount <= 8)
bmi.biBitCount = 8;
else
bmi.biBitCount = 24;
bmi.biCompression = BI_RGB;
bmi.biSizeImage = 0;
bmi.biXPelsPerMeter = 0;
bmi.biYPelsPerMeter = 0;
bmi.biClrUsed = 0;
bmi.biClrImportant = 0;
BITMAPINFO bmInfo;
bmInfo.bmiHeader = bmi;
::GetDIBits(GetDC()->m_hDC, (HBITMAP)bmp, 0, bm.bmHeight, NULL, &bmInfo, DIB_RGB_COLORS);
LPBYTE buf;
if(bmInfo.bmiHeader.biSizeImage == 0)
buf = new BYTE[((((bmInfo.bmiHeader.biWidth * bmInfo.bmiHeader.biBitCount) + 31) & ~31) >> 3) * bmInfo.bmiHeader.biHeight];
else
buf = new BYTE[bmInfo.bmiHeader.biSizeImage];
::GetDIBits(GetDC()->m_hDC, (HBITMAP)bmp, 0, bm.bmHeight, (LPVOID)buf, &bmInfo, DIB_RGB_COLORS);
// here I stretch the bitmap onto the printer's DC
::StretchDIBits(dc.m_hDC, x, y, dx, dy, 0, 0, bm.bmWidth, bm.bmHeight, (LPVOID)buf, &bmInfo, DIB_RGB_COLORS, SRCCOPY);
delete[] buf;
That's it. I hope it helps!
|
|
|
|
 |
|
 |
It really helped. A million thanks..
Vini
|
|
|
|
 |
|
 |
You can't print to a network printer (or most others) using that code. To print graphics you MUST use DIB bitmaps. It's tricky.
Scott
|
|
|
|
 |
|
 |
yes, that's right !!!
thanks.
I have replace the stretchBlt function by the following code ( took from
http://www.codeproject.com/treectrl/prttview.asp )
// Enlarge and print the Bitmap
//copy the bitmap (Device dependant bitmap or DDB)
//to a Device indepedant bitmap (DIB)
CPalette pal;
HANDLE hDIB = DDBToDIB(bitmap, BI_RGB, &pal );
LPBITMAPINFOHEADER lpbi;
lpbi = (LPBITMAPINFOHEADER)hDIB;
int nColors = lpbi->biClrUsed ? lpbi->biClrUsed : 1 << lpbi->biBitCount;
BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB;
LPVOID lpDIBBits;
if( bmInfo.bmiHeader.biBitCount > 8 )
lpDIBBits = (LPVOID)((LPDWORD)(bmInfo.bmiColors +
bmInfo.bmiHeader.biClrUsed) +
((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
else
lpDIBBits = (LPVOID)(bmInfo.bmiColors + nColors);
HDC hDC = dcPrinter.GetSafeHdc();
//copy de DIB to the printer device
//I use DIB rather than DDB because DDB can
//have an unpredicable behavior with network printer !!!!!
if ( StretchDIBits(
hDC, // hDC
0, // DestX
0, // DestY
zoom*DlgSize.right, // nDestWidth
zoom*DlgSize.bottom, // nDestHeight
0, // SrcX
0, // SrcY
DlgSize.right, // wSrcWidth
DlgSize.bottom, // wSrcHeight
lpDIBBits, // lpBits
&bmInfo, // lpBitsInfo
DIB_RGB_COLORS, // wUsage
SRCCOPY) // dwROP
== GDI_ERROR
)
{
ERR(DIALOG_ERROR_STRETCH_BITMAP);
return (int)DIALOG_ERROR_STRETCH_BITMAP;
}
The DDBToDIB function is defined at http://www.codeguru.com/bitmap/ddb_to_dib.shtml
|
|
|
|
 |
|
 |
Is that the same reason it doesn't work on several HP printers i've tested it on ?
And if so, why does it work on other inkjet's / lasers like Epson and Brother ?
Be interested to know the WHY
ScorpioMidget
|
|
|
|
 |
|
 |
Found the problem
I wasn't clearing the memdc before drawing to it
just needed a bitblt with Whiteness
ScorpioMidget
|
|
|
|
 |
|
 |
This is a good overview of printing and some extended features for bitmap printing !
Question, could you implement the code for a resource bitmap
or an external bitmap file print job?
|
|
|
|
 |