From what I have read in the documentation and some posts I found here in the forum, this function does not expect just an array of RGBA values, but an entire image (file) in memory, and therefore 'data' has to point to the first byte of the file in memory.
But if this is true, I don't know why the second parameter 'size' is needed and how it is interpreted.
If the function expects an entire file, it could determine the size of the image via the file's header, just as loadFromFile probably does (which doesn't expect a size). So I guess I understand something wrong here and hope that someone can explain why this parameter is needed.