This content has been marked as final. Show 3 replies
hey RR - yeah I know what you mean, it seems that the docs are a bit muddled on this one (along with most of the rest of the examples in the bmpdata class ;) i think that much of the confusion is due to 'ordering' the params in the explanations differently than in the method call... go figure LOL!
but I think i'd go with the threshold method here, seems like palletMap would be cumbersome (although I have yet to use it in anything) but I have used threshold recently to do something just like this and used:
bmp.threshold(bmp, new Rectangle(0,0,w,h), new Point(0,0), '==', 0x00000000, 0xFFFFFFFF, 0xFF000000, false);
so i think the thing to do is:
bmp.threshold(bmp, new Rectangle(0,0,w,h), new Point(0,0), '<', 0x5F000000, 0xFFFFFFFF, 0xFF000000, false);
(all this time working with hex, and i still don't understand how the values are represented - i really should look that up lol, so i 'think' that 0x5F000000 is 50% transparency not certain)
i also 'think' (lol) that the thing with this method is (and it befuddles myself as well :) that the operator and the 'copySource' param are opposing, so that you can change the resulting action of the formula by changing either. above i used == and false - whereas you've used != and true - both should perform the same action, so it's always tough to keep the logic straight!
Thanks. I'm glad to know that I'm not alone in finding this confusing. But you helped me in a big way.
I kept trying to figure out how to do the part where if it is this, change it to my specific color and if it isn't go to transparent (or what have you). I wasn't seeing any different witht he copySource parameter and it was because I was using threshold with the same source and desitnation bitmaps. So even if a pixel failed it was "copied" because it was already there. D'uh! So now I know I need two bitmaps.
I'm still really confused about the values. Okay 50% alpha is 0x7Fxxxxxx and you can just compare the alpha values with a mask of 0xFF000000. And 25% alpha is 0x40xxxxxx. But then here is where I get confused...
I made a square of 75% alpha red. So I would think the value of the pixel would be 0xC0FF0000, but it is reported (using getPixel32().toString(16)) as -3f010000 -- so the alpha component is -0x3f if you trace it out. But it still responds passes the comparison as if it was 0xCO.
I also just tried it with 51% alpha as well. That should be 0x83, but getPixel32().toString(16) shows it as -0x7d.
Well the little file I made to test some of this out helped me and it is good to know that it seems to work. Even if the traces confusing me more. Perhaps I should just have faith in it and not ask it to show me what it is doing!
LMAO! no kidding! do we really 'need' to know...LOL! jk ( of course we do ;)
dang - i should have mentioned that, in my original code I'd used two - I'd noticed that you were only using one bmp - so i threw it in there quick, since you 'can' use the same source image bmp, but of course, not in this type of case.
I sure get confused by the hex value system - i guess it's time to learn what the hecks going on there LOL! but really interesting comparisons there that you've found.