mirror of
https://github.com/grp/Wii.py.git
synced 2025-06-19 07:15:49 -04:00
removed more png and moved wx to toScreen
This commit is contained in:
parent
019c15daf6
commit
f68eed7c2b
26
TPL.py
26
TPL.py
@ -1,6 +1,4 @@
|
|||||||
import os, hashlib, struct, subprocess, fnmatch, shutil, urllib, array
|
import os, hashlib, struct, subprocess, fnmatch, shutil, urllib, array
|
||||||
import wx
|
|
||||||
import png
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from Crypto.Cipher import AES
|
from Crypto.Cipher import AES
|
||||||
@ -201,7 +199,6 @@ class TPL():
|
|||||||
else:
|
else:
|
||||||
rgba = flatten(inp[x+y*w])
|
rgba = flatten(inp[x+y*w])
|
||||||
i1 = (rgba >> 0) & 0xff
|
i1 = (rgba >> 0) & 0xff
|
||||||
#rgba = img[x + 1 + (y * w)]
|
|
||||||
rgba = flatten(inp[x+1+y*w])
|
rgba = flatten(inp[x+1+y*w])
|
||||||
i2 = (rgba >> 0) & 0xff
|
i2 = (rgba >> 0) & 0xff
|
||||||
|
|
||||||
@ -282,7 +279,6 @@ class TPL():
|
|||||||
g = (rgba >> 8) & 0xff
|
g = (rgba >> 8) & 0xff
|
||||||
b = (rgba >> 16) & 0xff
|
b = (rgba >> 16) & 0xff
|
||||||
newpixel = ((b >>3) << 11) | ((g >>2) << 5) | ((r >>3) << 0)
|
newpixel = ((b >>3) << 11) | ((g >>2) << 5) | ((r >>3) << 0)
|
||||||
#out[outp] = swap16(newpixel)
|
|
||||||
out[outp] = newpixel
|
out[outp] = newpixel
|
||||||
outp += 1
|
outp += 1
|
||||||
return out
|
return out
|
||||||
@ -321,7 +317,6 @@ class TPL():
|
|||||||
newpixel |= r << 10
|
newpixel |= r << 10
|
||||||
newpixel |= g << 5
|
newpixel |= g << 5
|
||||||
newpixel |= b << 0
|
newpixel |= b << 0
|
||||||
#out[outp] = swap16(newpixel)
|
|
||||||
out[outp] = newpixel
|
out[outp] = newpixel
|
||||||
outp += 1
|
outp += 1
|
||||||
return out
|
return out
|
||||||
@ -349,13 +344,11 @@ class TPL():
|
|||||||
z += 1
|
z += 1
|
||||||
if(z == 16):
|
if(z == 16):
|
||||||
for i in range(16):
|
for i in range(16):
|
||||||
print i, w*h*4
|
|
||||||
out[iv] = lr[i]
|
out[iv] = lr[i]
|
||||||
iv += 1
|
iv += 1
|
||||||
out[iv] = la[i]
|
out[iv] = la[i]
|
||||||
iv += 1
|
iv += 1
|
||||||
for i in range(16):
|
for i in range(16):
|
||||||
print i, w*h*4
|
|
||||||
out[iv] = lb[i]
|
out[iv] = lb[i]
|
||||||
iv += 1
|
iv += 1
|
||||||
out[iv] = lg[i]
|
out[iv] = lg[i]
|
||||||
@ -403,7 +396,6 @@ class TPL():
|
|||||||
rgbdata = self.I4((w, h), tpldata)
|
rgbdata = self.I4((w, h), tpldata)
|
||||||
|
|
||||||
elif(tex.format == 1): #I8, 8-bit
|
elif(tex.format == 1): #I8, 8-bit
|
||||||
print w*h, tex.data_off, len(data)-tex.data_off
|
|
||||||
tpldata = struct.unpack(">" + str(w * h) + "B", data[tex.data_off:tex.data_off + (w * h * 1)])
|
tpldata = struct.unpack(">" + str(w * h) + "B", data[tex.data_off:tex.data_off + (w * h * 1)])
|
||||||
rgbdata = self.I8((w, h), tpldata)
|
rgbdata = self.I8((w, h), tpldata)
|
||||||
elif(tex.format == 2): #IA4, 8-bit
|
elif(tex.format == 2): #IA4, 8-bit
|
||||||
@ -457,18 +449,15 @@ class TPL():
|
|||||||
rgbdata = self.CI14X2((w, h), tpldata, paldata)
|
rgbdata = self.CI14X2((w, h), tpldata, paldata)
|
||||||
elif(tex.format == 14):
|
elif(tex.format == 14):
|
||||||
sz = ((w + 7) >> 3) * ((w + 7) >> 3) * 32
|
sz = ((w + 7) >> 3) * ((w + 7) >> 3) * 32
|
||||||
#print sz
|
|
||||||
#print len(data[tex.data_off:])
|
|
||||||
tpldata = struct.unpack(">" + str(sz / 2) + "H", data[tex.data_off:tex.data_off + sz])
|
tpldata = struct.unpack(">" + str(sz / 2) + "H", data[tex.data_off:tex.data_off + sz])
|
||||||
|
|
||||||
rgbdata = self.CMP((w, h), tpldata)
|
rgbdata = self.CMP((w, h), tpldata)
|
||||||
else:
|
else:
|
||||||
raise TypeError("Unsupported TPL Format: " + str(tex.format))
|
raise TypeError("Unsupported TPL Format: " + str(tex.format))
|
||||||
|
|
||||||
#output = png.Writer(width = w, height = h, alpha = True, bitdepth = 8)
|
|
||||||
output = Image.fromstring("RGBA", (w, h), rgbdata)
|
output = Image.fromstring("RGBA", (w, h), rgbdata)
|
||||||
#output.write(open(outfile, "wb"), rgbdata)
|
ext = outfile[outfile.rfind("."):]
|
||||||
output.save(outfile, "PNG")
|
output.save(outfile, ext)
|
||||||
|
|
||||||
return outfile
|
return outfile
|
||||||
def getSizes(self):
|
def getSizes(self):
|
||||||
@ -502,14 +491,13 @@ class TPL():
|
|||||||
class imp(wx.Panel):
|
class imp(wx.Panel):
|
||||||
def __init__(self, parent, id, im):
|
def __init__(self, parent, id, im):
|
||||||
wx.Panel.__init__(self, parent, id)
|
wx.Panel.__init__(self, parent, id)
|
||||||
w = im.GetWidth()
|
w, h = im.size
|
||||||
h = im.GetHeight()
|
|
||||||
wx.StaticBitmap(self, -1, im, ( ((max(w, 300) - w) / 2), ((max(h, 200) - h) / 2) ), (w, h))
|
wx.StaticBitmap(self, -1, im, ( ((max(w, 300) - w) / 2), ((max(h, 200) - h) / 2) ), (w, h))
|
||||||
|
|
||||||
self.toPNG("tmp.png")
|
import wx
|
||||||
img = wx.Image("tmp.png", wx.BITMAP_TYPE_ANY).ConvertToBitmap()
|
self.toImage("tmp.png")
|
||||||
w = img.GetWidth()
|
img = Image.open("tmp.png")
|
||||||
h = img.GetHeight()
|
w, h = img.size
|
||||||
app = wx.App(redirect = True)
|
app = wx.App(redirect = True)
|
||||||
frame = wx.Frame(None, -1, "TPL (" + str(w) + ", " + str(h) + ")", size = (max(w, 300), max(h, 200)))
|
frame = wx.Frame(None, -1, "TPL (" + str(w) + ", " + str(h) + ")", size = (max(w, 300), max(h, 200)))
|
||||||
image = imp(frame, -1, img)
|
image = imp(frame, -1, img)
|
||||||
|
Loading…
Reference in New Issue
Block a user