Ejemplo n.º 1
0
    def test_full(self):
        data = image_encoding.html_to_png('')

        image = Image.open(data)
        image = image_encoding.crop_384(image)
        image = image_encoding.convert_to_1bit(image)

        n_bytes, _ = image_encoding.rle_from_bw(image)
        self.assertEquals(n_bytes, 3072)
Ejemplo n.º 2
0
    def test_full(self):
        data = image_encoding.html_to_png('')

        image = Image.open(data)
        image = image_encoding.crop_384(image)
        image = image_encoding.threshold(image)

        n_bytes, _ = image_encoding.rle_from_bw(image)
        self.assertEquals(n_bytes, 3072)
Ejemplo n.º 3
0
    def test_full(self):
        data = image_encoding.html_to_png(
            '<html><body style="margin: 0px; height: 10px;"></body></html>')

        image = Image.open(data)
        image = image_encoding.crop_384(image)
        image = image_encoding.convert_to_1bit(image)

        n_bytes, _ = image_encoding.rle_from_bw(image)
        self.assertEquals(n_bytes, 3840)
Ejemplo n.º 4
0
    def test_specific_image_rle(self):
        image = Image.new('1', (3, 3), 0)

        # 3x3 checkerboard
        draw = ImageDraw.Draw(image)
        draw.point((0, 0), 1)
        draw.point((2, 0), 1)
        draw.point((1, 1), 1)
        draw.point((0, 2), 1)
        draw.point((2, 2), 1)

        n_bytes, rle = image_encoding.rle_from_bw(image)
        self.assertEqual(
            rle, b'\x01\x09\x00\x00\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01')
        self.assertEquals(n_bytes, 9)
Ejemplo n.º 5
0
def _payload_from_pixels(pixels):
    """
    :returns: binary payload to be embedded in full message.
    """
    pixel_count, rle_pixels = image_encoding.rle_from_bw(pixels)
    return _encode_pixels(pixel_count, rle_pixels)
Ejemplo n.º 6
0
def _payload_from_pixels(pixels):
    """
    :returns: binary payload to be embedded in full message.
    """
    pixel_count, rle_pixels = image_encoding.rle_from_bw(pixels)
    return _encode_pixels(pixel_count, rle_pixels)
Ejemplo n.º 7
0
 def test_default_pipeline(self):
     n_bytes, _ = image_encoding.rle_from_bw(
         image_encoding.default_pipeline(''))
     self.assertEquals(n_bytes, 3072)
Ejemplo n.º 8
0
 def test_default_pipeline(self):
     n_bytes, _ = image_encoding.rle_from_bw(
         image_encoding.default_pipeline('')
     )
     self.assertEquals(n_bytes, 3072)
Ejemplo n.º 9
0
 def test_default_pipeline(self):
     n_bytes, _ = image_encoding.rle_from_bw(
         image_encoding.default_pipeline(
             '<html><body style="margin: 0px; height: 10px;"></body></html>'
         ))
     self.assertEquals(n_bytes, 3840)