(self)
Create a graphics ROM from the contents of a 2D image
Create a graphics ROM from the contents of a 2D image
Create a graphics ROM from the contents of a 2D image
def create(self):
        """Create a graphics ROM from the contents of a 2D image"""
        self.open_rom('wb')
        edge = self.edge
        num_tiles = int((self.img.get_width() / edge) * (self.img.get_height() / edge))
        # limit the processing of tiles up to size bytes
        if self.size:
            if self.size//self.multiple<num_tiles:
                num_tiles = self.size//self.multiple
        dpa = pygame.PixelArray(self.img)
        i = self.pos2D_iterator(self.img.get_width())

        for n in range(num_tiles):
            (x, y) = next(i)
            t = pygame.Surface((edge, edge), depth=8)
            tpa = pygame.PixelArray(t)
            tpa[0:edge, 0:edge] = dpa[x:x+edge, y:y+edge]
            self.write_tile_to_rom(t)

        self.close_rom()
def create ( self ) : self . open_rom ( 'wb' ) edge = self . edge num_tiles = int ( ( self . img . get_width ( ) / edge ) * ( self . img . get_height ( ) / edge ) ) # limit the processing of tiles up to size bytes if self . size : if self . size // self . multiple < num_tiles : num_tiles = self . size // self . multiple dpa = pygame . PixelArray ( self . img ) i = self . pos2D_iterator ( self . img . get_width ( ) ) for n in range ( num_tiles ) : ( x , y ) = next ( i ) t = pygame . Surface ( ( edge , edge ) , depth = 8 ) tpa = pygame . PixelArray ( t ) tpa [ 0 : edge , 0 : edge ] = dpa [ x : x + edge , y : y + edge ] self . write_tile_to_rom ( t ) self . close_rom ( )