CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007
    Posts
    11

    Bitmap printing -> tiny printed picture ??

    When i call this procedure to print a bitmap loaded from a file(the bitmap is a desktop capture 1280x1024) the printed picture is much much smaller!(about 240x190)

    a sample output(print to pdf):

    Output Sample


    Code:
    void PrintBitmap() {
         CPrintDialog printDlg(FALSE);
         printDlg.GetDefaults(); 
         CDC dc;
         dc.Attach(printDlg.GetPrinterDC());
         
         // Initialise print document details
         DOCINFO di;    
         ::ZeroMemory (&di, sizeof (DOCINFO));
         di.cbSize = sizeof (DOCINFO);
         BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job 
         dc.StartPage();                      // begin new page
    
         // Get the bitmap from disk
         CBitmap bitmap;
         bitmap.Attach(::LoadImage( ::GetModuleHandle(NULL), "C:\\temp1.bmp", IMAGE_BITMAP, 0, 0, 
                                    LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE));
         CDC memDC; 
         memDC.CreateCompatibleDC(&dc);
         CBitmap *pBmp = memDC.SelectObject(&bitmap);
    
         BITMAP bm;
         bitmap.GetBitmap(&bm); // for width and height
    
         // copy to printDC
         dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
    
         memDC.SelectObject(pBmp);
    
         if (bPrintingOK)
           dc.EndDoc();         // end a print job
         else dc.AbortDoc();    // abort job. 
    }
    any ideas ?
    Last edited by Cruonit; August 9th, 2007 at 07:31 AM.

  2. #2

    Re: Bitmap printing -> tiny printed picture ??

    Are you taking into consideration that a BMP on a screen is shown at about 72 dpi, and the same BMP on a printer will be at LEAST 300 dpi? Maybe 1200 dpi?

    StretchBlt it to the actual printer DC cooridantes of the page and see it that fixes it.

  3. #3
    Join Date
    Jul 2007
    Posts
    11

    Re: Bitmap printing -> tiny printed picture ??

    thx it works !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured