Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. StretchDIBits fit into paper

StretchDIBits fit into paper

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vancouver777
    wrote on last edited by
    #1

    I would like to make my program to fit into paper when printing out. I know we should deal with that with this function but I am not sure about parameter Does anyone know what to put? BITMAPINFOHEADER *pBMI = (BITMAPINFOHEADER*)(LPVOID)lock; int nColors = 0; if( pBMI->biBitCount <= 8 ) nColors = ( 1<< pBMI->biBitCount ); if( b_PrintFit ) { ::StretchDIBits( pDC->GetSafeHdc( ), pInfo->m_rectDraw.left, pInfo->m_rectDraw.top, pBMI->biWidth, pBMI->biHeight, 0, 0, pBMI->biWidth, pBMI->biHeight, (LPBYTE)pBMI + (pBMI->biSize + nColors * sizeof(RGBQUAD)), (BITMAPINFO*)pBMI, DIB_RGB_COLORS, SRCCOPY); Thanks shin

    A 1 Reply Last reply
    0
    • V vancouver777

      I would like to make my program to fit into paper when printing out. I know we should deal with that with this function but I am not sure about parameter Does anyone know what to put? BITMAPINFOHEADER *pBMI = (BITMAPINFOHEADER*)(LPVOID)lock; int nColors = 0; if( pBMI->biBitCount <= 8 ) nColors = ( 1<< pBMI->biBitCount ); if( b_PrintFit ) { ::StretchDIBits( pDC->GetSafeHdc( ), pInfo->m_rectDraw.left, pInfo->m_rectDraw.top, pBMI->biWidth, pBMI->biHeight, 0, 0, pBMI->biWidth, pBMI->biHeight, (LPBYTE)pBMI + (pBMI->biSize + nColors * sizeof(RGBQUAD)), (BITMAPINFO*)pBMI, DIB_RGB_COLORS, SRCCOPY); Thanks shin

      A Offline
      A Offline
      Alex Dolpfin
      wrote on last edited by
      #2

      10th parameter of StretchDIBits should be a pointer to a buffer containing RGB data of bitmap you want to print. For eg. CBitmap bmp; bmp.LoadBitmap(IDB_SOMEBITMAP); BITMAP bm; bmp.GetBitmap(&bm); bm.bmBits is the pointer you need. Other parameters may be right or wrong cause I dont know what they mean in your program. By the way, for printing a bitmap you should to create a printer DC and to calculate destination rectangle with paper resolution. For more info see MSDN!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups