Discussion:
Printing DirectX graphics output in VB.net
(too old to reply)
Tracks
2006-08-04 15:29:02 UTC
Permalink
I am sending graphics to a directx device and drawing 3d on the screen. Now I
want to be able to send this to the printer. Need an example of how to make
the printer the directx device instead of the screen. I would like to just
use the same code maybe. I create the screen device:

device = New Device(0, DeviceType.Hardware, WinHandle,
CreateFlags.SoftwareVertexProcessing, presentParams) 'Create a device

where Winhandle is the Form.Handle. can I just send the printer handle? Im
sure there is more to it? I need a detailed example in VB.net.

I want to send the graphics, not just print the screen bitmap, so I get
better resolution/quality.

Thanks,

Tom
Wessam Bahnassi
2006-08-04 19:07:33 UTC
Permalink
You can't do that. You'll have to draw your scene to a print-resolution
frame buffer with D3D, then grab the bitmap data from there and send it to
the printer through GDI+.
--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
Post by Tracks
I am sending graphics to a directx device and drawing 3d on the screen. Now I
want to be able to send this to the printer. Need an example of how to make
the printer the directx device instead of the screen. I would like to just
device = New Device(0, DeviceType.Hardware, WinHandle,
CreateFlags.SoftwareVertexProcessing, presentParams) 'Create a device
where Winhandle is the Form.Handle. can I just send the printer handle? Im
sure there is more to it? I need a detailed example in VB.net.
I want to send the graphics, not just print the screen bitmap, so I get
better resolution/quality.
Thanks,
Tom
Tracks
2006-08-04 23:11:02 UTC
Permalink
Hmm, that is what I was afraid of. Got your ears on MS?

I realize that printing in a high speed rendering loop does not make much
sense, but I just use the 3d engine in directx to show a 3d landscape model
on the screen. After the user moves the scene around to just the right spot,
click the print button and whalaa, the fixed scence prints in higher quality
than stretch blitting a screen capture onto an 8.5 x 11.

I am just now getting my life long dream of truely printing from the same
code that I draw to the screen with, in 2d GDI using vb.net. Thanks MS! Now I
want to print my 3d graphics!!!!!!!!!!!!!
Post by Wessam Bahnassi
You can't do that. You'll have to draw your scene to a print-resolution
frame buffer with D3D, then grab the bitmap data from there and send it to
the printer through GDI+.
--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
Post by Tracks
I am sending graphics to a directx device and drawing 3d on the screen. Now I
want to be able to send this to the printer. Need an example of how to make
the printer the directx device instead of the screen. I would like to just
device = New Device(0, DeviceType.Hardware, WinHandle,
CreateFlags.SoftwareVertexProcessing, presentParams) 'Create a device
where Winhandle is the Form.Handle. can I just send the printer handle? Im
sure there is more to it? I need a detailed example in VB.net.
I want to send the graphics, not just print the screen bitmap, so I get
better resolution/quality.
Thanks,
Tom
legalize+ (Richard [Microsoft Direct3D MVP])
2006-08-05 00:07:59 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by Tracks
Hmm, that is what I was afraid of. Got your ears on MS?
You might be able to do this in Vista, but DirectX was intentionally
created as "a path to the hardware that doesn't go through GDI", so
that you can't create a device on GDI printer handle is no surprise.

DirectX takes GDI out of the picture. On purpose.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>
Pilgrimage 2006, Saturday September 23rd: <http://pilgrimage.scene.org>
North America's Longest Running Demoparty
Wessam Bahnassi
2006-08-05 04:09:04 UTC
Permalink
I don't see what really prevents you from taking a hi-res screenshot during
your D3D app's operation.
We do that all the time for generating print-resolution images for magazine
reviews and stuff.
It can be as easy as allocating a new big render-target (if 4kx4k is enough
for you) and rendering over that instead of the conventional "72dpi"
backbuffer. Or you can go with a generic solution as rendering your scene in
partitions then stitching these partitions together, and this technique is
covered in several texts (e.g. Game Programming Gems).
--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
--
In|Structurez Arabic Gamedev Community
www.instructurez.com
Post by Tracks
Hmm, that is what I was afraid of. Got your ears on MS?
I realize that printing in a high speed rendering loop does not make much
sense, but I just use the 3d engine in directx to show a 3d landscape model
on the screen. After the user moves the scene around to just the right spot,
click the print button and whalaa, the fixed scence prints in higher quality
than stretch blitting a screen capture onto an 8.5 x 11.
I am just now getting my life long dream of truely printing from the same
code that I draw to the screen with, in 2d GDI using vb.net. Thanks MS! Now I
want to print my 3d graphics!!!!!!!!!!!!!
Post by Wessam Bahnassi
You can't do that. You'll have to draw your scene to a print-resolution
frame buffer with D3D, then grab the bitmap data from there and send it to
the printer through GDI+.
--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
Post by Tracks
I am sending graphics to a directx device and drawing 3d on the screen.
Now
I
want to be able to send this to the printer. Need an example of how to make
the printer the directx device instead of the screen. I would like to just
device = New Device(0, DeviceType.Hardware, WinHandle,
CreateFlags.SoftwareVertexProcessing, presentParams) 'Create a device
where Winhandle is the Form.Handle. can I just send the printer handle? Im
sure there is more to it? I need a detailed example in VB.net.
I want to send the graphics, not just print the screen bitmap, so I get
better resolution/quality.
Thanks,
Tom
Tracks
2006-08-05 13:15:01 UTC
Permalink
Yeah, I guess that is the approach. Try to create a directx device with dots
equal to the printer dpi x paper size and then blt that to the printer. Not
saying I know how, or that it can be done. I'm no expert.

If anyone has sample code for this that would be helpful?

Its just easier using the VB printer object and sending it vector graphics
direct (ie line (x,y,x2,y2) ) and letting the system/printer turn that into
whatever printer dpi raster image. I get beautiful 2d plan view printouts of
my terrain that way now from the GDI or whereever it comes from. And now in
vb.net I actually do it with the same code (screen or printer use same code I
mean just send the code the e args for whatever)! In vb past there was always
something that required all special code for the printer.

Again, I only need directx for the 3d engine that lets me send it 3d
triangles and then it creates the 2d image for me - much faster and better
quality/features than my old vb code where I did it myself.
Post by Wessam Bahnassi
I don't see what really prevents you from taking a hi-res screenshot during
your D3D app's operation.
We do that all the time for generating print-resolution images for magazine
reviews and stuff.
It can be as easy as allocating a new big render-target (if 4kx4k is enough
for you) and rendering over that instead of the conventional "72dpi"
backbuffer. Or you can go with a generic solution as rendering your scene in
partitions then stitching these partitions together, and this technique is
covered in several texts (e.g. Game Programming Gems).
--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
--
In|Structurez Arabic Gamedev Community
www.instructurez.com
Post by Tracks
Hmm, that is what I was afraid of. Got your ears on MS?
I realize that printing in a high speed rendering loop does not make much
sense, but I just use the 3d engine in directx to show a 3d landscape model
on the screen. After the user moves the scene around to just the right spot,
click the print button and whalaa, the fixed scence prints in higher quality
than stretch blitting a screen capture onto an 8.5 x 11.
I am just now getting my life long dream of truely printing from the same
code that I draw to the screen with, in 2d GDI using vb.net. Thanks MS! Now I
want to print my 3d graphics!!!!!!!!!!!!!
Post by Wessam Bahnassi
You can't do that. You'll have to draw your scene to a print-resolution
frame buffer with D3D, then grab the bitmap data from there and send it to
the printer through GDI+.
--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
Post by Tracks
I am sending graphics to a directx device and drawing 3d on the screen.
Now
I
want to be able to send this to the printer. Need an example of how to make
the printer the directx device instead of the screen. I would like to just
device = New Device(0, DeviceType.Hardware, WinHandle,
CreateFlags.SoftwareVertexProcessing, presentParams) 'Create a device
where Winhandle is the Form.Handle. can I just send the printer handle? Im
sure there is more to it? I need a detailed example in VB.net.
I want to send the graphics, not just print the screen bitmap, so I get
better resolution/quality.
Thanks,
Tom
Loading...