Hi everybody. In my free time I decided to do some little research on the format in which trainer photo/icon are saved in S/V.
After some trials and errors, I descovered that each pixel is represented by a sequence of 8 bytes, of which the first 2 represent colors in BGR 565 encoding and the third is some sort of Alpha channel transparency. I'm currently not aware of the purpose of the other bytes, since editing them didn't bring any noticeable change. Then, thanks to this recent commit , I was able to get the correct size and aspect ratio for the images, and I assembled a little python script that I'm attaching to this post.
It is pretty simple to use, just open the save block editor in PkHex, save the image block you desire to see, check the corrisponding values for width - lenght - size (take for reference the previous link until PkHex doesn't get an official update), finally run the script.
For example, if we want to save the current profile picture:
export the block at 0x14C5A101 as 'picture.bin'
check the width at 0xFEAA87DA, e.g. 1440
check the height at 0x5361CEB5, e.g. 832
check size at 0x1E505002, e.g. 599040
let's save the output as 'current.png'
The code in the terminal, after changing directory to the one in which we find both picture.bin and imgdec.py, will be:
python imgdec.py picture.bin 1440 832 599040 -o current.png
In the future I'll try to understand better the other bytes of the encoding and maybe build a little editor/injector for custom images. Of course you are free to make any change you want, and if you want to share new ideas let me know in the replies!
Alongside the script I also attach some example output images from my saves.
imgdec.py