Exemple #1
0
    def print_matrix(self, matrix, api=None, linefeed=True):
        if api is None:
            api = self.GRAPHICS_API

        max_cols = self.GRAPHICS_MAX_COLS[api]
        cmd = self.GRAPHICS_CMD[api]

        # Check that the given image fits properly with the api, and if not, try to increase the api
        line, line_len = next(
            matrix2graphics(api, matrix, max_cols, self.GRAPHICS_MULTIPLIER))
        if api == GRAPHICS_8BITS and line_len > max_cols:
            api = GRAPHICS_24BITS
            max_cols = self.GRAPHICS_MAX_COLS[api]
            cmd = self.GRAPHICS_CMD[api]

        for line, line_len in matrix2graphics(
                api,
                matrix,
                max_cols,
                self.GRAPHICS_MULTIPLIER,
                # Bematech already center it for us
                centralized=False):
            assert line_len <= max_cols, (line_len, max_cols)
            n2 = 0
            n1 = line_len
            # line_len = n1 + n2 * 256
            while n1 >= 256:
                n2 += 1
                n1 -= 256

            self.write(cmd % (chr(n1), chr(n2), line))
            if linefeed:
                self.write(LINE_FEED)
Exemple #2
0
    def print_matrix(self, matrix, api=None, linefeed=True):
        if api is None:
            api = self.GRAPHICS_API

        max_cols = self.GRAPHICS_MAX_COLS[api]
        cmd = self.GRAPHICS_CMD[api]

        # Check that the given image fits properly with the api, and if not, try to increase the api
        line, line_len = next(matrix2graphics(api, matrix, max_cols, self.GRAPHICS_MULTIPLIER))
        if api == GRAPHICS_8BITS and line_len > max_cols:
            api = GRAPHICS_24BITS
            max_cols = self.GRAPHICS_MAX_COLS[api]
            cmd = self.GRAPHICS_CMD[api]

        for line, line_len in matrix2graphics(api, matrix,
                                              max_cols, self.GRAPHICS_MULTIPLIER,
                                              # Bematech already center it for us
                                              centralized=False):
            assert line_len <= max_cols, (line_len, max_cols)
            n2 = 0
            n1 = line_len
            # line_len = n1 + n2 * 256
            while n1 >= 256:
                n2 += 1
                n1 -= 256

            self.write(cmd % (chr(n1), chr(n2), line))
            if linefeed:
                self.write(LINE_FEED)
Exemple #3
0
    def print_matrix(self, matrix, api=None, linefeed=True, multiplier=None):
        multiplier = multiplier or self.GRAPHICS_MULTIPLIER
        if api is None:
            api = self.GRAPHICS_API

        max_cols = self.GRAPHICS_MAX_COLS[api]
        cmd = self.GRAPHICS_CMD[api]

        # Check that the given image fits properly with the api, and if not, try to increase the api
        line, line_len = next(
            matrix2graphics(api, matrix, max_cols, multiplier))
        if api == GRAPHICS_8BITS and line_len > max_cols:
            api = GRAPHICS_24BITS
            max_cols = self.GRAPHICS_MAX_COLS[api]
            cmd = self.GRAPHICS_CMD[api]

        # Change the space between lines to 0
        self.write(ESC + '3\x00')
        for line, line_len in matrix2graphics(api,
                                              matrix,
                                              max_cols,
                                              multiplier,
                                              centralized=False):
            assert line_len <= max_cols, (line_len, max_cols)
            n2 = 0
            n1 = line_len
            # line_len = n1 + n2 * 256
            while n1 >= 256:
                n2 += 1
                n1 -= 256

            self.write(cmd % (chr(n1), chr(n2), line))
            if linefeed:
                self.write(self.LINE_FEED)

        # Change the space between lines to default
        self.write(ESC + '2')
Exemple #4
0
    def _print_matrix(self, matrix):
        max_cols = self.GRAPHICS_MAX_COLS[self.GRAPHICS_API]
        cmd = self.GRAPHICS_CMD[self.GRAPHICS_API]

        for line, line_len in matrix2graphics(self.GRAPHICS_API, matrix, max_cols, self.GRAPHICS_MULTIPLIER):
            assert line_len <= max_cols
            n2 = 0
            n1 = line_len
            # line_len = n1 + n2 * 256
            while n1 >= 256:
                n2 += 1
                n1 -= 256

            self.write(cmd % (chr(n1), chr(n2), line))
            self.write(LINE_FEED)
Exemple #5
0
    def _print_matrix(self, matrix):
        max_cols = self.GRAPHICS_MAX_COLS[self.GRAPHICS_API]
        cmd = self.GRAPHICS_CMD[self.GRAPHICS_API]

        for line, line_len in matrix2graphics(self.GRAPHICS_API, matrix,
                                              max_cols,
                                              self.GRAPHICS_MULTIPLIER):
            assert line_len <= max_cols
            n2 = 0
            n1 = line_len
            # line_len = n1 + n2 * 256
            while n1 >= 256:
                n2 += 1
                n1 -= 256

            self.write(cmd % (chr(n1), chr(n2), line))
            self.write(LINE_FEED)