- Home /
Dynamically Remove White - Replace with Alpha
Hello,
Lets say I have an image like this within my application:
Is there any way to dynamically remove the white during runtime? So it becomes something like this:
I know that I can do this by remove the white within an external editor (PS), but I need it to do it during runtime within Unity. Also, these images are also created dynamically during runtime, for example the user might take a photo of a black and white image, and is then loaded into Unity - so having a pre-made alpha channel isn't possible.
I appreciate the help, thanks.
Answer by ryandotdee · Feb 12, 2015 at 02:49 PM
Hi
Pretty sure you would need to use a sprite, not a jpg and use an alpha channel
These images are also being loaded in at runtime. For example, the user might take a photo of a black and white image. I want to be able to remove the white, and replace it with an alpha. So having an alpha channel before hand isn't possible.
ahh, I see. ok well in that case you would have to break the image into pixels and look at all of them in turn, not going to write the code out as there are many examples on the web, here are a couple I found after a search
http://stackoverflow.com/questions/1230188/how-can-i-iterate-through-each-pixel-in-a-gif-image
http://stackoverflow.com/questions/17208254/how-to-change-pixel-color-of-an-image-in-c-net
You should be able to achieve what you are looking for via this route, I am not aware of any in built unity method for doing this, thats not to say it does not exist, i just dont know about it if it does :)