It's for my texture generator. I want to apply this thing so it can pick the two most important colors in a range of 8, it'll be to convert images to characters (that usually have one foreground and background color per line orso, or per character even. So speed is a little bit of an issue, since I'm not going to wait minutes or even some seconds on a result.
This int, in this case just is $00rrggbb, so I require at least 24bits worth of information to store in that int. I could say that '8' is the limit, as this is a sorta classic limitation (per line). But I figured that an algorithm usually doesn't mind values so I figured that a generic routine would do the trick.
I actually did some pattern'izing like this some while ago, but that was on indexed images, this one is meant for normal bitmap images (it's just another texture generator filter).
In the indexed version I only had 16 possible colors, so I just counted whatever indexes there were in the line o' 8 pixels, and put their SHL8 quantities in an array, OR'ed with the index. Then I sorted that array, since the quantity was SHL8'ed, it sorted on quantity. Then I AND'ed the index from the first 8 bits again, et voila. It would btw be so nice if BMax could store the index after sorting somewhere, so one would be able to apply it's changed state on other stuff.
This int, in this case just is $00rrggbb, so I require at least 24bits worth of information to store in that int. I could say that '8' is the limit, as this is a sorta classic limitation (per line). But I figured that an algorithm usually doesn't mind values so I figured that a generic routine would do the trick.
I actually did some pattern'izing like this some while ago, but that was on indexed images, this one is meant for normal bitmap images (it's just another texture generator filter).
In the indexed version I only had 16 possible colors, so I just counted whatever indexes there were in the line o' 8 pixels, and put their SHL8 quantities in an array, OR'ed with the index. Then I sorted that array, since the quantity was SHL8'ed, it sorted on quantity. Then I AND'ed the index from the first 8 bits again, et voila. It would btw be so nice if BMax could store the index after sorting somewhere, so one would be able to apply it's changed state on other stuff.