Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
BitmapData.threshold() for CPP target. #72
BitmapData.threshold() implementation for cpp target. Pretty fast! Also tested and accurate - same visuals and return values as Flash API version. Got lots of help from crazysam (Sam Batista) and the HaxeFlixel community on this one.
This is my first pull request, so let me know if I did it wrong or need to fix something!
Three test images are used below: one grid of greyscale values, one grid of bluescale values, and one giant huge benchmark image full of yellow smiley faces (the benchmark color-swaps the yellow shades to cyan).
Probably worth adding a comment above explaining what this does (could just copy a trimmed version from the AS3 docs). The important part is to mention which operation strings are valid: "One of the following comparison operators, passed as a String: "<", "<=", ">", ">=", "==", "!=""
Thanks for the pull request! I like how you've compared the results between flash and cpp :)
However please also make sure that it is haxe3 compatible. As crazysam and the TravisCI build result've suggested, it is that Int32 has to be changed.
And by the way it is a good practice to
Also please remove that command-line.n.
You can make the changes and push to your fork and this pull request will be updated.
Okay... so that makes things complicated. The remaining references to Int32 are for the Int32.ucompare() function, which is pretty central to this implementation. Without ucompare(), the operator comparisons simply don't work - "<" and ">" don't return the right results, which in turn screws up "<=" and ">=".
Is there a Haxe3 alternative to Int32.ucompare() ?
Okay, I think I got it!
Tests with the new ucompare function are below.
I believe this removes the Int32 dependencies. I now have a local ucompare function in BitmapData.hx - this is RealyUniqueName's contribution. I figure this should probably eventually go in some utility class in the Std library - would Math be appropriate? Until someone gives me a better idea I'll just leave it here for now so I don't mess anything up.
I also have a repo for a simple test suite for this function (it generates the test images you see below) in case someone else wants to check my work: