Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _swbmp_from_pil_image(img):
if img.mode != "RGBA":
img = img.convert("RGBA")
pybuf = img.tobytes()
rtbuf = _ibuffer(pybuf)
return SoftwareBitmap.create_copy_from_buffer(rtbuf, BitmapPixelFormat.RGBA8, img.width, img.height,
BitmapAlphaMode.STRAIGHT)