38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import math
|
|
import numpy as np
|
|
import PIL.Image as Img
|
|
|
|
def import_img(filename, out_name, show=False):
|
|
img = Img.open(filename)
|
|
width, height = img.size
|
|
|
|
#print(width, " ", height)
|
|
|
|
if(show):
|
|
Img.show(img)
|
|
|
|
ptr = open(out_name, "w")
|
|
ptr.write(str(width) + " " + str(height))
|
|
ptr.write("\n")
|
|
for h in range(0,width):
|
|
for w in range(0,height):
|
|
(red, green, blue) = img.getpixel((w,height -1 -h))
|
|
if red * green * blue != 1:
|
|
ptr.write(str(red) + "," + str(green) + "," + str(blue))
|
|
else:
|
|
ptr.write("1,1,1")
|
|
if(w != width-1):
|
|
ptr.write(" ")
|
|
ptr.write("\n")
|
|
|
|
print("Successfully parsed image '", filename, "'")
|
|
ptr.close()
|
|
|
|
import_img("textures/copper_ingot.bmp", "textures/copper.txt")
|
|
import_img("textures/carbon_ingot.bmp", "textures/carbon.txt")
|
|
import_img("textures/iron_ingot.bmp", "textures/iron.txt")
|
|
import_img("textures/gold_ingot.bmp", "textures/gold.txt")
|
|
import_img("textures/tungsten.bmp", "textures/tungsten.txt")
|
|
import_img("textures/nether_star.bmp", "textures/star.txt")
|
|
import_img("textures/zinc_ingot.bmp", "textures/zinc.txt")
|
|
import_img("textures/diamond.bmp", "textures/diamond.txt") |