Ported r2576 from ZXing

Original commit message: "Better take on InvertedLuminanceSource --
allow possibility of rotation and efficient un-inversion"