def newImg(self, path): # Destroy old pixels for i in range(self.setSize): self.data = DataManager.getImage(self.path, i) for j in range(self.imgSizeX * self.imgSizeY): self.pixel[i][j].destroy() # New attributes self.path = path self.imageNum = 0 # current image in the data to be viewed self.imgSize = DataManager.getImgSize(path, split=True) self.imgSizeX = self.imgSize[1] self.imgSizeY = self.imgSize[0] self.imgSize = DataManager.getImgSize(path, split=False) self.setSize = DataManager.getSetSize(path) # Number of images in set self.currentPixel = None # Tk.Frame obj self.currentPixelPos = None # int position of pixel in current image # self.pixel is a 2d array containing Tk.Frames. [0] = imageNum, [1] = frames pixel = [] for i in range(self.setSize): pixel.append([]) self.data = DataManager.getImage(self.path, i) for j in range(self.imgSizeX * self.imgSizeY): val = int.from_bytes(self.data[j:j + 1], byteorder='big') pixel[i].append(self.newPixel(val, j)) self.pixel = pixel # Free up some ram self.data = None return
def __init__(self, parent, path): # take data and use datamanager to return imageSize, and ints. # Attributes self.path = path self.imageNum = 0 # current image in the data to be viewed self.imgSize = DataManager.getImgSize(path, split=True) self.imgSizeX = self.imgSize[1] self.imgSizeY = self.imgSize[0] self.imgSize = DataManager.getImgSize(path, split=False) self.setSize = DataManager.getSetSize(path) # Number of images in set self.currentPixel = None # Tk.Frame obj self.currentPixelPos = None # int position of pixel in current image # Pixel holder self.wrapper = Tk.Frame(parent) self.wrapper.grid(row=0, column=0) self.digitDisplay = Tk.Frame(self.wrapper, width=235, height=235) self.digitDisplay.grid_propagate(False) for i in range(self.imgSizeY): self.digitDisplay.grid_rowconfigure(i, weight=1) for i in range(self.imgSizeX): self.digitDisplay.grid_columnconfigure(i, weight=1) self.digitDisplay.grid(row=0, column=0) # EntryBox self.pixelLabel = Tk.Label(self.wrapper, text='No pixel selected') self.pixelLabel.grid(row=1, column=0, sticky='nswe') # self.pixel is a 2d array containing Tk.Frames. [0] = imageNum, [1] = frames pixel = [] for i in range(self.setSize): pixel.append([]) self.data = DataManager.getImage(self.path, i) for j in range(self.imgSizeX * self.imgSizeY): val = int.from_bytes(self.data[j:j + 1], byteorder='big') pixel[i].append(self.newPixel(val, j)) self.pixel = pixel # Free up some ram self.data = None return
def getImgData(self): data = DataManager.getImage(self.path, self.imageNum) return data.tolist() # Convert to list to work around numpy bug