0

I am creating an image in PIL to set as the desktop background using ctypes, however it is incredibly slow to save to a file then pass in the absolute path.

image.save('file.png')
ctypes.windll.user32.SystemParametersInfoW(0x14, 0, 'file.png', 0x2)

Is there anyway to directly pass in the image data, be it by casting to numpy array or bytes directly into the windll to speed up my code?

VicLobato
  • 21
  • 2
  • 2
    I don't think that interface will accept an actual image, only a file name. – Mark Ransom Aug 20 '22 at 02:00
  • Check [\[SO\]: C function called from Python via ctypes returns incorrect value (@CristiFati's answer)](https://stackoverflow.com/a/58611011) for a serious flaw in your code. This is how it should be done: https://stackoverflow.com/q/40574622/4788546. – CristiFati Aug 20 '22 at 03:38

0 Answers0