Click here to Skip to main content
13,141,157 members (52,985 online)
Rate this:
Please Sign up or sign in to vote.
I was wondering if there is a way to get data directly from graphic port in c# or c++? Like what we do with serial ports(we can open serial ports and read data from it).
Posted 11-Nov-12 1:01am
Richard MacCutchan 11-Nov-12 7:05am
The short answer is: Yes. The longer answer is: you need to use the details of the cable type and channel protocol to get the data and interpret it.
mehdi_k 11-Nov-12 9:32am
a normal graphic port uses a serial port, so is it the same way we use for other serial ports? would you explain more and give a code sample. Thanks.
Richard MacCutchan 11-Nov-12 9:35am
I don't have any more information on this, you need to do some research for yourself.
mehdi_k 11-Nov-12 15:27pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you're talking about the port you plug your monitor into, you do NOT treat it the same way you treat a serial port. The same code will not work.

What are you trying to do with this??
mehdi_k 11-Nov-12 15:24pm
That is exactly what I'm trying to do, I want to get data from the port that I plug my monitor into, see if my monitor gets it and shows me as images I want to get them directly from the port in my for example c# app.
Please help.
Dave Kreskowiak 11-Nov-12 16:20pm
Not going to happen.

You really don't understand how this works. You can get a little information FROM the monitor, such as its capabilities and make/model/sn, but you cannot send it commands and it will not send you the image being displayed or any part of it.

The port you plug the monitor into is not exposed like the Serial Port is. It doesn't even work anywhere close to the same way. You cannot just "open a port" and start talking to it. It's nowhere near that simple.

Talking to the monitor is only done through the video driver, and what is exposed to your code is very limited in capbility to keep the monitor in a known state so the video driver can maintain control of it.

The onyl way you're going to get more capability is if you wrote your own video driver. From the sounds of things, that is VERY FAR over your head.
mehdi_k 12-Nov-12 5:26am
Yeah I thought so, but the data that comes through the port is already processed by Graphic card and it's driver so no need to write a driver(witch is VERY FAR over my head!). so the thing is how to communicate to port and get the data(that has been already processed), and the next thing is to translate the data to what you want(for example an image).
Anyway, Thanks for your time.
Dave Kreskowiak 12-Nov-12 8:19am
You're not getting it. You're not going to talk to the port. You talk to the video driver.

Also, getting the image that's displayed is more than a bit tricky. For example, if you think you're going to get the image of a DVD playing in a window, you're mistaken. The channel is protected for copyright reasons.

You won't get back any image data from the monitor at all, and only partially from the video driver.

I have no idea what the ultimate goal of doing this is, so....
mehdi_k 13-Nov-12 8:08am
if you want to know the goal:
a few ago I tried to get the image of a game, but I couldn't do that with print screen, so I tried to use directx in a c# app, but I needed to get image of back buffer in order to get the image of the game that was playing because the front buffer has the desktop image. in nobody knows reason :
I couldn't do that too.
so I thought maybe in this way I'd be able to do that witch so far...
Dave Kreskowiak 13-Nov-12 18:52pm
Print screen or screen shots don't work because the common methods to capture an image only work with windows with handles. DirectX games don't follow Windows normal rendering pipline, so can't be captured with these methods.

You have to use DirectX to get at the image, such as in
mehdi_k 14-Nov-12 16:22pm
Yes I know that, and I have tried.
Did you see :
didn't work!!!
Dave Kreskowiak 14-Nov-12 16:25pm
Nope, 'cause I don't read every frickin message on the site.

That's how it has to be done. "Doesn't work" doesn't tell anyone anything useful to be able to help you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 11 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100