MapleStory Finger Point

๐Ÿ’Ž Python/Python_Code

ํ‘๋ฐฑ ์‚ฌ์ง„ ๋งŒ๋“ค๊ธฐ - ํŒŒ์ด์ฌ for Beginner (2ํŒ)

HYEJU01 2024. 3. 30. 04:24
#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()