[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Printing to a graphics file

Posted on 2000-02-09
6
Medium Priority
?
254 Views
Last Modified: 2013-11-20
Hi,

I have an MFC application that displays a picture (scrolled), and prints it. I would like, however, to make it also create a graphics file, copy of what would be on the printer. I would also like to open this file later on and print it. What is the approach?

Thank you.
0
Comment
Question by:kerzner
  • 3
  • 2
6 Comments
 

Expert Comment

by:UandI
ID: 2506872
Try to write the information to a CMetaFileDC instead to the printer device context. With CopyMetaFile you can then write it to a file.

I suggest that you see the documentation on this and try to find sample code from MSDN.

Another way would be to transform your picture into a standard bitmap format and write it to a file with your own code. This would allow you to open the file with any graphic editor (for example paintbrush).

I hope this helps you somehow.
0
 
LVL 1

Author Comment

by:kerzner
ID: 2515651
Thank you, I would accept the answer as complete, if I knew how to form my own bitmaps.
Does anybody know a good library? Or for gif for that matter.

Sincerely yours.
0
 

Expert Comment

by:stu32934
ID: 2522285
My be completely irrelevent but anyway...I've created a gif filter. I based it on GIFLIB and attapted it to handle multiple layered gifs. Have a look at:

http://www.tuxedo.org/~esr/giflib/doc/index.html
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Accepted Solution

by:
UandI earned 400 total points
ID: 2523191
I used the following code to prepare my own bitmaps:

//Create a 24-bit-per-pixel surface
HBITMAP Create24BPPDIBSection(HDC hDC, int iWidth, int iHeight)
{
      BITMAPINFO      bmi;
      HBITMAP            hbm;
      LPBYTE            pBits;

      //Initialize to 0s
      ZeroMemory(&bmi, sizeof(bmi));

      //Initialize header
      bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
      bmi.bmiHeader.biWidth = iWidth;
      bmi.bmiHeader.biHeight = iHeight;
      bmi.bmiHeader.biPlanes = 1;
      bmi.bmiHeader.biBitCount = 24;
      bmi.bmiHeader.biCompression = BI_RGB;

      //Create the surface
      hbm = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (void**)&pBits, NULL, 0);
      return(hbm);
}

Hope it helps
0
 
LVL 1

Author Comment

by:kerzner
ID: 2523370
Thank you,

I think the gif libraries and bmp code will solve my problem completely. Of course, one has to delve in it, but if I understand correctly that I can translate my MoveTo() and LineTo() calls to the created image instead of the screen, then I would consider this questions closed.

Thanks again. Sincerely,
Mark Kerzner
0
 
LVL 1

Author Comment

by:kerzner
ID: 2523387
I had to accept only one answer as final, but I would also like to give credit to stu32934.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question