예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #5
0
파일: encoders.py 프로젝트: bentimms/sirius
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)
예제 #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)
예제 #7
0
 def test_default_pipeline(self):
     n_bytes, _ = image_encoding.rle_from_bw(
         image_encoding.default_pipeline(''))
     self.assertEquals(n_bytes, 3072)
예제 #8
0
 def test_default_pipeline(self):
     n_bytes, _ = image_encoding.rle_from_bw(
         image_encoding.default_pipeline('')
     )
     self.assertEquals(n_bytes, 3072)
예제 #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)