Zarklord Posted August 13, 2016 Share Posted August 13, 2016 the title ^ but in all seriousness when ever i have done a if statment that is something like: if (currentPixel.R != 0 && currentPixel.B != 0 && currentPixel.G != 0 && currentPixel.A != 0) { //do something } it doesn't work, and I know that the code isn't exactly correct(it was correct when I tried it in codelab)i was just showing you what i tried basically I want to know if a pixels exists at all(the way i would determine that the code works would be new file ctrl + a then delete and then have it do something so i can know that it doesn't run even once(for instance have it write text that says "failed" inside the if block so that if the if statement is true even once then then ill know). thank you Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted August 13, 2016 Share Posted August 13, 2016 When you delete a selection, it makes pixels in the selection White with zero opacity. As in (255, 255, 255, 0) Your code is looking for Black with zero opacity. As in (0, 0, 0, 0) You may just want to ignore the Color and just check the opacity. Or are the color channels important in your script? Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
MJW Posted August 13, 2016 Share Posted August 13, 2016 If you want to test if a pixel is transparent, do what toe_head2001 suggests: only test if alpha is 0. It's the correct thing to do, and it's easier to boot. I'll mention in passing that you can directly compare colors, such as: if (CurrentPixel != ColorBgra.TransparentBlack) { ....do something } That would be an easier way to do what you did above, but it's not what you should do to test for transparency. EDIT: I should say it's an easier way to do what you seem to want to do. I think you mean to have: if (currentPixel.R != 0 || currentPixel.B != 0 || currentPixel.G != 0 || currentPixel.A != 0) The way it is, it will skip doing something if any of the color components is zero. Quote Link to comment Share on other sites More sharing options...
Zarklord Posted August 14, 2016 Author Share Posted August 14, 2016 thanks i will try that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.