I wrote this tip as I like to change the background image of my login screen and I did not want to manually scale down and copy and paste the image every time. It also shows a nice application of the Image Resizer tool I posted before (see ImageResizer).
Scaling the Image
Since Windows only accepts .jpg images with a size below 256 KB as login background, we have to scale bigger images down before we can use them. The
ImageResizer class described in ImageResizer will take care of that, so I won't go into more details about the scaling process.
The WinForms Application
This is an extremely simple WinForms application. As you can see, there are only two buttons, one for choosing and updating the login screen background image and one for just closing the app. Depending on the size of the chosen image, it will either be copied to the correct location directly or it will be scaled down first. To illustrate this process, take a look at the code of the Form.cs file:
public partial class Form1 : Form
private void FD_Open_File_FileOk_1(object sender, CancelEventArgs e)
const int MAXSIZE = 240 * 1024;
FileInfo fi = new FileInfo(FD_Open_File.FileName);
if (fi.Extension != ".jpg")
MessageBox.Show("ERROR: Please choose an .jpg file!");
if (fi.Length > MAXSIZE)
ImageResizer resizer = new ImageResizer(MAXSIZE, fi.FullName,
MessageBox.Show("Login screen changed successfully!");
private void B_Confirm_Click(object sender, EventArgs e)
private void B_ChoseeImage_Click(object sender, EventArgs e)
As you can see, the code is really straightforward. After clicking on the Choose Image button, we open a file dialog where the user can choose an image. If it is not a .jpg file, the user gets back to the application without a change. Otherwise, we check if the length of the file is bigger than the allowed file size. I have chosen a maximum size of 240 KB even though Windows allows a file size of up to 256 KB to be used as login screen background image because for some reason Windows did not display some images close to this border. Also scaling the pictures down about 16 KB more won't make a huge difference in quality in most cases. For the scaling process itself, I used the
ImageResizer class which is included in the project and can also be found here: ImageResizer. If finally, everything is alright, the image is copied to the correct location on the disk, overwriting the old login screen background image. From now on, Windows will automatically use the chosen image as the login background.
Note: You should start the application as an administrator, otherwise you might not have write-access to the necessary location.
That's it! I hope you find this simple application useful and can make use of it. Any comments, suggestions, and tips are appreciated!