Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Any way to get the desktop image? | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7162/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-21-05 08:18 AM Link | Quote
I need a way to take whatever image the user currently has set for their desktop in XP, at whatever size it's being displayed at (in case it's being stretched - basically, take the image you would see if you had no taskbar, no windows and no icons) and draw various pieces of this image on device contexts. Is there a way to do this (or get the image's DC if nothing else) or do I have to manually load whatever file is being used and scale/tile it myself? (Active Desktop shouldn't be an issue; the program isn't meant to be used with one anyway.)

Also is there built-in JPEG/GIF/PNG to BMP conversion code? I noticed that when you use one of these as a desktop image, Windows just converts it to a bitmap.
Dish

Spiny
Level: 38

Posts: 580/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 09-21-05 08:35 AM Link | Quote
I've never tested this... but this looks like it might work for the desktop thing:



char buf[MAX_PATH] = "";
SystemParametersInfo( SPI_GETDESKWALLPAPER, MAX_PATH, buf, 0 );




That "Retrieves the full path of the bitmap file for the desktop wallpaper." (as quoted from MSDN). So I guess you're right about the desktop image always being a bitmap... weird.

--edit--
although... I don't know how to figure if it's tiled/stretched. Maybe that's one of the options in SystemParametersInfo .. although I didn't see one.

As for getting the display area minus the taskbar... a somewhat hackish (but pretty easy) way would be to create a maximized, invisible window and then just GetWindowRect. There's also GetSystemMetrics which can be used to get the display size... although I think it includes the taskbar.
--end edit--

--edit 2--
erm.. scratch that... just saw SPI_GETWORKAREA for SystemParametersInfo.. that looks like it'll get the display area. Still don't know about stretch/tiled/centered though...
--end edit 2--


I don't know of any jpg/gif/png loader... except for that you can load PNG files to D3D textures. Windows probably taps into Internet Explorer's image reading functions for that or something.

I'm sure there are image libraries around you can use to load such things to an HDC or whatever. Libpng is, of course, free and open source ... although it's somewhat of a pain in the ass to use. I made a kind of sloppy wrapper for it though if you're interested.

JPG/GIF might be a little tougher... since they're no longer free... you'd be hard pressed to find any open source loader you can use... but there might still be some kind of image library you can use anyway.


(edited by Disch on 09-20-05 11:39 PM)
(edited by Disch on 09-20-05 11:42 PM)
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 590/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 09-21-05 09:16 AM Link | Quote
Umm... I have no idea what you're doing, since you really didn't say, but...

If it's any help, the wallpaper info is stored in the registry. Check out HKEY_CURRENT_USER\Control Panel\Desktop

Converted Wallpaper gives the full path to the wallpaper. Then there's TileWallpaper wich seems to be set to 0 for not tiled. And last is WallpaperStyle. It seems that 0 is Center, and 2 is Stretched. It's also set to 0 if TileWallpaper is set to 1.

Anyway, not sure if that helps any, but there it is.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7175/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-21-05 04:56 PM Link | Quote
Yeah, that should help. Also, the taskbar doesn't make a difference, because the wallpaper goes under it anyway. I was just hoping I could draw directly from the buffer it uses to draw the image instead of having to locate and open it and tile/stretch it myself.
Kyoufu Kawa
I'm not bad. I'm just drawn that way.
Level: 70

Posts: 2319/2481
EXP: 3008456
For next: 7355

Since: 03-19-04
From: Catgirl Central

Since last post: 14 hours
Last activity: 13 hours
Posted on 09-22-05 12:25 AM Link | Quote
The PaintDesktop function fills the clipping region in the specified device context with the desktop pattern or wallpaper. The function is provided primarily for shell desktops.

BOOL WINAPI PaintDesktop(
HDC hdc // handle to DC
);
Parameters
hdc
[in] Handle to the device context.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/ 2000: To get extended error information, call GetLastError.

Requirements
Windows NT/2000: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7189/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-22-05 01:00 AM Link | Quote
Holy crap, that's perfect! Not only does it draw the desktop background, but it automatically accommodates for tiling/stretching and the window's position.

This is exactly what I wanted to do (sans border, but that's easy to do; I added it to show the window dimensions). Thanks man!

Interesting though, it fails if the window uses translucency... shouldn't be a problem, since I don't use it anyway, but it's kinda odd.
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 594/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 09-22-05 03:02 AM Link | Quote
Ta-da! Took three of us, but you got some useful info out of it.

Now, what, may I ask (and I'm gonna even if I may not ), are you doing?
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7199/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-22-05 06:55 AM Link | Quote
I'm planning to do something like this. That one was done with Active Desktop, using HTML, but it took up a lot of resources and wasn't very flexible, so I want to do the same using windows and a standard desktop. Obviously, it'd look pretty crappy if the images like the one in the bottom right had a solid background colour.
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 596/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 09-22-05 07:38 AM Link | Quote
Nice. Plan to share?

P.S. - Your taskbar seems to be drunk. It wandered over to the side of the screen...
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7203/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-22-05 07:54 AM Link | Quote
Sure, but don't expect it to be done anytime soon. And vertical taskbars pwn.
BTW, small problem opening files. wallpapers.ini is in C:\Windows, but fopen("wallpapers.ini","rt"); doesn't work (unless the program is actually in C:\Windows). I have to do fopen("c:\\windows\\wallpapers.ini","rt");. C:\Windows is in the system path, though, so shouldn't it look there when it can't find the file?
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Any way to get the desktop image? | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.012 seconds.