#raw ํ์ผ , 256x256 ํ๋ฐฑ์ด๋ฏธ์ง 0~255
# 0์ ๊ฐ๊น์ฐ๋ฉด ๊ฒ์ / 255์ ๊ฐ๊น์ฐ๋ฉด ํฐ์
from tkinter import *
def loadImage(fname) :
global inImage, XSIZE,YSIZE
fp = open(fname, 'rb')
for i in range (0,XSIZE):
tmpList = []
for k in range(0, YSIZE) :
data=int(ord(fp.read(1)))
tmpList.append(data)
inImage.append(tmpList)
fp.close()
def displayImage(image) :
global XSIZE,YSIZE
rgbString = ""
for i in range(0,XSIZE):
tmpString = ""
for k in range(0,YSIZE) :
data = image[i][k]
tmpString += "#%02x%02x%02x " % (data,data,data)
rgbString += "{" + tmpString +"} "
paper.put(rgbString)
## ์ ์ญ ๋ณ์ ##
window = None
canvas = None
XSIZE, YSIZE = 256,256
inImage = []
## ๋ฉ์ธ ์ฝ๋ ##
window = Tk()
window.title("ํ๋ฐฑ์ฌ์ง๋ณด๊ธฐ")
canvas = Canvas(window, height=XSIZE, width=YSIZE)
paper = PhotoImage(width = XSIZE, height=YSIZE)
canvas.create_image((XSIZE/2, YSIZE/2), image=paper, state="normal")
filename = '98.raw'
loadImage(filename)
displayImage(inImage)
canvas.pack()
window.mainloop()