Click here to Skip to main content
15,890,717 members
Home / Discussions / C#
   

C#

 
GeneralRe: Listview and tooltip popup for each cell? Pin
DaveyM6928-Feb-09 2:58
professionalDaveyM6928-Feb-09 2:58 
QuestionDesktop Calander [modified] Pin
WinSolution28-Feb-09 1:17
WinSolution28-Feb-09 1:17 
AnswerRe: Desktop Calander Pin
Searril28-Feb-09 4:34
Searril28-Feb-09 4:34 
GeneralRe: Desktop Calander Pin
Jaiprakash M Bankolli28-Feb-09 6:18
Jaiprakash M Bankolli28-Feb-09 6:18 
GeneralRe: Desktop Calander Pin
WinSolution28-Feb-09 6:49
WinSolution28-Feb-09 6:49 
QuestionHow To Get Local Printer status Pin
naeemnimi28-Feb-09 1:14
naeemnimi28-Feb-09 1:14 
AnswerRe: How To Get Local Printer status Pin
Philip.F28-Feb-09 5:44
Philip.F28-Feb-09 5:44 
QuestionTaking a Screenshot - but with performance :( Pin
prattel28-Feb-09 0:46
prattel28-Feb-09 0:46 
Hi there,

I'm trying to read a few pixels (200) from my screen, repeatedly. Though what I have found is that
1) the Graphics method CopyFromScreen() has quite a high overhead. Whether I read 1 pixel or 1000 doesn't matter. It's always 33ms, and it doesn't even matter if I keep creating new Bitmap / Graphics objects or reuse the old ones.
2) unmanaged GDI32.BitBlt has exactly the same problem, even if I reuse all hDCs.

So, my question is, is there a fast way to obtain a few pixels from the screen? I already thought about using Direct3d, but I fail using it - and I don't even know if that would perform any better. It keeps throwing a BadImageFormatException at me, and says it's not a Win32 application (Exception from hResult: 0x800700C1). Btw, I don't even want to save to HD. I just want the raw pixels in memory to play around with them. The stuff below was just taken from an example I found.

That's the code I tried to use:
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = false;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.PresentFlag = PresentFlag.LockableBackBuffer;
presentParams.BackBufferWidth = 1280;
presentParams.BackBufferHeight = 1024;
presentParams.MultiSample = MultiSampleType.None;
presentParams.DeviceWindowHandle = User32.GetDesktopWindow();

Device device = new Device(0, DeviceType.Hardware, User32.GetDesktopWindow(), CreateFlags.HardwareVertexProcessing, presentParams);
Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer);
backbuffer.Dispose();


Any hints on a quicker way to read a few pixels, all in one horizontal line, would be appreciated Smile | :)
AnswerRe: Taking a Screenshot - but with performance :( Pin
PIEBALDconsult28-Feb-09 3:43
mvePIEBALDconsult28-Feb-09 3:43 
GeneralRe: Taking a Screenshot - but with performance :( Pin
prattel28-Feb-09 3:45
prattel28-Feb-09 3:45 
Questiontriplets extraction from sentence Pin
kinno27-Feb-09 21:59
kinno27-Feb-09 21:59 
AnswerRe: triplets extraction from sentence Pin
dan!sh 27-Feb-09 22:06
professional dan!sh 27-Feb-09 22:06 
Questionasp controls in web application Pin
Zeyad Jalil27-Feb-09 21:47
professionalZeyad Jalil27-Feb-09 21:47 
AnswerRe: asp controls in web application [modified] Pin
dan!sh 27-Feb-09 21:50
professional dan!sh 27-Feb-09 21:50 
GeneralRe: asp controls in web application Pin
Zeyad Jalil27-Feb-09 22:10
professionalZeyad Jalil27-Feb-09 22:10 
GeneralRe: asp controls in web application Pin
dan!sh 27-Feb-09 22:14
professional dan!sh 27-Feb-09 22:14 
AnswerRe: asp controls in web application Pin
Calin Tatar28-Feb-09 0:34
Calin Tatar28-Feb-09 0:34 
QuestionBHO and cookies ? Pin
tsahiB27-Feb-09 21:24
tsahiB27-Feb-09 21:24 
QuestionLooking for tips & tricks Pin
E_Gold27-Feb-09 20:08
E_Gold27-Feb-09 20:08 
AnswerRe: Looking for tips & tricks Pin
Abhijit Jana27-Feb-09 20:42
professionalAbhijit Jana27-Feb-09 20:42 
GeneralRe: Looking for tips & tricks Pin
E_Gold27-Feb-09 21:14
E_Gold27-Feb-09 21:14 
AnswerRe: Looking for tips & tricks Pin
Eddy Vluggen27-Feb-09 22:31
professionalEddy Vluggen27-Feb-09 22:31 
QuestionProblem with Generic Collection and Interface Pin
_ro_bb_o27-Feb-09 19:06
_ro_bb_o27-Feb-09 19:06 
AnswerRe: Problem with Generic Collection and Interface Pin
DaveyM6928-Feb-09 2:40
professionalDaveyM6928-Feb-09 2:40 
QuestionReading a Packet assistance Pin
Andrew Timmins27-Feb-09 18:46
Andrew Timmins27-Feb-09 18:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.