I’m trying to write a simple program to change my desktop wallpaper.
I’m using a downloaded jpeg file and I would like to convert it in code.
The problem is the bitmap needs to be 24 bit to display.
How do I do this?
Thanks in advance.
public class ChangeWallpaper
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
public static void Main()
{
Bitmap wallbm = new Bitmap("pic.jpg");
wallbm.Save("pic.bmp");
SystemParametersInfo(20, 0, "pic.bmp", 0x01 | 0x02);
}
}
I couldn’t get Clone to work for some reason.
I was able to get it to work by trial and error by using the following code: