mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-02 07:25:45 -04:00
compose the texture in memory and set the displayed image to it
This commit is contained in:
parent
33f709d8e6
commit
1462e3cc7e
1 changed files with 26 additions and 7 deletions
|
@ -5,10 +5,10 @@ import gtk
|
|||
import gtk.glade
|
||||
|
||||
class Patch:
|
||||
def __init__(self, n,w,h):
|
||||
def __init__(self, n,x,y):
|
||||
self.name = n
|
||||
self.width = w
|
||||
self.height =h
|
||||
self.yoff = x
|
||||
self.xoff =y
|
||||
|
||||
class HellowWorldGTK:
|
||||
"""This is an Hello World GTK application"""
|
||||
|
@ -24,22 +24,41 @@ class HellowWorldGTK:
|
|||
self.wTree = gtk.glade.XML(self.gladefile,"window1")
|
||||
self.image1 = self.wTree.get_widget("orig_texture")
|
||||
|
||||
# parse the example texture
|
||||
# parse the example texture, fetch the width,height;
|
||||
# create Patch objects and stuff them into a list
|
||||
patches = []
|
||||
width,height = 0,0
|
||||
for line in self.example_texture.split("\n"):
|
||||
if len(line) > 0:
|
||||
# texture definition (we hope)
|
||||
if line[0] != '*':
|
||||
name,width,height = line.split()
|
||||
# patch list (we hope)
|
||||
else:
|
||||
junk,name,width,height = line.split()
|
||||
patches.append(Patch(name,width,height))
|
||||
junk,name,y,x= line.split()
|
||||
patches.append(Patch(name,int(x),int(y)))
|
||||
|
||||
# read the patches into pixbufs
|
||||
# a horrid hack to get them client->server side
|
||||
for patch in patches:
|
||||
self.image1.set_from_file(patch.name.lower() + ".gif")
|
||||
patch.pixbuf = self.image1.get_pixbuf()
|
||||
|
||||
self.image1.set_from_file("comp02_1.gif")
|
||||
texbuf = gtk.gdk.Pixbuf(
|
||||
patches[0].pixbuf.get_colorspace(),
|
||||
patches[0].pixbuf.get_has_alpha(),
|
||||
patches[0].pixbuf.get_bits_per_sample(),
|
||||
int(width),
|
||||
int(height))
|
||||
|
||||
# copy each patch into the texture pixbuf
|
||||
for patch in patches:
|
||||
patch.pixbuf.copy_area(0,0,
|
||||
patch.pixbuf.get_width(),
|
||||
patch.pixbuf.get_height(),
|
||||
texbuf, patch.xoff, patch.yoff)
|
||||
|
||||
self.image1.set_from_pixbuf(texbuf)
|
||||
pixbuf = self.image1.get_pixbuf()
|
||||
if pixbuf:
|
||||
scale = 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue