def test_rgb_alpha_to_bgra(self): size = (32, 64, 3) rgbim = model.DataArray(numpy.zeros(size, dtype=numpy.uint8)) rgbim[:, :, 0] = 1 rgbim[:, :, 1] = 100 rgbim[:, :, 2] = 200 bgraim = format_rgba_darray(rgbim, 0) # Checks it added alpha channel and set everything to scale self.assertEqual(bgraim.shape, (32, 64, 4)) self.assertTrue((bgraim == 0).all())
def test_rgb_to_bgra(self): size = (32, 64, 3) rgbim = model.DataArray(numpy.zeros(size, dtype=numpy.uint8)) rgbim[:, :, 0] = 1 rgbim[:, :, 1] = 100 rgbim[:, :, 2] = 200 bgraim = format_rgba_darray(rgbim, 255) # Checks it added alpha channel self.assertEqual(bgraim.shape, (32, 64, 4)) self.assertEqual(bgraim[0, 0, 3], 255) # Check the channels were swapped to BGR self.assertTrue((bgraim[1, 1] == [200, 100, 1, 255]).all())