Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by oliver-jones · Feb 12, 2015 at 02:42 PM · imageruntimealpha

Dynamically Remove White - Replace with Alpha

Hello,

Lets say I have an image like this within my application:

alt text

Is there any way to dynamically remove the white during runtime? So it becomes something like this:

alt text

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.

01.jpg (63.4 kB)
02.jpg (81.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image oliver-jones · Feb 12, 2015 at 02:51 PM 0
Share

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.

avatar image ryandotdee · Feb 12, 2015 at 02:56 PM 0
Share

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 :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you set a texture's `alpha is transparency` at runtime? 0 Answers

Loading image runtime from file 1 Answer

Unity 5.2 Canvas.RenderOverlays serious fps hit 2 Answers

Runtime created Material only works when clicking in inspector 0 Answers

How to load an image at runtime via WWW correctly 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges