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. printing a graphic

printing a graphic

Scheduled Pinned Locked Moved C / C++ / MFC
c++comgraphicshelptutorial
3 Posts 3 Posters 2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    This may have been covered in a previous post, but I don't know because there are just too many previous posts to wade through. I am trying to print a bitmap graphic that is generated from data. It is in a view, so currently I am just printing the view using the whole doc/view printing made easy functions. Actually, I didn't even have to do any programming at all because somehow it was all set up pretty well already just by the MFC standards. Only I have two imposing problems: 1) My bitmap's y axis is reversed or something, because it isn't just printed upside-down, it is printed with the entire y-axis completely reversed, but the x-axis normal. So my graphic is innacurate. 2) My bitmap is being printed really tiny, which makes it hard to see. Because it is generated from data, it needs to be able to be seen clearly. So can anyone help me flip the y-axis and enlarge it when it gets printed but leave my view as it currently is (unflipped and not enlarged)? I can't seem to find any useful information on how to do either, because I'm not working with text. Any help would be appreciated. If you would like to email me, you can do so at: ALeonard@bruker-axs.com

    D 1 Reply Last reply
    0
    • L Lost User

      This may have been covered in a previous post, but I don't know because there are just too many previous posts to wade through. I am trying to print a bitmap graphic that is generated from data. It is in a view, so currently I am just printing the view using the whole doc/view printing made easy functions. Actually, I didn't even have to do any programming at all because somehow it was all set up pretty well already just by the MFC standards. Only I have two imposing problems: 1) My bitmap's y axis is reversed or something, because it isn't just printed upside-down, it is printed with the entire y-axis completely reversed, but the x-axis normal. So my graphic is innacurate. 2) My bitmap is being printed really tiny, which makes it hard to see. Because it is generated from data, it needs to be able to be seen clearly. So can anyone help me flip the y-axis and enlarge it when it gets printed but leave my view as it currently is (unflipped and not enlarged)? I can't seem to find any useful information on how to do either, because I'm not working with text. Any help would be appreciated. If you would like to email me, you can do so at: ALeonard@bruker-axs.com

      D Offline
      D Offline
      Derek
      wrote on last edited by
      #2

      get the picture into a DC.. then use some code like this... CPrintDialog printdlg(false, NULL); // instantiate the printer dialog if (printdlg.DoModal() != IDOK) // show the printer setup dialog return; CDC srcDC; // this needs to be the image HDC hDC = printdlg.GetPrinterDC(); // get a DC to the printer CDC pDC; pDC.Attach(hDC); // attach the printer dc to a CDC pDC.StartDoc("printing"); // start the document pDC.StartPage("page 1"); // start the current page int width = 500 // image width int height // image height // this next function will stretch the image to full size (as it is displayed)... pDC.StretchBlt(0, 0, width * 3, height * 3, &srcDC, 0, 0, width, height, SRCCOPY); pDC.EndPage(); pDC.EndDoc(); ================== The original message was:
      This may have been covered in a previous post, but I don't know because there are just too many previous posts to wade through.

      I am trying to print a bitmap graphic that is generated from data. It is in a view, so currently I am just printing the view using the whole doc/view printing made easy functions. Actually, I didn't even have to do any programming at all because somehow it was all set up pretty well already just by the MFC standards. Only I have two imposing problems:

      1. My bitmap's y axis is reversed or something, because it isn't just printed upside-down, it is printed with the entire y-axis completely reversed, but the x-axis normal. So my graphic is innacurate.
      2. My bitmap is being printed really tiny, which makes it hard to see. Because it is generated from data, it needs to be able to be seen clearly.

      So can anyone help me flip the y-axis and enlarge it when it gets printed but leave my view as it currently is (unflipped and not enlarged)? I can't seem to find any useful information on how to do either, because I'm not working with text. Any help would be appreciated.

      If you would like to email me, you can do so at: ALeonard@bruker-axs.com

      M 1 Reply Last reply
      0
      • D Derek

        get the picture into a DC.. then use some code like this... CPrintDialog printdlg(false, NULL); // instantiate the printer dialog if (printdlg.DoModal() != IDOK) // show the printer setup dialog return; CDC srcDC; // this needs to be the image HDC hDC = printdlg.GetPrinterDC(); // get a DC to the printer CDC pDC; pDC.Attach(hDC); // attach the printer dc to a CDC pDC.StartDoc("printing"); // start the document pDC.StartPage("page 1"); // start the current page int width = 500 // image width int height // image height // this next function will stretch the image to full size (as it is displayed)... pDC.StretchBlt(0, 0, width * 3, height * 3, &srcDC, 0, 0, width, height, SRCCOPY); pDC.EndPage(); pDC.EndDoc(); ================== The original message was:
        This may have been covered in a previous post, but I don't know because there are just too many previous posts to wade through.

        I am trying to print a bitmap graphic that is generated from data. It is in a view, so currently I am just printing the view using the whole doc/view printing made easy functions. Actually, I didn't even have to do any programming at all because somehow it was all set up pretty well already just by the MFC standards. Only I have two imposing problems:

        1. My bitmap's y axis is reversed or something, because it isn't just printed upside-down, it is printed with the entire y-axis completely reversed, but the x-axis normal. So my graphic is innacurate.
        2. My bitmap is being printed really tiny, which makes it hard to see. Because it is generated from data, it needs to be able to be seen clearly.

        So can anyone help me flip the y-axis and enlarge it when it gets printed but leave my view as it currently is (unflipped and not enlarged)? I can't seem to find any useful information on how to do either, because I'm not working with text. Any help would be appreciated.

        If you would like to email me, you can do so at: ALeonard@bruker-axs.com

        M Offline
        M Offline
        Mike 0
        wrote on last edited by
        #3

        I did exactly what you have said to do here. But, apparently some printers do not support dc.StretchBlt (). They did before because my code worked for about a year. I don't know what happened but it stopped working. I am now trying as follows (with little success): HANDLE hBitamp = ::CreateCompatibleBitmap (printerDC, width, height); memDC.SelectObject (hBitmap); // do some drawing into the printerDC CBitmap it; it.Attach (hBitmap); unsigned char *bits = new unsigned char [640*480]; it.GetBitmapBits (640*480, bits); ::StretchDIBits (printerDC.GetSafeHdc (),.... bits,....); And it does most of what I want. The image is flipped about the Y axis, but that's not a problem. But, none of the line graphics appear. Any ideas? Thanks, Mike

        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