def build_surface_from_8bit_dmd_string(self, str_data, composite_op=None): self.eight_to_RGB_map = VgaDMD.get_palette_ch() self.font_dots = str_data x = 0 y = 0 d = "" for dot in str_data: # get the Byte from the frame data dot = ord(dot) # convert it to the correct RGB pallette color (r, g, b) = self.eight_to_RGB_map[dot] d += r + g + b # # write out the color into the target buffer array # index = y*self.y_offset + x*self.x_offset # #self.pySurface[index:(index+bytes_per_pixel)] = (b,g,r,0) # buffer_interface[index:(index+4)] = (b,g,r,0) # #move to the next dot # x += 1 # if x == self.width: # x = 0 # y += 1 #self.pySurface = pygame.image.fromstring(d,(self.width,self.height),'RGB').convert() # surf = HD_load_file(path) self.pySurface = sdl2_DisplayManager.inst( ).make_texture_from_imagebits(bits=d, width=self.width, height=self.height, mode='RGB', composite_op=composite_op)
def build_surface_from_8bit_dmd_string(self, str_data): self.eight_to_RGB_map = VgaDMD.get_palette_ch() self.font_dots = str_data x = 0 y = 0 d = "" for dot in str_data: # get the Byte from the frame data dot = ord(dot) # convert it to the correct RGB pallette color (r, g, b) = self.eight_to_RGB_map[dot] d += r + g + b # # write out the color into the target buffer array # index = y*self.y_offset + x*self.x_offset # #self.pySurface[index:(index+bytes_per_pixel)] = (b,g,r,0) # buffer_interface[index:(index+4)] = (b,g,r,0) # #move to the next dot # x += 1 # if x == self.width: # x = 0 # y += 1 self.pySurface = pygame.image.fromstring(d, (self.width, self.height), 'RGB').convert()
def build_surface_from_8bit_dmd_string(self, str_data): self.eight_to_RGB_map = VgaDMD.get_palette_ch() self.font_dots = str_data x = 0 y = 0 d = "" for dot in str_data: # get the Byte from the frame data dot = ord(dot) # convert it to the correct RGB pallette color (r,g,b) = self.eight_to_RGB_map[dot] d +=r + g + b # # write out the color into the target buffer array # index = y*self.y_offset + x*self.x_offset # #self.pySurface[index:(index+bytes_per_pixel)] = (b,g,r,0) # buffer_interface[index:(index+4)] = (b,g,r,0) # #move to the next dot # x += 1 # if x == self.width: # x = 0 # y += 1 self.pySurface = pygame.image.fromstring(d,(self.width,self.height),'RGB').convert()
def build_surface_from_8bit_dmd_string(self, str_data, composite_op=None): self.eight_to_RGB_map = VgaDMD.get_palette_ch() self.font_dots = str_data x = 0 y = 0 d = "" for dot in str_data: # get the Byte from the frame data dot = ord(dot) # convert it to the correct RGB pallette color (r,g,b) = self.eight_to_RGB_map[dot] d +=r + g + b # # write out the color into the target buffer array # index = y*self.y_offset + x*self.x_offset # #self.pySurface[index:(index+bytes_per_pixel)] = (b,g,r,0) # buffer_interface[index:(index+4)] = (b,g,r,0) # #move to the next dot # x += 1 # if x == self.width: # x = 0 # y += 1 #self.pySurface = pygame.image.fromstring(d,(self.width,self.height),'RGB').convert() # surf = HD_load_file(path) self.pySurface = sdl2_DisplayManager.inst().make_texture_from_imagebits(bits=d, width=self.width, height=self.height, mode='RGB', composite_op=composite_op)
def convertImageToOldDMD(src): pal_image= Image.new("P", (1,1)) tuplePal = VgaDMD.get_palette() flatPal = [element for tupl in tuplePal for element in tupl] pal_image.putpalette(flatPal) src_rgb = src.convert("RGB").quantize(palette=pal_image) src_p = src_rgb.convert("P") (w,h) = src.size frame = Frame(w, h) for x in range(w): for y in range(h): color = src_p.getpixel((x,y)) frame.set_dot(x=x, y=y, value=color) return frame