windows 10 account picture could not be saved
The problem of the windows 10 account picture could not be saved
In this blog post, we will study what are the problems that the windows 10 account picture could not be saved. To accomplish this above task some users try to write a code on the same and then implement it on their machine. So as an example let’s take one of the C# codes for it. For this code to execute one must have an API associated with it. As shown in the below code the programmer generated it by using the accountpicture-ms file. After that, it changes its registry to run the same. The problem that appears in this code is that windows is not able to read the generated file. The code for the same is shown below:
private static readonly byte[] ACCOUNTPICTURE_MS_HEADER = new byte[] { 0xB2, 0xF9, 0x00, 0x00, 0xAE, 0xF9, 0x00, 0x00, 0x31, 0x53, 0x50, 0x53, 0x18, 0xB0, 0x8B, 0x0B, 0x25, 0x27, 0x44, 0x4B, 0x92, 0xBA, 0x79, 0x33, 0xAE, 0xB2, 0xDD, 0xE7, 0xD5, 0x0C }; private static readonly byte[] FIRST_PICTURE_HEADER = new byte[] { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x70, 0x00, 0x34, 0x00, 0x32, 0x00, 0x39, 0x00, 0x34, 0x00, 0x39, 0x00, 0x36, 0x00, 0x37, 0x00, 0x32, 0x00, 0x39, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0x0C, 0x00, 0x00 }; private static readonly byte[] SECOND_PICTURE_HEADER = new byte[] { 0x00, 0x00, 0xBD, 0xEC, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x70, 0x00, 0x34, 0x00, 0x32, 0x00, 0x39, 0x00, 0x34, 0x00, 0x39, 0x00, 0x36, 0x00, 0x37, 0x00, 0x32, 0x00, 0x39, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0xEC, 0x00, 0x00 }; public static byte[] CreateAccountPicture(Image avatar) { Bitmap avatar96 = Utils.ResizeImage(avatar, 96, 96); MemoryStream stream96 = new MemoryStream(); avatar96.Save(stream96, ImageFormat.Jpeg); avatar96.Dispose(); Bitmap avatar448 = Utils.ResizeImage(avatar, 448, 448); MemoryStream stream448 = new MemoryStream(); avatar448.Save(stream448, ImageFormat.Jpeg); avatar448.Dispose(); avatar.Dispose(); byte[] jfif96 = stream96.ToArray(); byte[] jfif448 = stream448.ToArray(); stream96.Close(); stream448.Close(); MemoryStream picture = new MemoryStream(jfif96.Length + jfif448.Length + ACCOUNTPICTURE_MS_HEADER.Length + FIRST_PICTURE_HEADER.Length + SECOND_PICTURE_HEADER.Length); picture.Write(ACCOUNTPICTURE_MS_HEADER, 0, ACCOUNTPICTURE_MS_HEADER.Length); picture.Write(FIRST_PICTURE_HEADER, 0, FIRST_PICTURE_HEADER.Length); picture.Write(jfif96, 0, jfif96.Length); picture.Write(SECOND_PICTURE_HEADER, 0, SECOND_PICTURE_HEADER.Length); picture.Write(jfif448, 0, jfif448.Length); picture.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, 8); byte[] pic = picture.ToArray(); picture.Close(); return pic; }
Solution
The major problem in the above code is that the picture settings must be taken from the registry branch on the system.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\{User_SID}
ImageX is a string parameter with values of 32, 40, 48, 96, 192, 200, 240, and 448. Every item represents the link to the corresponding size image. hence, one should keep in mind the following points to solve the above issue.
- Create a collection of images in the sizes specified above and save the collection to disc.
- In order to be able to write to the HKLM registry hive, execute your code as an administrator.
- Register paths in the database.
- To effect the changes, a reboot or logoff/login may be required.
Also Read: Consider evaluating a polynomial