What ToByteArray actually does is create a 'blob' (byte array) and call Write with that byte array as an argument.
Your comparison with the default .NET encoder does not seem fair. You are writing images in the webP format which is not supported by the .NET encoder. Writing to webP will compress the pixels much better but this will of course cost time.
Your comparison with the default .NET encoder does not seem fair. You are writing images in the webP format which is not supported by the .NET encoder. Writing to webP will compress the pixels much better but this will of course cost time.