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