For both X and GDI - copy a section of the destop?

In C, how can I ask my desktop to give me a BMP-ish rendition of what it would display at X[sub]0[/sub],Y[sub]0[/sub] - X[sub]1[/sub],Y[sub]1[/sub] if nothing else were there? IE - ask for what portion of the background image & icons would be displayed at pixels 100,100 - 500,500 of a 1024x768 desktop?

I’m a newbie/unskilled C programmer, trying to write a silly little application that simulates a transparent / translucent background. I’m confident that I can write everything else (given a little time and effort), but damned if I can’t figure out how to ask either windows system for a simple array of pixels. It doesn’t seem to be a commonly-asked question, cause I can’t find any answers on the ol’ inter-web either.

Thanks and pie :slight_smile:

I suspect you’ll find that, when writing Windows apps, you’ll be spending a lot more time digging through the Win32 API or some framework layer written on top of it (like OWL or MFC) than you will learning C/C++. The language is simple compared to the API.

Windows doesn’t like to deal with a “simple array of pixels,” so maybe that’s part of what’s slowing down your search. You’ll have to use some species of BITMAP structure, which you most likely won’t want to manipulate directly, since its format depends on the device it’s indended for display on. You’ll want to use the GDI functions for virtually any manipulations you have in mind.

I’m pretty sure you’ll want to start with GetDesktopWindow(), then copy the contents of that window into a BITMAP. Here’s an article about capturing the contents of any window into a .BMP file, which is close to what you’re after.

Sorry if this comes off as pedantic or condescending; I’m just not sure how much you know already.

I know little, and what little I know is, I’m sure, full of holes. So condescend away! I did some hunting around at MSDN (thanks!).

Now I think I can at least grab some pixels from the desktop. I read the article you linked, and WOW - that’s not light reading!! I’m going to have to dig into that some more. Obviously, it bears much more analysis, but I’m thrilled that I have somewhere to start.

Anyone want to chime in on the X side? I’m all about trying to program in two dense APIs without a good knowledge of either :wink: Well, at least I’d like a place to start once I get the MS-version working.

Thanks again!

I guess I could mention that I plan to wrap both up into something SDL friendly and a few #ifdef statements to compile. I’m not really trying to learn Windows AND X programming at the same time, I just need a little of each.