Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating and Printing a Bitmap from a Dialog

Posted on 1998-07-17
3
Medium Priority
?
256 Views
Last Modified: 2013-11-20
I was handed down a CDialog based program. This program does all sorts of graphing, and just doodles all over the dialog area (using SetPixelV, LineTo, etc). What I want to do is know the most efficient code for extracting a rectangular region of pixels from the dialog area, and spooling them out to the printer so that it fills exactly the entire page no matter what printer I am on.

Example to make myself more clear:
There is a dialog box. There are no controls or buttons or anything on it whatsoever. Some stuff was doodled onto it.
The dialog boxes coordinates are (0,0 to 400,400)
I want to extract a (50,50 to 200,200) rect from the dialog box and send it to the printer in such a way that it always fills one full piece of paper.

How do I accomplish this the best possible way?
Thanks in advance.
0
Comment
Question by:lesinsm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 90 total points
ID: 1319381
The easieast way is to stretch dialog area giving dialog window HDC directly to printer DC with StrechBlt. The problem can be if dialog area contains color graphics. In this case you should copy dialog area into compatible bitmap selected into memory DC, then convert this memory DDB into 24 bit DIB and only then send this DIB to printer with StretchDIBits. In this case printer will perform the best dithering.
0
 

Author Comment

by:lesinsm
ID: 1319382
How do you convert the memory from DDB into 24-bit DIB?
Thanks, Galkin!
0
 
LVL 7

Expert Comment

by:galkin
ID: 1319383
It is not trivial task. You cannot use any of syetm DIB API since they are dealing with HDC but you cannot use printer DC as b/w printer contains only two colows. so if you try to convert other then two colow bitmap any function will fail. you will have to allocate memory block 3 * height * width bytes in heap with GlobalAlloc, Then lock it with GlobalLock. Then directly set RGB value for each bits in this memory block. handle to this memory is your DIB handle. you can use StretchDIBits to send this DIB to the printer.
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

661 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