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?
  
User name:
Password:
Reply:
 

UserPost
HyperLamer
Posts: 7203/8210
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?
Elric
Posts: 596/687
Nice. Plan to share?

P.S. - Your taskbar seems to be drunk. It wandered over to the side of the screen...
HyperLamer
Posts: 7199/8210
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
Posts: 594/687
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
Posts: 7189/8210
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.
Kyoufu Kawa
Posts: 2319/2481
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
Posts: 7175/8210
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.
Elric
Posts: 590/687
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.
Dish
Posts: 580/596
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.
HyperLamer
Posts: 7162/8210
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.
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.004 seconds.