I think this is exactly what you should do, loop through the array of pixels,
check for alpha and then discard. Although when you for example would have a
star shape it will not resize the image to be smaller be aware of this.

I think this is exactly what you should do, loop through the array of pixels,
check for alpha and then discard. Although when you for example would have a
star shape it will not resize the image to be smaller be aware of this.